# HG changeset patch # User Christophe Lincoln # Date 1335966999 -7200 # Node ID 8e6a203e0881bd511745a311833810295da050ed # Parent ac3b66b7cd05bb4f0c22e79b030eb9325b937d5d Add new scp-box diff -r ac3b66b7cd05 -r 8e6a203e0881 Makefile --- a/Makefile Tue May 01 12:47:28 2012 +0200 +++ b/Makefile Wed May 02 15:56:39 2012 +0200 @@ -29,7 +29,7 @@ @echo -n "Generating SliTaz Boxes pot file... " @xgettext -o po/slitaz-boxes/slitaz-boxes.pot -L Shell \ --package-name="SliTaz Boxes" \ - ./boxes/wifi-box ./boxes/burn-box + ./boxes/wifi-box ./boxes/burn-box ./boxes/scp-box @echo "done" tazbox-pot: diff -r ac3b66b7cd05 -r 8e6a203e0881 applications/scp-box.desktop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/applications/scp-box.desktop Wed May 02 15:56:39 2012 +0200 @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=SCP Secure copy +Name[fr]=Copie sécurisée SCP +Name[pt]=SCP Cópia Segura de Arquivos +Name[pt_BR]=SCP Cópia Segura de Arquivos +Exec=scp-box +Icon=folder-remote +Type=Application +Categories=Application;Network; diff -r ac3b66b7cd05 -r 8e6a203e0881 applications/tazinst-doc.desktop --- a/applications/tazinst-doc.desktop Tue May 01 12:47:28 2012 +0200 +++ b/applications/tazinst-doc.desktop Wed May 02 15:56:39 2012 +0200 @@ -4,7 +4,7 @@ Name[pt]=Manual do Tazinst Name[pt_BR]=Manual do Tazinst Name[fr]=Manuel de Tazinst -Exec=browser file:///usr/share/doc/slitaz-tools/tazinst.html +Exec=browser file:///usr/share/doc/slitaz/tazinst.html Icon=text-html Type=Application Categories=Documentation; diff -r ac3b66b7cd05 -r 8e6a203e0881 boxes/scp-box --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/boxes/scp-box Wed May 02 15:56:39 2012 +0200 @@ -0,0 +1,142 @@ +#!/bin/sh +# +# SCP Box - Small front end to the secure file copy utility. +# +# Copyright (C) 2008-2012 SliTaz GNU/Linux - BSD License +# +# Author: Christophe Lincoln +# +. /lib/libtaz.sh + +[ "$file" ] || file="$HOME" +[ "$dir" ] || dir="$HOME" + +# Internal variables (we need a space before options). +config=$HOME/.config/scpbox +icon=/usr/share/pixmaps/slitaz-icon.png +term="xterm -geometry 80x16" +scpopts=" -r -P 22" + +# Make sure we have a config files. +if [ ! -d "$config" ] || [ -f "$config/hosts" ]; then + mkdir -p $config + touch $config/hosts && chmod 0600 $config/hosts +fi + +# +# Functions +# + +# Help and usage +usage() { + cat << EOT + +$(gettext "Usage:") $(basename $0) [command|option] + +$(gettext "Commands:") + list-hosts $(gettext "List all know hosts") + +$(gettext "Options:") + --file=/path/to/file + --dir=/path/to/directory + +$(gettext "Examples:") + $(basename $0) --file=/path/to/file + +EOT +} + +# List last used hosts. +list_hosts() { + for h in $(cat $config/hosts) + do + echo -n "!$h" + done +} + +# Main GUI box function with pure Yad spec +scpbox_main() { + text=$(gettext "Secure copy - Copy files remotly with scp") + yad --form --title="SCP Box" --window-icon=$icon \ + --image=folder-remote --image-on-top \ + --height=320 --width=500 --text="$text" \ + --field="$(gettext "User name:")" \ + --field="$(gettext "Hostname:")" \ + --field="$(gettext "Know hosts:")":CB \ + --field="$(gettext "Options:")" \ + --field="$(gettext "Local file:")":FL \ + --field="$(gettext "Local directory:")":DIR \ + --field="$(gettext "Remote path:")" \ + --button="$(gettext "Download")":2 \ + --button="$(gettext "Upload")":0 \ + --button="gtk-close":1 \ + "$USER" "" "$(list_hosts)" "$scpopts" "$file" "$dir" "" +} + +# Main function +scpbox() { + # Store box results + main=$(scpbox_main) + ret=$? + [ "$debug" ] && echo "DEBUG: main=$main" + + user=$(echo $main | cut -d "|" -f 1) + hostname=$(echo $main | cut -d "|" -f 2) + options=$(echo $main | cut -d "|" -f 4) + remote=$(echo $main | cut -d "|" -f 7) + + # Use and store new hostname. + if [ "$hostname" ]; then + echo "$hostname" >> $config/hosts + host="$hostname" + else + host=$(echo $main | cut -d "|" -f 3) + fi + if [ "$host" == "(null)" ] || [ ! "$host" ]; then + echo "No host: exit" && exit 0 + fi + + # Deal with --button values + case $ret in + 0) + # Upload: do we have a single file or a directory (skip $HOME) + file=$(echo $main | cut -d "|" -f 5) + dir=$(echo $main | cut -d "|" -f 6) + if [ -f "$file" ]; then + local="$file" + elif [ "$dir" != "$HOME" ]; then + local="$dir" + else + echo "No file: exit" && exit 0 + fi + cmd="scp $options $local $user@$host:$remote" + [ "$debug" ] && echo "DEBUG: $cmd" + $term -e "$cmd" ;; + 2) + # Download: we need a remote a file. + local=$(echo $main | cut -d "|" -f 6) + if [ ! "$remote" ]; then + echo "No remote file: exit" && exit 0 + fi + cmd="scp $options $user@$host:$remote $local" + [ "$debug" ] && echo "DEBUG: $cmd" + $term -e "$cmd" ;; + *) + exit 0 ;; + esac +} + +# +# Commands +# + +case "$1" in + list-hosts) + list_hosts ;; + ""|--*) + scpbox ;; + *) + usage ;; +esac + +exit 0 diff -r ac3b66b7cd05 -r 8e6a203e0881 doc/style.css --- a/doc/style.css Tue May 01 12:47:28 2012 +0200 +++ b/doc/style.css Wed May 02 15:56:39 2012 +0200 @@ -1,7 +1,7 @@ /* CSS style for SliTaz Doc */ html { min-height: 102%; } -body { font: 88% sans-serif, vernada, arial; margin: 0; } +body { font: 13px sans-serif, vernada, arial; margin: 0; } h1 { margin: 0; padding: 8px; color: #fff; font-size: 20px; } h2 { color: #d66018; } h3 { color: #666; font-size: 140%; } a:hover { text-decoration: none; }