diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-18 15:38:27 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-18 15:38:27 +0200 |
commit | 188134c9c5e7e3557bb4f1ce5dc77e77b9947749 (patch) | |
tree | 695934c01ec9b67449de2918b9e8bb27f3c3dc21 /etc | |
parent | e7819c83a692c8290cbea43252710cf2d1c39b25 (diff) |
Added put function
Diffstat (limited to 'etc')
-rw-r--r-- | etc/function | 2 | ||||
-rw-r--r-- | etc/functions/fdie | 2 | ||||
-rw-r--r-- | etc/functions/put | 42 |
3 files changed, 46 insertions, 0 deletions
diff --git a/etc/function b/etc/function index 8fc9d2c..2bdbb97 100644 --- a/etc/function +++ b/etc/function @@ -1,7 +1,9 @@ +## vim:ft=zsh autoload chpwd extr plonkhost world-readable youtube-watch autoload reload autoload rtab autoload xexport xsource +autoload put autoload throw catch diff --git a/etc/functions/fdie b/etc/functions/fdie new file mode 100644 index 0000000..10c4ed5 --- /dev/null +++ b/etc/functions/fdie @@ -0,0 +1,2 @@ +echo -e "${fail}${*}${reset}" +return 1 diff --git a/etc/functions/put b/etc/functions/put new file mode 100644 index 0000000..70a3ec9 --- /dev/null +++ b/etc/functions/put @@ -0,0 +1,42 @@ +## vim:ft=zsh + +autoload fdie +typeset hostname +typeset -a ssh_options hosts +typeset target_dir server_prefix +typeset file + +function put_aneurysm () { + hostname='derf.homelinux.org' + ssh_options=(-q) + target_dir='public_html/tmp/' + server_prefix='https://derf.homelinux.org/~derf/tmp/' +} + +function put_sievert () { + hostname='sievert.tabularazor.org' + ssh_options=(-q) + target_dir='www/tmp/' + server_prefix='https://tabularazor.org/~derf/tmp/' +} + +hosts=(aneurysm sievert) + +if [[ -f $1 ]] { + file=${1:t} + while (( $#hosts )) { + put_$hosts[1] + ping -c 1 $hostname &> /dev/null + if (( ? == 0 )) { + scp $ssh_options $file $hostname:$target_dir + ssh $ssh_options $hostname "chmod 644 $target_dir$file" + echo $server_prefix$file + return 0 + } else { + shift hosts + } + } + fdie "No hosts reachable" +} else { + fdie "$1: No such file" +} |