From 30301313227162973affe115385bd848ef4ebaef Mon Sep 17 00:00:00 2001 From: Disassembler Date: Fri, 30 Mar 2018 21:58:44 +0200 Subject: [PATCH] Introduce FrontlineSMS Docker image, closes #151 --- 00-install.sh | 1 + README.md | 1 + basic/srv/portal/index.html | 2 +- flsms.sh | 26 +++++++++ flsms/Dockerfile | 25 +++++++++ flsms/docker/etc/X11/dummy.conf | 53 +++++++++++++++++++ flsms/docker/etc/services.d/.s6-svscan/finish | 3 ++ flsms/docker/etc/services.d/frontlinesms/run | 8 +++ flsms/docker/etc/services.d/xorg/run | 5 ++ flsms/etc/init.d/flsms | 24 +++++++++ flsms/srv/flsms/data/app-settings.properties | 3 ++ 11 files changed, 150 insertions(+), 1 deletion(-) create mode 100755 flsms.sh create mode 100644 flsms/Dockerfile create mode 100644 flsms/docker/etc/X11/dummy.conf create mode 100755 flsms/docker/etc/services.d/.s6-svscan/finish create mode 100755 flsms/docker/etc/services.d/frontlinesms/run create mode 100755 flsms/docker/etc/services.d/xorg/run create mode 100755 flsms/etc/init.d/flsms create mode 100644 flsms/srv/flsms/data/app-settings.properties diff --git a/00-install.sh b/00-install.sh index e2f04ec..3c6c1ed 100755 --- a/00-install.sh +++ b/00-install.sh @@ -12,6 +12,7 @@ ${SOURCE_DIR}/basic.sh ${SOURCE_DIR}/ckan.sh # ${SOURCE_DIR}/ccleanup.sh # ${SOURCE_DIR}/cts.sh +${SOURCE_DIR}/flsms.sh ${SOURCE_DIR}/gnuhealth.sh ${SOURCE_DIR}/kanboard.sh ${SOURCE_DIR}/mifosx.sh diff --git a/README.md b/README.md index 06e750e..733945f 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ vi 00-install.sh | CKAN Datapusher | ckandp | 8004 | 8080 (HTTP) | | Crisis Cleanup | ccleanup | 8005 | 8080 (HTTP) | | CTS | cts | 8006 | 8080 (HTTP) | +| FrontlineSMS | flsms | 8018 | 8080 (HTTP) | | GNU Health | gnuhealth | 8008 | 8080 (HTTP) | | KanBoard | kanboard | 8009 | 8080 (HTTP) | | MariaDB | mariadb | 3306 | 3306 (MySQL) | diff --git a/basic/srv/portal/index.html b/basic/srv/portal/index.html index 92bfd59..c055f63 100644 --- a/basic/srv/portal/index.html +++ b/basic/srv/portal/index.html @@ -134,7 +134,7 @@ -
+

FrontlineSMSFrontlineSMS

