summaryrefslogtreecommitdiff
path: root/etc/functions
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-12-18 08:21:51 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2008-12-18 08:22:01 +0100
commit4eb90213ec3c7c32448bc4a59edc8e1ed1ec2d98 (patch)
treee6407daf5901b26a2a5402bac0e3de17a89bf0c4 /etc/functions
parent22683afb6b4eab721eac56bfdf35da20514a53e1 (diff)
put: Implemented $something_like_host_classes or so
(also, put supports IPv6 now)
Diffstat (limited to 'etc/functions')
-rwxr-xr-xetc/functions/put23
1 files changed, 20 insertions, 3 deletions
diff --git a/etc/functions/put b/etc/functions/put
index a24be62..4f408ca 100755
--- a/etc/functions/put
+++ b/etc/functions/put
@@ -17,6 +17,13 @@ if ! check_com curl; then
warn "curl not present, won't be able to check upload success"
fi
+function put_aneurysm_vpn {
+ hostname='aneurysm.wildernet.org'
+ ssh_options=(-q)
+ target_dir='public_html/tmp/'
+ server_prefix='http://aneurysm.wildernet.org/~derf/tmp/'
+}
+
function put_aneurysm_int {
hostname='aneurysm'
ssh_options=(-q)
@@ -38,14 +45,24 @@ function put_sievert () {
server_prefix='https://tabularazor.org/~derf/tmp/'
}
+hosts_vpn=(aneurysm_vpn)
hosts=(aneurysm_int aneurysm sievert)
-n_hosts=$#hosts
+while [[ $1 == -* ]] {
+ case $1 in
+ *)
+ (( $(eval echo '$#'hosts_${1#-}) )) && eval hosts=\(\$hosts_${1#-}\)
+ ;;
+ esac
+ shift
+}
+
+n_hosts=$#hosts
if [[ -f $1 ]] {
file=$1
while (( $#hosts )) {
put_$hosts[1]
- ping -c 1 $hostname &> /dev/null
+ 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}"
@@ -57,8 +74,8 @@ if [[ -f $1 ]] {
fi
} else {
(( n_ping++ ))
- shift hosts
}
+ shift hosts
}
fdie "Tried uploading to $n_hosts hosts without success\n" \
" - $n_ping hosts are unreachable\n" \