Compare commits

..

9 Commits
dind ... master

Author SHA1 Message Date
Alex
652f94ff4b
Update to newest API endpoints, added extensions.conf
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-13 21:18:30 -04:00
Alex
490718f91f
fix for file not found on line 38 of gonk.sh
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-12 20:03:48 -04:00
Alex
0256aa9c49
add -i to sed instead of redirection fixing blank pjsip.conf
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-12 19:56:23 -04:00
Alex
313ad55670
add cron as it wasnt installed nor started.
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-12 17:09:19 -04:00
Alex
6fe1b25bd5
silence curl
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-12 15:28:44 -04:00
Alex
9790cddf49
Change pjsip's replacements to be ipv4 only
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-12 14:28:43 -04:00
Alex
d01311c62a
added reload.sh, optimized dockerfile,
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-12 13:41:03 -04:00
Alex
31f5854686
A possibly working release?
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-10 23:56:19 -04:00
Alex
5541be0b5a
Hopefully this works
Some checks reported errors
continuous-integration/drone/push Build was killed
2022-09-09 15:06:45 -04:00
4 changed files with 72 additions and 9 deletions

View File

@ -1,11 +1,10 @@
--- ---
kind: pipeline kind: pipeline
type: docker type: exec
name: default name: default
steps: steps:
- name: build and push - name: build and push
image: docker:dind
commands: commands:
- "docker build -t plnk . " - "docker build -t plnk . "
- "echo $PLNK_REGISTRY_PASSWD | docker login --password-stdin --username drone https://plnk.littleoni.net" - "echo $PLNK_REGISTRY_PASSWD | docker login --password-stdin --username drone https://plnk.littleoni.net"

View File

@ -1,12 +1,14 @@
FROM debian:latest FROM debian:latest
COPY resources /build
## Upgrade packages on system ## Upgrade packages on system
RUN apt-get update RUN apt-get update
## Install build tools ## Install build tools
RUN apt-get install -y g++ gcc make patch RUN apt-get install -y \
g++\
gcc\
make\
patch
## Install package dependencies ## Install package dependencies
RUN apt-get install -y \ RUN apt-get install -y \
@ -28,7 +30,10 @@ RUN apt-get install -y \
uuid-dev uuid-dev
## Install GONK specific dependencies ## Install GONK specific dependencies
RUN apt-get install -y fail2ban iptables net-tools RUN apt-get install -y fail2ban iptables net-tools cron
## Copy over source and other scripts
COPY resources /build
## Move and unpack source to /build ## Move and unpack source to /build
RUN mkdir /build/asterisk-current RUN mkdir /build/asterisk-current
@ -45,9 +50,12 @@ RUN make install
## Cleanup ## Cleanup
WORKDIR / WORKDIR /
RUN cp /build/reload.sh /usr/bin/reload
RUN chmod +x /usr/bin/reload
RUN cp /build/gonk.sh /usr/bin/gonk RUN cp /build/gonk.sh /usr/bin/gonk
RUN chmod +x /usr/bin/gonk RUN chmod +x /usr/bin/gonk
RUN rm -rf /build RUN rm -rf /build
RUN apt-get remove -y --purge g++ gcc make patch RUN apt-get remove -y --purge g++ gcc make patch
RUN apt-get autoremove -y && apt-get clean -y && apt-get autoclean -y
ENTRYPOINT [ "gonk" ] ENTRYPOINT [ "gonk" ]

View File

@ -1,5 +1,8 @@
#!/bin/bash #!/bin/bash
echo "Starting pre-requisite services..."
service cron start
echo "Starting Gonk node..." echo "Starting Gonk node..."
echo " ______ echo " ______
@ -11,8 +14,12 @@ echo " ______
|/\|/\|" |/\|/\|"
if [ -f /var/gonk ]; then if [ -f /var/gonk ]; then
echo "Gonk has already been provisioned" echo "Gonk has already been provisioned"
service fail2ban start
else else
echo "Running first time provisioning..." echo "Running first time provisioning..."
@ -24,12 +31,48 @@ else
chown -R gonk:gonk /var/spool/asterisk chown -R gonk:gonk /var/spool/asterisk
echo " Pulling config files for the first time..." echo " Pulling config files for the first time..."
curl -o /etc/asterisk/asterisk.conf https://api.gonk.nicolor.tech/asterisk/$HOSTNAME/$GONK_KEY curl -s https://ap5.gonknet.org/asterisk/$HOSTNAME/$GONK_KEY > /etc/asterisk/asterisk.conf
curl -o /etc/asterisk/pjsip.conf https://api.gonk.nicolor.tech/pjsip/$HOSTNAME/$GONK_KEY curl -s https://ap5.gonknet.org/asterisk/pjsip/$HOSTNAME/$GONK_KEY > /etc/asterisk/pjsip.conf
curl -o /etc/asterisk/modules.conf https://api.gonk.nicolor.tech/modules/$HOSTNAME/$GONK_KEY curl -s https://ap5.gonknet.org/asterisk/modules/$HOSTNAME/$GONK_KEY > /etc/asterisk/modules.conf
curl -s https://ap5.gonknet.org/asterisk/logger/$HOSTNAME/$GONK_KEY > /etc/asterisk/logger.conf
curl -s https://ap5.gonknet.org/asterisk/extensions/$HOSTNAME/$GONK_KEY > /etc/asterisk/extensions.conf
sed -i "s/##EXTERNAL_IP##/$(curl -s https://ipv4.myip.wtf/text)/g" /etc/asterisk/pjsip.conf
echo " Setting up config updater cron..."
echo "26 * * * * gonk /usr/bin/reload" > /etc/cron.d/reload
echo " Setting up VOIPBL..."
echo " Downloading script..."
curl -s https://gonknet.org/static/voipbl.sh > /usr/bin/voipbl.sh
chmod 700 /usr/bin/voipbl.sh
chmod +x /usr/bin/voipbl.sh
echo " Setting up VOIPBL cron..."
echo "13 */4 * * * root /usr/bin/voipbl.sh" > /etc/cron.d/voipbl
echo " Setting up fail2ban"
curl -s https://ap5.gonknet.org/f2b/asterisk/$HOSTNAME/$GONK_KEY > /etc/fail2ban/jail.d/asterisk.conf
curl -s https://ap5.gonknet.org/f2b/voipbl/$HOSTNAME/$GONK_KEY > /etc/fail2ban/action.d/voipbl.conf
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 touch /var/gonk
fi fi
echo "Starting Asterisk..." echo "Starting Asterisk..."
asterisk -U gonk -G gonk -f asterisk -U gonk -G gonk -f

13
resources/reload.sh Normal file
View File

@ -0,0 +1,13 @@
#! /bin/bash
echo "Reloading config files..."
curl -s https://ap5.gonknet.org/asterisk/$HOSTNAME/$GONK_KEY > /etc/asterisk/asterisk.conf
curl -s https://ap5.gonknet.org/asterisk/pjsip/$HOSTNAME/$GONK_KEY > /etc/asterisk/pjsip.conf
curl -s https://ap5.gonknet.org/asterisk/modules/$HOSTNAME/$GONK_KEY > /etc/asterisk/modules.conf
curl -s https://ap5.gonknet.org/asterisk/logger/$HOSTNAME/$GONK_KEY > /etc/asterisk/logger.conf
curl -s https://ap5.gonknet.org/asterisk/extensions/$HOSTNAME/$GONK_KEY > /etc/asterisk/extensions.conf
sed -i "s/##EXTERNAL_IP##/$(curl https://ipv4.myip.wtf/text)/g" /etc/asterisk/pjsip.conf
asterisk -x "core restart when convenient"