diff options
Diffstat (limited to 'filehooker/root-image/krebs/lib')
| -rw-r--r-- | filehooker/root-image/krebs/lib/filehooker | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/filehooker/root-image/krebs/lib/filehooker b/filehooker/root-image/krebs/lib/filehooker index 90d887bd..c72d4d51 100644 --- a/filehooker/root-image/krebs/lib/filehooker +++ b/filehooker/root-image/krebs/lib/filehooker @@ -5,9 +5,12 @@ ncdc_user=${ncdc_user:-hooker} ncdc_bin=${ncdc_bin:-/usr/bin/ncdc} + ncdc_config(){ # maybe we want to use the running ncdc process and communicate via tmux send-keys ? - (sleep 1;cat;printf "/quit\n") | sudo -u $ncdc_user "$ncdc_bin" + txt="$(cat)" + (sleep 1;printf "%s" "$txt";printf "/quit\n") | sudo -u $ncdc_user "$ncdc_bin" 2>/dev/null || \ + sudo -u $ncdc_user /usr/bin/tmux send-keys -t dcpp:ncdc "$txt" C-m } ncdc_configure_netshare(){ @@ -27,8 +30,8 @@ ncdc_configure_nick(){ } ncdc_configure_hub(){ rnd=`hexdump -n 2 -e '/2 "%u"' /dev/urandom` - hubname="hub_$rnd" hub=${1?adcs://localhost:2781} + hubname="${2:-hub_$rnd}" info "configuring DC Hub: $hub, activating autconnect" info "setting active as true" (echo "/open ${hubname} ${hub}" ; @@ -119,20 +122,27 @@ info "enable tor_announce" systemctl enable tor_announce systemctl start tor_announce } - +is_mounted(){ + cat /etc/mtab| cut -d\ -f 1 | grep -q "^$1$" && info "$1 is already mounted" +} share_all_partitions(){ count=0 - find /dev -name '[shv]d[a-z][0-9]' | while read disk;do - size=$(get_disksize $disk) - if test "$size" -gt "$min_netshare_size"; + # all /dev/sdX and all mapped devices + (find /dev -name '[shv]d[a-z][0-9]';find /dev/mapper ! -type d)| while read disk;do + size=$(get_disksize $disk 2>/dev/null) + + if test "$size" -gt "$min_netshare_size" 2>/dev/null ; #&& ! is_mounted "$disk"; then info "trying disk $disk" mountpoint=/media/vag$count mkdir -p $mountpoint - umount $mountpoint 2>&1 >/dev/null && info "$mountpoint unmounted" || : - ! mount $disk $mountpoint && error "cannot mount $disk" && continue + umount $disk >/dev/null 2>&1 && info "remounting $disk" || : + umount $mountpoint >/dev/null 2>&1 && info "unmounting old mountpoint $mountpoint" || : + ! mount $disk $mountpoint >/dev/null 2>&1 && error "cannot mount $disk" && continue + chown "$ncdc_user" "$mountpoint" : $((count++)) - ncdc_configure_netshare "$mountpoint" "$(basename $mountpoint)" + ncdc_configure_netshare "$mountpoint" "$(basename $mountpoint)" 2>/dev/null + info "$mountpoint is mounted and shared" else info "skipping $disk" fi |
