ssfs annotate ssfs-box @ rev 109
Remove ashism ==
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Feb 26 12:27:01 2019 +0100 (2019-02-26) |
parents | 10d2e9fb6131 |
children |
rev | line source |
---|---|
pankso@7 | 1 #!/bin/sh |
pankso@7 | 2 # |
pankso@7 | 3 # SliTaz Secure File Storage GTK user interface using Yad. |
pankso@7 | 4 # |
pankso@7 | 5 # Copyright (C) SliTaz GNU/Linux - BSD License |
pankso@7 | 6 # Author: Christophe Lincoln <pankso@slitaz.org> |
pankso@7 | 7 # |
pankso@7 | 8 |
pankso@7 | 9 app=$(basename $0) |
pankso@7 | 10 config=$HOME/.config/ssfs/client.lua |
pankso@51 | 11 pixmap=/usr/share/pixmaps/ssfs.png |
pankso@7 | 12 |
pankso@73 | 13 # Internationalization |
pankso@73 | 14 . /usr/bin/gettext.sh |
pankso@73 | 15 TEXTDOMAIN='ssfs' |
pankso@73 | 16 export TEXTDOMAIN |
pankso@73 | 17 |
pankso@7 | 18 # |
pankso@7 | 19 # Functions |
pankso@7 | 20 # |
pankso@7 | 21 |
pankso@7 | 22 info() { |
pankso@7 | 23 size=$(du -sh $HOME/Sync | awk '{print $1}') |
pankso@51 | 24 files=$(find $HOME/Sync | wc -l) |
pankso@7 | 25 host=$(fgrep 'host' $config | cut -d '"' -f 2) |
pankso@7 | 26 login=${host%@*} |
pankso@7 | 27 host=${host#*@} |
pankso@7 | 28 echo -e "Login\n$login |
pankso@7 | 29 Host\n$host |
pankso@7 | 30 Size\n$size |
pankso@51 | 31 Files\n$files |
pankso@7 | 32 RSA Key\n~/.ssh/id_rsa" |
pankso@7 | 33 } |
pankso@7 | 34 |
pankso@7 | 35 # Default tools GUI box function. |
pankso@7 | 36 tools_main() { |
pankso@7 | 37 if [ ! -s "$config" ]; then |
pankso@10 | 38 $0 setup && exit 0 |
pankso@7 | 39 fi |
pankso@81 | 40 [ "$opts" ] || opts="--width=520 --height=320" |
pankso@68 | 41 text=$(gettext "<b>Welcome to the Ssfs Client user interface</b>") |
pankso@51 | 42 info | yad $opts \ |
pankso@51 | 43 --list --title="Ssfs Box" \ |
pankso@51 | 44 --image-on-top --window-icon=$pixmap \ |
pankso@51 | 45 --text="$text" --image=$pixmap \ |
pankso@7 | 46 --column "Ssfs" --column "$(gettext "Value")" \ |
pankso@81 | 47 --button="$(gettext "Setup client"):5" \ |
pankso@81 | 48 --button="$(gettext "Edit config"):4" \ |
pankso@81 | 49 --button="$(gettext "Browse files"):3" \ |
pankso@81 | 50 --button="$(gettext "SSH Login"):2" \ |
pankso@7 | 51 --button="gtk-close:1" |
pankso@7 | 52 } |
pankso@7 | 53 |
pankso@7 | 54 # Default tools functions. |
pankso@7 | 55 tools() { |
pankso@7 | 56 # Store box results |
pankso@7 | 57 main=$(tools_main) |
pankso@7 | 58 # Deal with --button values |
pankso@7 | 59 case $? in |
pankso@7 | 60 1) exit 0 ;; |
pankso@81 | 61 2) terminal -e "ssfs login" ;; |
pankso@81 | 62 3) file-manager $HOME/Sync ;; |
pankso@81 | 63 4) editor $config ;; |
pankso@81 | 64 5) $0 setup ;; |
pankso@7 | 65 *) continue ;; |
pankso@7 | 66 esac |
pankso@7 | 67 case $main in |
pankso@81 | 68 Files*) file-manager $HOME/Sync ;; |
pankso@7 | 69 RSA*) |
pankso@7 | 70 yad --text-info --title="RSA Key" \ |
pankso@51 | 71 --width=560 --height=420 \ |
pankso@81 | 72 --filename=$HOME/.ssh/id_rsa \ |
pankso@81 | 73 --button="gtk-close:1" ;; |
pankso@7 | 74 *) |
pankso@51 | 75 continue ;; |
pankso@7 | 76 esac |
pankso@7 | 77 } |
pankso@7 | 78 |
pankso@7 | 79 # Setup GUI box function. |
pankso@7 | 80 setup_main() { |
pankso@7 | 81 text=$(gettext \ |
paul@12 | 82 "<b>Welcome to the Ssfs Setup</b>\n |
pankso@7 | 83 Any account on a server yet ? You can vist www.slitaz.org |
pankso@7 | 84 services or setup your own server in a few minutes!\n") |
pankso@78 | 85 yad --form --title="Ssfs Setup" \ |
pankso@51 | 86 --window-icon=$pixmap \ |
pankso@7 | 87 --width=460 --height=200 --image-on-top \ |
pankso@51 | 88 --text="$text" --image=$pixmap \ |
pankso@7 | 89 --field="Login" --field="Server" |
pankso@7 | 90 } |
pankso@7 | 91 |
pankso@7 | 92 # Default tools functions. |
pankso@7 | 93 setup() { |
pankso@7 | 94 # Store box results and setup. |
pankso@7 | 95 main=$(setup_main) |
pascal@109 | 96 [ $? = 1 ] && exit 0 |
pankso@7 | 97 login=$(echo $main | cut -d '|' -f 1) |
pankso@7 | 98 host=$(echo $main | cut -d '|' -f 2) |
pankso@7 | 99 [ "$host" ] || exit 0 |
pankso@49 | 100 rm -f $config |
pankso@55 | 101 terminal -hold -geometry 76x16 -T "Ssfs" \ |
pankso@7 | 102 -e "ssfs setup --login=$login --host=$host" |
pankso@7 | 103 } |
pankso@7 | 104 |
pankso@51 | 105 # Notification mode. |
pankso@51 | 106 notify() { |
pankso@81 | 107 export opts="--geometry=520x320-40+40 --timeout=6 --skip-taskbar" |
pankso@51 | 108 yad --notification --image=$pixmap --command=$0 \ |
pankso@51 | 109 --text="$(gettext "Ssfs Live Sync storage")" |
pankso@51 | 110 } |
pankso@51 | 111 |
pankso@7 | 112 # |
pankso@7 | 113 # Commands |
pankso@7 | 114 # |
pankso@7 | 115 |
pankso@7 | 116 case "$1" in |
pankso@7 | 117 help) |
pankso@7 | 118 echo "Usage: $app [command]" ;; |
pankso@7 | 119 setup) |
pankso@7 | 120 setup ;; |
pankso@51 | 121 notify) |
pankso@51 | 122 notify ;; |
pankso@51 | 123 *) |
pankso@7 | 124 tools ;; |
pankso@7 | 125 esac |
pankso@7 | 126 exit 0 |