summaryrefslogtreecommitdiffstats
path: root/ship
diff options
context:
space:
mode:
Diffstat (limited to 'ship')
-rw-r--r--ship/lib/filehooker6
-rw-r--r--ship/lib/network11
-rw-r--r--ship/lib/retiolum16
3 files changed, 27 insertions, 6 deletions
diff --git a/ship/lib/filehooker b/ship/lib/filehooker
index 3c881f91..72be751a 100644
--- a/ship/lib/filehooker
+++ b/ship/lib/filehooker
@@ -13,7 +13,6 @@ ncdc_configure_netshare(){
rnd=`hexdump -n 2 -e '/2 "%u"' /dev/urandom`
rnd_name="${2:-share_$rnd}"
info "adding share"
-
(echo "/share $rnd_name $1") | ncdc_config
}
@@ -32,11 +31,12 @@ ncdc_configure_hub(){
echo "/hset autoconnect true") | ncdc_config
}
-
-ncdc_install(){
+ncdc_download(){
install_dir="$(dirname "${ncdc_bin}")"
info "installing ncdc to $install_dir"
curl http://dev.yorhel.nl/download/ncdc-linux-x86_64-1.19.tar.gz | tar xz -C "$install_dir"
+}
+ncdc_install(){
useradd -m $ncdc_user ||:
}
diff --git a/ship/lib/network b/ship/lib/network
index bc4d1047..6c8970a0 100644
--- a/ship/lib/network
+++ b/ship/lib/network
@@ -76,6 +76,17 @@ run_telnet(){
port="$2"
$(which_telnet) "$host" "$port"
}
+port_open(){
+ # $1 - host
+ # $2 - port
+ # nc -zw 2 $1 $2
+ echo | run_telnet "$1" "$2" & pid=$!
+ { sleep 5; kill $pid;} & wid=$!
+ wait $pid
+ RET=$?
+ kill $wid >/dev/null 2>&1
+ return $RET
+}
send_irc(){
## reads from stdin, writes to IRC
diff --git a/ship/lib/retiolum b/ship/lib/retiolum
index 1e55041c..eba2775e 100644
--- a/ship/lib/retiolum
+++ b/ship/lib/retiolum
@@ -23,7 +23,17 @@ refresh_supernode_keys(){
fi
done && return 1
}
-
+port_open(){
+ # $1 - host
+ # $2 - port
+ # nc -zw 2 $1 $2
+ echo | run_telnet "$1" "$2" & pid=$!
+ { sleep 5; kill $pid;} & wid=$!
+ wait $pid
+ RET=$?
+ kill $wid >/dev/null 2>&1
+ return $RET
+}
find_supernodes(){
cd $hosts_dir
set +f
@@ -37,7 +47,7 @@ find_supernodes(){
' $name`"; then
port=${Port-655}
for host in $Address; do
- if nc -zw 2 $host $port 2>/dev/null; then
+ if port_open $host $port 2>/dev/null; then
echo "$name [('$host', $port)]"
fi &
done
@@ -63,7 +73,7 @@ find_active_nodes(){
' $name`"; then
port=${Port-655}
for host in $Address; do
- if nc -zw 2 $host $port 2>/dev/null; then
+ if port_open $host $port 2>/dev/null; then
echo "$name [('$host', $port)]"
fi &
done