SMS messaging přes veřejné datové brány

    diff --git a/flsms.sh b/flsms.sh new file mode 100755 index 0000000..0f8828b --- /dev/null +++ b/flsms.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +SOURCE_DIR=$(realpath $(dirname "${0}"))/flsms + +# Check prerequisites +docker image ls | grep -q java || $(realpath $(dirname "${0}"))/java.sh + +# Build Docker container +docker build -t flsms ${SOURCE_DIR} + +# Configure FrontlineSMS +mkdir -p /srv/flsms/data +export FLSMS_ADMIN_USER=admin +export FLSMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) +export FLSMS_ADMIN_USER_HASH=$(echo -n "${FLSMS_ADMIN_USER}" | base64) +export FLSMS_ADMIN_PWD_HASH=$(echo -n "${FLSMS_ADMIN_PWD}" | base64) +envsubst <${SOURCE_DIR}/srv/flsms/data/app-settings.properties >/srv/flsms/data/app-settings.properties +chown -R 8018:8018 /srv/flsms/data + +# Create FrontlineSMS service +cp ${SOURCE_DIR}/etc/init.d/flsms /etc/init.d/flsms +rc-update add flsms +service flsms start + +# Add application definition +spotter-appmgr add-app flsms "https://flsms.{host}/" "${FLSMS_ADMIN_USER}" "${FLSMS_ADMIN_PWD}" diff --git a/flsms/Dockerfile b/flsms/Dockerfile new file mode 100644 index 0000000..337cda4 --- /dev/null +++ b/flsms/Dockerfile @@ -0,0 +1,25 @@ +FROM java +MAINTAINER Disassembler + +RUN \ + # Install runtime dependencies + apk --no-cache add openjdk8-jre s6 ttf-dejavu xf86-video-dummy xorg-server \ + # Create OS user + && addgroup -S -g 8018 flsms \ + && adduser -S -u 8018 -h /srv/flsms -s /bin/sh -g flsms -G flsms flsms \ + # Install FrontlineSMS + && wget http://download-frontlinesms.s3.amazonaws.com/frontlinesms2_unix_2.6.5.sh -O /tmp/frontlinesms2.sh \ + # Hackfix for Busybox gunzip + && sed -i 's/gunzip -V/echo/' /tmp/frontlinesms2.sh \ + && echo -e 'o\n\nn\nSpotter\nSpotter\n11\n45\n\n\nadmin@example.com\n\n\n\n\n\n\n\n\n\n\n' | su - flsms -c 'sh /tmp/frontlinesms2.sh -c' \ + # Replace Jetty port + && sed -i 's/8130/8080/' /srv/flsms/frontlinesms2/launcher.properties \ + # Cleanup + && rm /tmp/frontlinesms2.sh + +COPY docker/ / + +VOLUME ["/srv/flsms/.frontlinesms2"] +EXPOSE 8080 + +CMD ["s6-svscan", "/etc/services.d"] diff --git a/flsms/docker/etc/X11/dummy.conf b/flsms/docker/etc/X11/dummy.conf new file mode 100644 index 0000000..d06d82f --- /dev/null +++ b/flsms/docker/etc/X11/dummy.conf @@ -0,0 +1,53 @@ +Section "ServerFlags" + Option "DontVTSwitch" "true" + Option "AllowMouseOpenFail" "true" + Option "PciForceNone" "true" + Option "AutoEnableDevices" "false" + Option "AutoAddDevices" "false" +EndSection + +Section "InputDevice" + Identifier "dummy_mouse" + Option "CorePointer" "true" + Driver "void" +EndSection + +Section "InputDevice" + Identifier "dummy_keyboard" + Option "CoreKeyboard" "true" + Driver "void" +EndSection + +Section "Device" + Identifier "dummy_videocard" + Driver "dummy" + Option "ConstantDPI" "true" + VideoRam 192000 +EndSection + +Section "Monitor" + Identifier "dummy_monitor" + HorizSync 5.0 - 1000.0 + VertRefresh 5.0 - 200.0 + Modeline "1280x720" 27.41 1280 1312 1416 1448 720 737 740 757 +EndSection + +Section "Screen" + Identifier "dummy_screen" + Device "dummy_videocard" + Monitor "dummy_monitor" + DefaultDepth 24 + SubSection "Display" + Viewport 0 0 + Depth 24 + Modes "1280x720" + Virtual 8192 4096 + EndSubSection +EndSection + +Section "ServerLayout" + Identifier "dummy_layout" + Screen "dummy_screen" + InputDevice "dummy_mouse" + InputDevice "dummy_keyboard" +EndSection diff --git a/flsms/docker/etc/services.d/.s6-svscan/finish b/flsms/docker/etc/services.d/.s6-svscan/finish new file mode 100755 index 0000000..78d5fdc --- /dev/null +++ b/flsms/docker/etc/services.d/.s6-svscan/finish @@ -0,0 +1,3 @@ +#!/bin/sh + +/bin/true diff --git a/flsms/docker/etc/services.d/frontlinesms/run b/flsms/docker/etc/services.d/frontlinesms/run new file mode 100755 index 0000000..c60a196 --- /dev/null +++ b/flsms/docker/etc/services.d/frontlinesms/run @@ -0,0 +1,8 @@ +#!/bin/execlineb -P + +foreground { s6-svwait -t 3000 -u /etc/services.d/xorg } +cd /srv/flsms +export DISPLAY :10 +fdmove -c 2 1 +s6-setuidgid 8018:8018 +/srv/flsms/frontlinesms2/FrontlineSMS2_Launcher diff --git a/flsms/docker/etc/services.d/xorg/run b/flsms/docker/etc/services.d/xorg/run new file mode 100755 index 0000000..66da33c --- /dev/null +++ b/flsms/docker/etc/services.d/xorg/run @@ -0,0 +1,5 @@ +#!/bin/execlineb -P + +fdmove -c 2 1 +s6-setuidgid 8018:8018 +Xorg -noreset +extension GLX +extension RANDR +extension RENDER -config dummy.conf :10 diff --git a/flsms/etc/init.d/flsms b/flsms/etc/init.d/flsms new file mode 100755 index 0000000..78be8fb --- /dev/null +++ b/flsms/etc/init.d/flsms @@ -0,0 +1,24 @@ +#!/sbin/openrc-run + +description="FrontlineSMS docker container" + +depend() { + need docker net + use dns logger netmount +} + +start() { + /usr/bin/docker run -d --rm \ + --name flsms \ + -h flsms \ + -v /srv/flsms/data:/srv/flsms/.frontlinesms2 \ + flsms +} + +start_post() { + /usr/local/bin/spotter-appmgr update-proxy flsms +} + +stop() { + /usr/bin/docker stop flsms +} diff --git a/flsms/srv/flsms/data/app-settings.properties b/flsms/srv/flsms/data/app-settings.properties new file mode 100644 index 0000000..80007e9 --- /dev/null +++ b/flsms/srv/flsms/data/app-settings.properties @@ -0,0 +1,3 @@ +auth.basic.enabled=on +auth.basic.username=${FLSMS_ADMIN_USER_HASH} +auth.basic.password=${FLSMS_ADMIN_PWD_HASH}