#@include core . /krebs/lib/core #@include network . /krebs/lib/network 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 ? txt="$(cat)" # printf "%s" "$txt" ! sudo -u $ncdc_user /usr/bin/tmux has-session -t dcpp && echo "ncdc session must be running" && exit 1 sudo -u $ncdc_user /usr/bin/tmux send-keys -t dcpp:ncdc "$txt" C-m } ncdc_configure_netshare(){ : "${1?provide path to share}" rnd=`hexdump -n 2 -e '/2 "%u"' /dev/urandom` rnd_name="${2:-share_$rnd}" 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 } ncdc_configure_nick(){ nick=${1?nick must be provided} info "configuring DC Nick: $nick" echo "/nick $nick" | ncdc_config } ncdc_configure_hub(){ rnd=`hexdump -n 2 -e '/2 "%u"' /dev/urandom` hub=${1?adcs://localhost:2781} hubname="${2:-hub_$rnd}" info "setting active as true" (echo "/set active true") | ncdc_config info "configuring DC Hub: $hub, activating autconnect" (echo "/open ${hubname} ${hub}" ; echo "/hset autoconnect true") | ncdc_config } 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 ||: } ncdc_autostart(){ # only systemd # punani install tmux cat > /etc/systemd/system/ncdc@.service </dev/null sleep 1 (printf "o\nn\np\n\n\n\nw\n\n") |fdisk $disk >/dev/null ||: #partprobe $disk mkfs.btrfs -f ${disk}1 >/dev/null uuid="$(blkid ${disk}1 -o value | head -n 1)" mountpoint="/media/vag${count}" mkdir -p "$mountpoint" echo "UUID=$uuid $mountpoint btrfs rw,relatime,space_cache 0 0" >> /etc/fstab echo "$mountpoint" : $((count++)) else info "skipping $disk" fi done } install_tor_announce(){ # systemd only info "writing tor_announce.service" cat > /etc/systemd/system/tor_announce.service<