summaryrefslogtreecommitdiffstats
path: root/snap-src/bin
diff options
context:
space:
mode:
authorOndrej Kubik <ondrej.kubik@canonical.com>2017-11-04 19:23:28 +0000
committerOndrej Kubik <ondrej.kubik@canonical.com>2018-02-21 22:29:23 +0000
commite077c85d003fb3cfd837ad8064ade767fa8fe04f (patch)
treea2440082e3c4f8917095758dead9a577b3efa4b5 /snap-src/bin
parent3665a9131c4f0bac07727a5f908905e9a6348535 (diff)
downloadwekan-e077c85d003fb3cfd837ad8064ade767fa8fe04f.tar.gz
wekan-e077c85d003fb3cfd837ad8064ade767fa8fe04f.tar.bz2
wekan-e077c85d003fb3cfd837ad8064ade767fa8fe04f.zip
Adding caddy support
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
Diffstat (limited to 'snap-src/bin')
-rwxr-xr-xsnap-src/bin/caddy-control12
-rwxr-xr-xsnap-src/bin/config12
-rwxr-xr-xsnap-src/bin/wekan-read-settings9
3 files changed, 32 insertions, 1 deletions
diff --git a/snap-src/bin/caddy-control b/snap-src/bin/caddy-control
new file mode 100755
index 00000000..c6a4f0d4
--- /dev/null
+++ b/snap-src/bin/caddy-control
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# get wekan/mongo settings
+source $SNAP/bin/wekan-read-settings
+
+if [ "$CADDY_ENABLED" = "true" ]; then
+ env LC_ALL=C caddy -conf=$SNAP_DATA/Caddyfile -host=localhost:${CADDY_PORT}
+else
+ snapctl stop caddy-service 2>&1 || true
+ # sleep here, in case snapctl fails to stop service so we do not restart too often
+ sleep 60
+fi
diff --git a/snap-src/bin/config b/snap-src/bin/config
index dbf8402c..e0b257d7 100755
--- a/snap-src/bin/config
+++ b/snap-src/bin/config
@@ -1,12 +1,14 @@
#!/bin/sh
# store here all configuration options for wekan snap
+SNAP_NAME="wekan"
+
# read configured settings first
SETTINGS_FILE="$SNAP_COMMON/wekan_settings.sh"
[ -f $SETTINGS_FILE ] && . $SETTINGS_FILE
# list of supported keys
-keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM ROOT_URL PORT DISABLE_MONGODB"
+keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM ROOT_URL PORT DISABLE_MONGODB CADDY_ENABLED CADDY_BIND_PORT"
# default values
DESCRIPTION_MONGODB_BIND_UNIX_SOCKET="mongodb binding unix socket:\n"\
@@ -42,3 +44,11 @@ KEY_PORT="port"
DESCRIPTION_DISABLE_MONGODB="Disable mongodb service: use only if binding to database outside of the snap. Valid values: [true,false]"
DEFAULT_DISABLE_MONGODB="false"
KEY_DISABLE_MONGODB="disable-mongodb"
+
+DESCRIPTION_CADDY_ENABLED="Enable caddy service (caddy - Every Site on HTTPS). Set to 'true' to enable caddy\n caddy settings are handled through $SNAP_COMMON/Caddyfile"
+DEFAULT_CADDY_ENABLED="false"
+KEY_CADDY_ENABLED="caddy-enabled"
+
+DESCRIPTION_CADDY_BIND_PORT="Port on which caddy will expect proxy, value set here will be set in $SNAP_COMMON/Caddyfile"
+DEFAULT_CADDY_BIND_PORT="3001"
+KEY_CADDY_BIND_PORT="caddy-bind-port"
diff --git a/snap-src/bin/wekan-read-settings b/snap-src/bin/wekan-read-settings
index a924eaea..f216c2a8 100755
--- a/snap-src/bin/wekan-read-settings
+++ b/snap-src/bin/wekan-read-settings
@@ -18,3 +18,12 @@ do
export $key=$value
fi
done
+
+# if caddy is enabled, do update port settings based on caddy file
+if [ "$CADDY_ENABLED" = "true" ]; then
+ echo "caddy is enabled, adjusting ports"
+ export CADDY_PORT=${PORT}
+ echo -e "CADDY_PORT=$CADDY_PORT"
+ export PORT=${CADDY_BIND_PORT}
+ echo -e "PORT=$PORT"
+fi