Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
652f94ff4b | ||
|
490718f91f | ||
|
0256aa9c49 | ||
|
313ad55670 | ||
|
6fe1b25bd5 | ||
|
9790cddf49 | ||
|
d01311c62a | ||
|
31f5854686 | ||
|
5541be0b5a |
@ -1,11 +1,10 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: exec
|
||||
name: default
|
||||
|
||||
steps:
|
||||
- name: build and push
|
||||
image: docker:dind
|
||||
commands:
|
||||
- "docker build -t plnk . "
|
||||
- "echo $PLNK_REGISTRY_PASSWD | docker login --password-stdin --username drone https://plnk.littleoni.net"
|
||||
|
16
Dockerfile
16
Dockerfile
@ -1,12 +1,14 @@
|
||||
FROM debian:latest
|
||||
|
||||
COPY resources /build
|
||||
|
||||
## Upgrade packages on system
|
||||
RUN apt-get update
|
||||
|
||||
## Install build tools
|
||||
RUN apt-get install -y g++ gcc make patch
|
||||
RUN apt-get install -y \
|
||||
g++\
|
||||
gcc\
|
||||
make\
|
||||
patch
|
||||
|
||||
## Install package dependencies
|
||||
RUN apt-get install -y \
|
||||
@ -28,7 +30,10 @@ RUN apt-get install -y \
|
||||
uuid-dev
|
||||
|
||||
## 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
|
||||
RUN mkdir /build/asterisk-current
|
||||
@ -45,9 +50,12 @@ RUN make install
|
||||
|
||||
## Cleanup
|
||||
WORKDIR /
|
||||
RUN cp /build/reload.sh /usr/bin/reload
|
||||
RUN chmod +x /usr/bin/reload
|
||||
RUN cp /build/gonk.sh /usr/bin/gonk
|
||||
RUN chmod +x /usr/bin/gonk
|
||||
RUN rm -rf /build
|
||||
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" ]
|
@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Starting pre-requisite services..."
|
||||
service cron start
|
||||
|
||||
echo "Starting Gonk node..."
|
||||
|
||||
echo " ______
|
||||
@ -11,8 +14,12 @@ echo " ______
|
||||
|/\|/\|"
|
||||
|
||||
|
||||
|
||||
|
||||
if [ -f /var/gonk ]; then
|
||||
echo "Gonk has already been provisioned"
|
||||
service fail2ban start
|
||||
|
||||
|
||||
else
|
||||
echo "Running first time provisioning..."
|
||||
@ -24,12 +31,48 @@ else
|
||||
chown -R gonk:gonk /var/spool/asterisk
|
||||
|
||||
echo " Pulling config files for the first time..."
|
||||
curl -o /etc/asterisk/asterisk.conf https://api.gonk.nicolor.tech/asterisk/$HOSTNAME/$GONK_KEY
|
||||
curl -o /etc/asterisk/pjsip.conf https://api.gonk.nicolor.tech/pjsip/$HOSTNAME/$GONK_KEY
|
||||
curl -o /etc/asterisk/modules.conf https://api.gonk.nicolor.tech/modules/$HOSTNAME/$GONK_KEY
|
||||
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 -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
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "Starting Asterisk..."
|
||||
asterisk -U gonk -G gonk -f
|
||||
|
||||
|
13
resources/reload.sh
Normal file
13
resources/reload.sh
Normal 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"
|
Loading…
Reference in New Issue
Block a user