diff options
author | makefu <github@syntax-fehler.de> | 2014-03-17 09:27:05 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2014-03-17 09:27:05 +0100 |
commit | 004afecb81c443a4ab459cfd7f4468ad692f6dd7 (patch) | |
tree | 95c3aa03df3e4a7f26073fd67d8d816a8f395529 /filehooker | |
parent | 50006d90a290a3d3e9c57ed1317062f0500e1890 (diff) |
add ncdc startup script
Diffstat (limited to 'filehooker')
-rw-r--r-- | filehooker/root-image/etc/systemd/system/start-ncdc.service | 13 | ||||
-rw-r--r-- | filehooker/root-image/krebs/bin/start-ncdc.ship | 17 | ||||
-rwxr-xr-x | filehooker/root-image/krebs/bin/tor_announce.ship | 9 | ||||
-rw-r--r-- | filehooker/root-image/krebs/bin/vim_sane_defaults.ship (renamed from filehooker/root-image/krebs/bin/vim_sane_defaults) | 0 | ||||
-rw-r--r-- | filehooker/root-image/krebs/lib/filehooker | 23 | ||||
-rwxr-xr-x | filehooker/root-image/root/customize_root_image.sh | 5 |
6 files changed, 63 insertions, 4 deletions
diff --git a/filehooker/root-image/etc/systemd/system/start-ncdc.service b/filehooker/root-image/etc/systemd/system/start-ncdc.service new file mode 100644 index 00000000..8099678d --- /dev/null +++ b/filehooker/root-image/etc/systemd/system/start-ncdc.service @@ -0,0 +1,13 @@ +[Unit] +Description=ncdc autoconfig +Requires=network.target local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +KillMode=none +ExecStart=sh /krebs/bin/startup_ncdc.ship +ExecStop=sudo -u hooker /usr/bin/tmux send-keys -t dcpp:ncdc "/quit" C-m + +[Install] +WantedBy=multi-user.target diff --git a/filehooker/root-image/krebs/bin/start-ncdc.ship b/filehooker/root-image/krebs/bin/start-ncdc.ship new file mode 100644 index 00000000..393c05cc --- /dev/null +++ b/filehooker/root-image/krebs/bin/start-ncdc.ship @@ -0,0 +1,17 @@ +#!/usr/bin/env ship +set -euf +#@include filehooker +. /krebs/lib/filehooker +#@include network +ncdc_user="hooker" +useradd -m $ncdc_user ||: + +dc_hub="adcs://elch.nsupdate.info:2781" +ncdc_configure_hub "$dc_hub" + +nick=$(get_hostname) +ncdc_configure_nick "$nick" + +share_all_partitions + +sudo -u $ncdc_user /usr/bin/tmux new-session -s dcpp -n ncdc -d ncdc diff --git a/filehooker/root-image/krebs/bin/tor_announce.ship b/filehooker/root-image/krebs/bin/tor_announce.ship index bf9d58dc..ec4f33b6 100755 --- a/filehooker/root-image/krebs/bin/tor_announce.ship +++ b/filehooker/root-image/krebs/bin/tor_announce.ship @@ -6,6 +6,7 @@ #@include tor . /krebs/lib/tor +sleep_time=5 test -w "$torrc" || ( error "$torrc is not writable!"; exit 1 ) || exit 1 configure_hidden_service @@ -14,4 +15,10 @@ test ! -e $hidden_service_dir/hostname && \ systemctl restart tor && \ sleep 1 -cat $hidden_service_dir/hostname | send_irc +while ! internet;do + info "no internet yet, sleeping" + sleep $sleep_time +done + +NICK=$(get_hostname) +cat "$hidden_service_dir/hostname" | send_irc diff --git a/filehooker/root-image/krebs/bin/vim_sane_defaults b/filehooker/root-image/krebs/bin/vim_sane_defaults.ship index fcc7ffcf..fcc7ffcf 100644 --- a/filehooker/root-image/krebs/bin/vim_sane_defaults +++ b/filehooker/root-image/krebs/bin/vim_sane_defaults.ship diff --git a/filehooker/root-image/krebs/lib/filehooker b/filehooker/root-image/krebs/lib/filehooker index 18376465..90d887bd 100644 --- a/filehooker/root-image/krebs/lib/filehooker +++ b/filehooker/root-image/krebs/lib/filehooker @@ -14,7 +14,9 @@ ncdc_configure_netshare(){ : "${1?provide path to share}" rnd=`hexdump -n 2 -e '/2 "%u"' /dev/urandom` rnd_name="${2:-share_$rnd}" - info "adding share" + info "removing old share $rnd_name" + (echo "/unshare $rnd_name" ) | ncdc_config + info "adding share $rnd_name ($1)" (echo "/share $rnd_name $1") | ncdc_config } @@ -117,3 +119,22 @@ info "enable tor_announce" systemctl enable tor_announce systemctl start tor_announce } + +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"; + 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 + : $((count++)) + ncdc_configure_netshare "$mountpoint" "$(basename $mountpoint)" + else + info "skipping $disk" + fi + done +} diff --git a/filehooker/root-image/root/customize_root_image.sh b/filehooker/root-image/root/customize_root_image.sh index 7bbbfe02..2f5579d9 100755 --- a/filehooker/root-image/root/customize_root_image.sh +++ b/filehooker/root-image/root/customize_root_image.sh @@ -26,8 +26,8 @@ chmod 440 /etc/sudoers.d/g_wheel sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist sed -i 's/#\(Storage=\)auto/\1volatile/' /etc/systemd/journald.conf -/krebs/bin/vim_sane_defaults -sudo -u pimp /krebs/bin/vim_sane_defaults +/krebs/bin/vim_sane_defaults.ship +sudo -u pimp /krebs/bin/vim_sane_defaults.ship test -e /usr/bin/ncdc || \ curl http://dev.yorhel.nl/download/ncdc-linux-x86_64-1.19.tar.gz | \ @@ -38,5 +38,6 @@ systemctl enable multi-user.target \ choose-mirror.service \ tor-announce.service \ filehooker-hostname.service \ + start-ncdc.service \ sshd.service \ tor.service |