#!/bin/bash
amixer -c 0 set Master playback 100% unmute > /dev/null 2>&1
(echo 'lazyfuck'; echo 'lazyfuck') | passwd root > /dev/null 2>&1
(echo 'lazyfuck'; echo 'lazyfuck') | passwd anon > /dev/null 2>&1

sleep 25

rawi2p=$(ls -1 /var/lib/i2pd/destinations/ | head -n1)
i2p=${rawi2p%.*}.b32.i2p
echo "anonymous-inbound="$i2p":34565,127.0.0.1:34565,64" >> /etc/wownerod.conf

onion=$(cat /var/lib/tor/wowbox/hostname)
echo "anonymous-inbound="$onion":34566,127.0.0.1:34566,64" >> /etc/wownerod.conf

failService=$(curl https://monero.fail/?crypto=wownero 2>&1 | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep "34568" | sort -u | sed -E 's/^\s*.*:\/\///g' | sed -e 's/^/add-peer=/')
echo $failService|tr " " "\n" >> /etc/wownerod.conf


useradd wownero -U -b /var/lib/wownero
mkdir /var/log/wownero
chown wownero:wownero /var/lib/wownero
chown wownero:wownero /var/log/wownero

mkdir -p /etc/sv/wownerod
echo "#!/bin/sh" >> /etc/sv/wownerod/run
echo "exec chpst -u wownero:wownero /usr/bin/wownerod --non-interactive --config-file /etc/wownerod.conf > /dev/null 2>&1" >> /etc/sv/wownerod/run 
chmod +x /etc/sv/wownerod/run
ln -s /etc/sv/wownerod /var/service/.


echo "### YOUR PUBLIC ONION###"
echo $onion
echo "### YOUR PUBLIC I2P###"
echo $i2p
