diff options
Diffstat (limited to 'etc/functions')
-rw-r--r-- | etc/functions/confirm_no | 3 | ||||
-rw-r--r-- | etc/functions/confirm_yes | 9 | ||||
-rwxr-xr-x | etc/functions/newsbeuter | 12 | ||||
-rwxr-xr-x | etc/functions/off | 6 | ||||
-rwxr-xr-x | etc/functions/put | 29 |
5 files changed, 46 insertions, 13 deletions
diff --git a/etc/functions/confirm_no b/etc/functions/confirm_no new file mode 100644 index 0000000..c69b4c6 --- /dev/null +++ b/etc/functions/confirm_no @@ -0,0 +1,3 @@ +## vim:ft=zsh +echo -n "$* [y/N] " +read -q diff --git a/etc/functions/confirm_yes b/etc/functions/confirm_yes new file mode 100644 index 0000000..7389d1d --- /dev/null +++ b/etc/functions/confirm_yes @@ -0,0 +1,9 @@ +## vim:ft=zsh +echo -n "$* [Y/n] " +read -k 1 +[[ $REPLY != $'\n' ]] && echo +if [[ $REPLY == 'y' || $REPLY == 'Y' || $REPLY == $'\n' ]] { + true +} else { + false +} diff --git a/etc/functions/newsbeuter b/etc/functions/newsbeuter new file mode 100755 index 0000000..bd0e217 --- /dev/null +++ b/etc/functions/newsbeuter @@ -0,0 +1,12 @@ +## vim:ft=zsh +autoload fdie + +function __sync { + if [[ $HOST != aneurysm ]] { + unisync unison aneurysm .newsbeuter || fdie "sync failed" + } +} + +__sync || return 1 +command newsbeuter $* +__sync diff --git a/etc/functions/off b/etc/functions/off index 12555d3..9af768a 100755 --- a/etc/functions/off +++ b/etc/functions/off @@ -44,7 +44,11 @@ if [[ $force != 1 && $hosts[$HOST] == *:server:* ]] { return 1 } -execute uinit stop-all +if pgrep -x amarokapp &> /dev/null; then + execute dcop amarok MainApplication-Interface quit +fi + +execute uinit -o text stop-all for line in $(cat /etc/fstab); { if [[ $line == *[12] ]] { filesystems+=${${(s: :)line}[1]} diff --git a/etc/functions/put b/etc/functions/put index 4f408ca..7c0354a 100755 --- a/etc/functions/put +++ b/etc/functions/put @@ -9,7 +9,7 @@ autoload check_com fdie warn typeset hostname typeset -a ssh_options hosts typeset target_dir server_prefix -typeset file +typeset file remote_file illegal typeset -i n_hosts n_ping n_curl if ! check_com curl; then @@ -22,13 +22,12 @@ function put_aneurysm_vpn { ssh_options=(-q) target_dir='public_html/tmp/' server_prefix='http://aneurysm.wildernet.org/~derf/tmp/' + illegal='*.(cgi|pl|php|py)' } function put_aneurysm_int { + put_aneurysm hostname='aneurysm' - ssh_options=(-q) - target_dir='public_html/tmp/' - server_prefix='https://derf.homelinux.org/~derf/tmp/' } function put_aneurysm () { @@ -36,10 +35,11 @@ function put_aneurysm () { ssh_options=(-q) target_dir='public_html/tmp/' server_prefix='https://derf.homelinux.org/~derf/tmp/' + illegal='*.(cgi|pl|php|py)' } function put_sievert () { - hostname='sievert.tabularazor.org' + hostname='sievert' ssh_options=(-q) target_dir='www/tmp/' server_prefix='https://tabularazor.org/~derf/tmp/' @@ -57,17 +57,22 @@ while [[ $1 == -* ]] { shift } + n_hosts=$#hosts if [[ -f $1 ]] { file=$1 while (( $#hosts )) { + remote_file=${file:t} put_$hosts[1] ping -c 1 $hostname &> /dev/null || ping6 -c 1 $hostname &> /dev/null if (( ? == 0 )) { - scp $ssh_options $file $hostname:$target_dir - ssh $ssh_options $hostname "chmod 644 $target_dir${file:t}" - if $(curl -fI $server_prefix${file:t} &> /dev/null); then - echo $server_prefix${file:t} + if [[ $remote_file == ${~illegal} ]] { + remote_file=${remote_file:r} + } + scp $ssh_options $file $hostname:$target_dir/$remote_file + ssh $ssh_options $hostname "chmod 644 $target_dir$remote_file" + if $(curl -fI $server_prefix$remote_file &> /dev/null); then + echo $server_prefix$remote_file return 0 else (( n_curl++ )) @@ -77,9 +82,9 @@ if [[ -f $1 ]] { } shift hosts } - fdie "Tried uploading to $n_hosts hosts without success\n" \ - " - $n_ping hosts are unreachable\n" \ - " - $n_curl errors while uploading" + fdie "Tried uploading to $n_hosts hosts without success" + ((n_ping)) && fdie " - $n_ping hosts are unreachable" + ((n_curl)) && fdie " - $n_curl errors while uploading" } else { fdie "$1: No such file" } |