ssfs diff ssfs-box @ rev 7

Add ssfs-box a saml GTK/Yad interface for the client
author Christophe Lincoln <pankso@slitaz.org>
date Sat Jun 11 08:50:57 2011 +0200 (2011-06-11)
parents
children ef6a5580a9cb
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ssfs-box	Sat Jun 11 08:50:57 2011 +0200
     1.3 @@ -0,0 +1,100 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# SliTaz Secure File Storage GTK user interface using Yad.
     1.7 +#
     1.8 +# Copyright (C) SliTaz GNU/Linux - BSD License
     1.9 +# Author: Christophe Lincoln <pankso@slitaz.org>
    1.10 +#
    1.11 +
    1.12 +app=$(basename $0)
    1.13 +config=$HOME/.config/ssfs/client.lua
    1.14 +
    1.15 +#
    1.16 +# Functions
    1.17 +#
    1.18 +
    1.19 +info() {
    1.20 +	size=$(du -sh $HOME/Sync | awk '{print $1}')
    1.21 +	host=$(fgrep 'host' $config | cut -d '"' -f 2)
    1.22 +	login=${host%@*}
    1.23 +	host=${host#*@}
    1.24 +	echo -e "Login\n$login
    1.25 +Host\n$host
    1.26 +Size\n$size
    1.27 +RSA Key\n~/.ssh/id_rsa"
    1.28 +}
    1.29 +
    1.30 +# Default tools GUI box function.
    1.31 +tools_main() {
    1.32 +	if [ ! -s "$config" ]; then
    1.33 +		$0 setup
    1.34 +	fi
    1.35 +	text=$(gettext "<b>Welcome to Ssfs GTK user interface</b>")
    1.36 +	info | yad \
    1.37 +		--list --title="Ssfs GTK tools" \
    1.38 +		--width=460 --height=280 --image-on-top \
    1.39 +		--text="$text" --image="slitaz-menu" \
    1.40 +		--column "Ssfs" --column "$(gettext "Value")" \
    1.41 +		--button="$(gettext "Edit config"):3" \
    1.42 +		--button="$(gettext "Browse files"):2" \
    1.43 +		--button="gtk-close:1"
    1.44 +}
    1.45 +
    1.46 +# Default tools functions.
    1.47 +tools() {
    1.48 +	# Store box results
    1.49 +	main=$(tools_main)
    1.50 +	# Deal with --button values
    1.51 +	case $? in
    1.52 +		1) exit 0 ;;
    1.53 +		2) file-manager $HOME/Sync ;;
    1.54 +		3) editor $config ;;
    1.55 +		*) continue ;;
    1.56 +	esac
    1.57 +	case $main in
    1.58 +		RSA*)
    1.59 +			yad --text-info --title="RSA Key" \
    1.60 +				--width=560 --height=380 \
    1.61 +				--filename=$HOME/.ssh/id_rsa ;;
    1.62 +		*)
    1.63 +			echo "TODO: $main" ;;
    1.64 +	esac
    1.65 +}
    1.66 +
    1.67 +# Setup GUI box function.
    1.68 +setup_main() {
    1.69 +	text=$(gettext \
    1.70 +"<b>Welcome to Ssfs Setup</b>\n
    1.71 +Any account on a server yet ? You can vist www.slitaz.org
    1.72 +services or setup your own server in a few minutes!\n")
    1.73 +	yad --form --title="Ssfs GTK Setup" \
    1.74 +		--width=460 --height=200 --image-on-top \
    1.75 +		--text="$text" --image="slitaz-menu" \
    1.76 +		--field="Login" --field="Server"
    1.77 +}
    1.78 +
    1.79 +# Default tools functions.
    1.80 +setup() {
    1.81 +	# Store box results and setup.
    1.82 +	main=$(setup_main)
    1.83 +	[ $? == 1 ] && exit 0
    1.84 +	login=$(echo $main | cut -d '|' -f 1)
    1.85 +	host=$(echo $main | cut -d '|' -f 2)
    1.86 +	[ "$host" ] || exit 0
    1.87 +	terminal -hold -geometry 72x10 \
    1.88 +		-e "ssfs setup --login=$login --host=$host"
    1.89 +}
    1.90 +
    1.91 +#
    1.92 +# Commands
    1.93 +#
    1.94 +
    1.95 +case "$1" in
    1.96 +	help)
    1.97 +		echo "Usage: $app [command]" ;;
    1.98 +	setup)
    1.99 +		setup ;;
   1.100 +	*) 
   1.101 +		tools ;;
   1.102 +esac
   1.103 +exit 0