From cb641aaf553526c803f4cbd4fceabaf54937e8dc Mon Sep 17 00:00:00 2001 From: JD Byrnes <204185+realJoshByrnes@users.noreply.github.com> Date: Fri, 14 May 2021 07:12:44 +1000 Subject: [PATCH] 0.7.1 Kalkun 0.7.1 on NGINX/PHP8 --- Dockerfile | 48 ++++++ README.md | 2 + config/gammurc | 60 +++++++ config/kalkun-daemon.php | 10 ++ config/kalkun-daemon.sh | 8 + config/kalkun-database.php | 24 +++ config/nginx.conf | 87 ++++++++++ config/openrc-gammu-smsd | 10 ++ db/Dockerfile | 3 + db/gammu.sql | 178 ++++++++++++++++++++ db/kalkun.sql | 331 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 19 +++ 12 files changed, 780 insertions(+) create mode 100644 Dockerfile create mode 100644 config/gammurc create mode 100644 config/kalkun-daemon.php create mode 100644 config/kalkun-daemon.sh create mode 100644 config/kalkun-database.php create mode 100644 config/nginx.conf create mode 100644 config/openrc-gammu-smsd create mode 100644 db/Dockerfile create mode 100644 db/gammu.sql create mode 100644 db/kalkun.sql create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5bc5a2e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +FROM nginx:alpine + +LABEL maintainer="realJoshByrnes on Github" + +COPY ./config/openrc-gammu-smsd /etc/init.d/gammu-smsd + +RUN /sbin/apk update && /sbin/apk add --no-cache \ + # Install Gammu-SMSD, PHP8, MariaDB-Client & OpenRC + gammu-smsd php8 php8-fpm php8-mysqli php8-mbstring \ + php8-session php8-ctype openrc mariadb-client tzdata \ + # Set default timezone to Australia/Sydney + && cp /usr/share/zoneinfo/Australia/Sydney /etc/localtime \ + && echo "Australia/Sydney" > /etc/timezone \ + && apk del tzdata \ + # Create required directories + && /bin/busybox mkdir -p /run/openrc /var/www/install /var/log/gammu \ + # Configure OpenRC + && /bin/busybox touch /run/openrc/softlevel \ + # Get Kalkun and add to /var/www + && /bin/busybox wget -qO- https://github.com/realJoshByrnes/Kalkun/tarball/master | \ + /bin/busybox tar x -zvf - -C /var/www --strip-components=1 \ + # Create www user + && /bin/busybox adduser -D -g 'www' www \ + && /bin/busybox sed -i "s|;listen.owner\s*=\s*nobody|listen.owner = www|g" /etc/php8/php-fpm.d/www.conf \ + && /bin/busybox sed -i "s|;listen.group\s*=\s*nobody|listen.group = www|g" /etc/php8/php-fpm.d/www.conf \ + && /bin/busybox sed -i "s|;listen.mode\s*=\s*0660|listen.mode = 0660|g" /etc/php8/php-fpm.d/www.conf \ + && /bin/busybox sed -i "s|user\s*=\s*nobody|user = www|g" /etc/php8/php-fpm.d/www.conf \ + && /bin/busybox sed -i "s|group\s*=\s*nobody|group = www|g" /etc/php8/php-fpm.d/www.conf \ + && /bin/busybox sed -i "s|;chdir\s*=\s/var/www|chdir = /var/www|g" /etc/php8/php-fpm.d/www.conf #uncommenting line \ + && /bin/busybox sed -i "s|;log_level\s*=\s*notice|log_level = notice|g" /etc/php8/php-fpm.conf #uncommenting line + +COPY ./config/nginx.conf /etc/nginx/nginx.conf +COPY ./config/gammurc /etc/gammurc +COPY ./config/kalkun-daemon.php /var/www/scripts/daemon.php +COPY ./config/kalkun-daemon.sh /var/www/scripts/daemon.sh +COPY ./config/kalkun-database.php /var/www/application/config/database.php + +# Set permissions +RUN /bin/busybox chown -R www:www /var/www \ + && /bin/busybox chown -R www:www /usr/share/nginx \ + && /bin/busybox chmod +x /etc/init.d/gammu-smsd \ + && /bin/busybox chmod +x /var/www/scripts/daemon.sh \ + # Set auto-start + && /sbin/rc-update add gammu-smsd default \ + && /sbin/rc-update add php-fpm8 default \ + && /sbin/rc-update add nginx default + +CMD ["openrc", "default"] \ No newline at end of file diff --git a/README.md b/README.md index 29f7c72..6c28d0a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # docker-gammu-kalkun A lightweight Gammu-SMSD / Kalkun docker container + +The recommended installation is via docker-compose. \ No newline at end of file diff --git a/config/gammurc b/config/gammurc new file mode 100644 index 0000000..2383d67 --- /dev/null +++ b/config/gammurc @@ -0,0 +1,60 @@ +[gammu] +port = /dev/gsm-modem +connection = at115200 +logfile = /var/log/gammu/gammu.log +logformat = textall + +[smsd] +InboxPath = /var/spool/gammu/inbox/ +OutboxPath = /var/spool/gammu/outbox/ +SentSMSPath = /var/spool/gammu/sent/ +ErrorSMSPath = /var/spool/gammu/error/ +InboxFormat = unicode +OutboxFormat = unicode +TransmitFormat = auto + +#Service = files +Service = sql +User = kalkun +Password = kalkun +Host = kalkun-db +Database = kalkun +Driver = native_mysql +SQL = mysql + +#PIN = +#NetworkCode = +#PhoneCode = +LogFile = /var/log/gammu/smsd.log +LogFacility = daemon +debugLevel = 4 +CommTimeout = 30 +SendTimeout = 30 +MaxRetries = 1 +RetryTimeout = 600 +ReceiveFrequency = 15 +StatusFrequency = 60 +LoopSleep = 1 +MultipartTimeout = 600 +CheckSecurity = 0 +HangupCalls = 1 +CheckBattery = 1 +CheckSignal = 1 +CheckNetwork = 1 +ResetFrequency = 0 +HardResetFrequency = 0 +DeliveryReport = sms +DeliveryReportDelay = 7200 +#PhoneID = ? +#SMSC = +614xxyyyzzz +RunOnReceive = /var/www/scripts/daemon.sh +#RunOnFailure = +#RunOnSent = +#RunOnIncomingCall = +#IncludeNumbersFile = +#ExcludeNumbersFile = +#IncludeSMSCFile +#ExcludeSMSCFile +BackendRetries = 10 +Send = True +Receive = True \ No newline at end of file diff --git a/config/kalkun-daemon.php b/config/kalkun-daemon.php new file mode 100644 index 0000000..c2bfa7d --- /dev/null +++ b/config/kalkun-daemon.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/config/kalkun-daemon.sh b/config/kalkun-daemon.sh new file mode 100644 index 0000000..c41052f --- /dev/null +++ b/config/kalkun-daemon.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Configure this (use absolute path) +PHP=/usr/bin/php8 # php cli path +DAEMON=/var/www/scripts/daemon.php # daemon.php path + +# Execute +$PHP $DAEMON \ No newline at end of file diff --git a/config/kalkun-database.php b/config/kalkun-database.php new file mode 100644 index 0000000..1ca7757 --- /dev/null +++ b/config/kalkun-database.php @@ -0,0 +1,24 @@ +