PLNK/resources/gonk.sh

75 lines
1.9 KiB
Bash
Raw Normal View History

2022-08-28 00:41:44 -04:00
#!/bin/bash
echo "Starting Gonk node..."
echo " ______
/______\\
| [==] |
|______|
\\______/
| | |
|/\|/\|"
if [ -f /var/gonk ]; then
echo "Gonk has already been provisioned"
2022-09-10 23:56:19 -04:00
service fail2ban start
2022-08-28 00:41:44 -04:00
else
echo "Running first time provisioning..."
echo " Adding gonk user..."
useradd -d /var/lib/asterisk/ -c "Gonk asterisk user" -r -s /sbin/nologin gonk
echo " Setting permissions..."
chown -R gonk:gonk /var/lib/asterisk
chown -R gonk:gonk /var/log/asterisk
chown -R gonk:gonk /var/spool/asterisk
echo " Pulling config files for the first time..."
2022-09-10 23:56:19 -04:00
curl -o /etc/asterisk/asterisk.conf https://ap5.gonknet.org/asterisk/$HOSTNAME/$GONK_KEY
curl -o /etc/asterisk/pjsip.conf https://ap5.gonknet.org/pjsip/$HOSTNAME/$GONK_KEY
curl -o /etc/asterisk/modules.conf https://ap5.gonknet.org/modules/$HOSTNAME/$GONK_KEY
curl -o /etc/asterisk/logger.conf https://ap5.gonknet.org/logger/$HOSTNAME/$GONK_KEY
2022-09-09 15:06:45 -04:00
sed "s/##EXTERNAL_IP##/$(curl https://ipv4.myip.wtf/text)/g" /etc/asterisk/pjsip.conf
2022-09-12 13:41:03 -04:00
echo " Setting up auto reload config files..."
echo "26 * * * * /usr/bin/reload" >> /etc/cron.d/reload
2022-09-09 15:06:45 -04:00
echo " Setting up VOIPBL..."
2022-09-10 23:56:19 -04:00
echo " Downloading script..."
curl -o /usr/bin/voipbl.sh https://gonknet.org/static/voipbl.sh
2022-09-09 15:06:45 -04:00
chmod 700 /usr/bin/voipbl.sh
2022-09-10 23:56:19 -04:00
chmod +x /usr/bin/voipbl.sh
echo " Setting up cron..."
echo "13 */4 * * * /usr/bin/voipbl.sh" >> /etc/cron.d/voipbl
echo " Setting up fail2ban"
curl -o /etc/fail2ban/jail.d/asterisk.conf https://ap5.gonknet.org/f2b/asterisk/$HOSTNAME/$GONK_KEY
curl -o /etc/fail2ban/action.d/voipbl.conf https://ap5.gonknet.org/f2b/voipbl/$HOSTNAME/$GONK_KEY
rm /etc/fail2ban/jail.d/defaults-debian.conf
2022-09-09 15:06:45 -04:00
2022-09-10 23:56:19 -04:00
asterisk -U gonk -G gonk
sleep 2
2022-09-12 13:41:03 -04:00
2022-09-10 23:56:19 -04:00
kill -9 -- $(cat /var/run/asterisk/asterisk.pid)
service fail2ban start
echo " Running voipbl for the first time"
/usr/bin/voipbl.sh
2022-09-09 15:06:45 -04:00
2022-08-28 00:41:44 -04:00
touch /var/gonk
fi
2022-09-10 23:56:19 -04:00
2022-08-28 00:41:44 -04:00
echo "Starting Asterisk..."
asterisk -U gonk -G gonk -f