#!/bin/bash echo "Starting pre-requisite services..." service cron start echo "Starting Gonk node..." echo " ______ /______\\ | [==] | |______| \\______/ | | | |/\|/\|" if [ -f /var/gonk ]; then echo "Gonk has already been provisioned" service fail2ban start 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..." curl -so /etc/asterisk/asterisk.conf https://ap5.gonknet.org/asterisk/$HOSTNAME/$GONK_KEY curl -so /etc/asterisk/pjsip.conf https://ap5.gonknet.org/pjsip/$HOSTNAME/$GONK_KEY curl -so /etc/asterisk/modules.conf https://ap5.gonknet.org/modules/$HOSTNAME/$GONK_KEY curl -so /etc/asterisk/logger.conf https://ap5.gonknet.org/logger/$HOSTNAME/$GONK_KEY sed "s/##EXTERNAL_IP##/$(curl https://ipv4.myip.wtf/text)/g" /etc/asterisk/pjsip.conf echo " Setting up auto reload config files..." echo "26 * * * * /usr/bin/reload" >> /etc/cron.d/reload echo " Setting up VOIPBL..." echo " Downloading script..." curl -so /usr/bin/voipbl.sh https://gonknet.org/static/voipbl.sh chmod 700 /usr/bin/voipbl.sh 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 -so /etc/fail2ban/jail.d/asterisk.conf https://ap5.gonknet.org/f2b/asterisk/$HOSTNAME/$GONK_KEY curl -so /etc/fail2ban/action.d/voipbl.conf https://ap5.gonknet.org/f2b/voipbl/$HOSTNAME/$GONK_KEY rm /etc/fail2ban/jail.d/defaults-debian.conf asterisk -U gonk -G gonk sleep 2 kill -9 -- $(cat /var/run/asterisk/asterisk.pid) service fail2ban start echo " Running voipbl for the first time" /usr/bin/voipbl.sh touch /var/gonk fi echo "Starting Asterisk..." asterisk -U gonk -G gonk -f