summaryrefslogtreecommitdiffstats
path: root/snap-src
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-02-23 21:01:44 +0200
committerLauri Ojansivu <x@xet7.org>2018-02-23 21:01:44 +0200
commit57cf86a79fe56e89516e9e08746fce217f1c4c98 (patch)
tree0c8dda2fb4ffe2280c1fd48913fea4c4e869e8ff /snap-src
parent1ef663531bb0c52ec37d4132a110c7b8d01561e8 (diff)
parent5bdb392258bd3d3863699e5bf05b64b70f222621 (diff)
downloadwekan-57cf86a79fe56e89516e9e08746fce217f1c4c98.tar.gz
wekan-57cf86a79fe56e89516e9e08746fce217f1c4c98.tar.bz2
wekan-57cf86a79fe56e89516e9e08746fce217f1c4c98.zip
Merge branch 'devel'
Diffstat (limited to 'snap-src')
-rw-r--r--snap-src/Caddyfile5
-rwxr-xr-xsnap-src/bin/caddy-control12
-rwxr-xr-xsnap-src/bin/config (renamed from snap-src/config)19
-rwxr-xr-xsnap-src/bin/mongodb-backup (renamed from snap-src/mongodb-backup)0
-rwxr-xr-xsnap-src/bin/mongodb-control (renamed from snap-src/mongodb-control)3
-rwxr-xr-xsnap-src/bin/mongodb-restore (renamed from snap-src/mongodb-restore)0
-rwxr-xr-xsnap-src/bin/wekan-control (renamed from snap-src/wekan-control)3
-rwxr-xr-xsnap-src/bin/wekan-help (renamed from snap-src/wekan-help)22
-rwxr-xr-xsnap-src/bin/wekan-read-settings29
-rwxr-xr-xsnap-src/wekan-read-settings36
10 files changed, 71 insertions, 58 deletions
diff --git a/snap-src/Caddyfile b/snap-src/Caddyfile
new file mode 100644
index 00000000..07ed4143
--- /dev/null
+++ b/snap-src/Caddyfile
@@ -0,0 +1,5 @@
+http://:8080
+proxy / localhost:3001 {
+ websocket
+ transparent
+}
diff --git a/snap-src/bin/caddy-control b/snap-src/bin/caddy-control
new file mode 100755
index 00000000..46d36c6b
--- /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_COMMON/Caddyfile -host=localhost:${CADDY_PORT}
+else
+ echo "caddy is disabled. Stop service"
+ snapctl stop --disable ${SNAP_NAME}.caddy
+ # sleep here, in case snapctl fails to stop service so we do not restart too often
+fi
diff --git a/snap-src/config b/snap-src/bin/config
index dbf8402c..da2ee5cd 100755
--- a/snap-src/config
+++ b/snap-src/bin/config
@@ -1,17 +1,14 @@
#!/bin/sh
-# store here all configuration options for wekan snap
-# read configured settings first
-SETTINGS_FILE="$SNAP_COMMON/wekan_settings.sh"
-[ -f $SETTINGS_FILE ] && . $SETTINGS_FILE
+# All supported keys are defined here together with descriptions and default values
# 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"\
"\t\t\t Default behaviour will preffer binding over unix socket, to disable unix socket binding set value to 'nill' string\n"\
-"\t\t\t To bind to instance of mongo provided through contect interface set to relative path to the socket inside shared directory"
+"\t\t\t To bind to instance of mongodb provided through content interface,set value to relative path to the socket inside '$SNAP_DATA/shared' directory"
DEFAULT_MONGODB_BIND_UNIX_SOCKET="$SNAP_DATA/share"
KEY_MONGODB_BIND_UNIX_SOCKET="mongodb-bind-unix-socket"
@@ -39,6 +36,14 @@ DESCRIPTION_PORT="port wekan is exposed at"
DEFAULT_PORT="8080"
KEY_PORT="port"
-DESCRIPTION_DISABLE_MONGODB="Disable mongodb service: use only if binding to database outside of the snap. Valid values: [true,false]"
+DESCRIPTION_DISABLE_MONGODB="Disable mongodb service: use only if binding to database outside of the ${SNAP_NAME} 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\t\tcaddy 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/mongodb-backup b/snap-src/bin/mongodb-backup
index bef8bf9b..bef8bf9b 100755
--- a/snap-src/mongodb-backup
+++ b/snap-src/bin/mongodb-backup
diff --git a/snap-src/mongodb-control b/snap-src/bin/mongodb-control
index 08af132d..a7a98739 100755
--- a/snap-src/mongodb-control
+++ b/snap-src/bin/mongodb-control
@@ -4,7 +4,8 @@
source $SNAP/bin/wekan-read-settings
if [ "true" == "${DISABLE_MONGODB}" ]; then
- echo "mongodb is disabled. Not starting it"
+ echo "mongodb is disabled. Stop service"
+ snapctl stop --disable ${SNAP_NAME}.mongodb
exit 0
fi
diff --git a/snap-src/mongodb-restore b/snap-src/bin/mongodb-restore
index c1c82775..c1c82775 100755
--- a/snap-src/mongodb-restore
+++ b/snap-src/bin/mongodb-restore
diff --git a/snap-src/wekan-control b/snap-src/bin/wekan-control
index 905642ed..bc2cefde 100755
--- a/snap-src/wekan-control
+++ b/snap-src/bin/wekan-control
@@ -1,8 +1,5 @@
#!/bin/bash
-SYSTEMD_WEKAN_SERVICE="snap.${SNAP_NAME}.wekan"
-SYSTEMD_MONGODB_SERVICE="snap.${SNAP_NAME}.mongodb"
-
# get wekan/mongo settings
source $SNAP/bin/wekan-read-settings
diff --git a/snap-src/wekan-help b/snap-src/bin/wekan-help
index bbf0e138..ee565500 100755
--- a/snap-src/wekan-help
+++ b/snap-src/bin/wekan-help
@@ -1,15 +1,17 @@
#!/bin/bash
-source $SNAP/bin/config &>/dev/null
+# first read settings
+source $SNAP/bin/wekan-read-settings &>/dev/null
+if [ "$CADDY_ENABLED" = "true" ]; then
+ # tweak port nunmber as it has been remapped
+ export PORT=${CADDY_PORT} &>/dev/null
+fi
echo -e "Wekan: The open-source Trello-like kanban.\n"
-echo -e "Make sure you have connected all interfaces, check more by calling $ snap interfaces"
+echo -e "Make sure you have connected all interfaces, check more by calling $ snap interfaces ${SNAP_NAME}"
echo -e "\n"
-echo -e "${SNAP_NAME} has two services, to check status/restart/stop use systemd commands"
-echo -e "mongodb service:"
-echo -e "\t$ sudo systemctl status/start/stop/restart snap.$SNAP_NAME.mongodb"
-echo -e "wekan service"
-echo -e "\t$ sudo systemctl status/start/stop/restart snap.$SNAP_NAME.wekan"
+echo -e "${SNAP_NAME} has multiple services, to check status use systemctl"
+echo -e "\t$ systemctl status snap.$SNAP_NAME.*"
echo -e "\n"
echo -e "To make backup of wekan's database use: $ ${SNAP_NAME}.database-backup [backup file]"
echo -e "\t backup file is optional parameter, if not passed backup is created in directory:"
@@ -42,7 +44,5 @@ do
echo -e "\t\tCurrent value set to: '${!key}', (default value: '${!default_value}')"
fi
done
-echo -e "\nFor changes to take effect restart wekan service,"
-echo -e "if mongodb key was change also restart mongodb service, before restarting wekan"
-echo -e "to restart mongodb: $ sudo systemctl restart snap.$SNAP_NAME.mongodb"
-echo -e "to restart wekan: $ sudo systemctl restart snap.$SNAP_NAME.wekan"
+
+echo -e "\n!!!! Some changes result in restart of some or all services, use with caution !!!!!"
diff --git a/snap-src/bin/wekan-read-settings b/snap-src/bin/wekan-read-settings
new file mode 100755
index 00000000..f216c2a8
--- /dev/null
+++ b/snap-src/bin/wekan-read-settings
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# read wekan config
+source $SNAP/bin/config
+
+
+for key in ${keys[@]}
+do
+ default_value="DEFAULT_$key"
+ description="DESCRIPTION_$key"
+ snappy_key="KEY_$key"
+ value=$(snapctl get ${!snappy_key})
+ if [ "x$value" == "x" ]; then
+ echo -e "$key=${!default_value} (default value)"
+ export $key=${!default_value}
+ else
+ echo -e "$key=$value"
+ 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
diff --git a/snap-src/wekan-read-settings b/snap-src/wekan-read-settings
deleted file mode 100755
index aec05bba..00000000
--- a/snap-src/wekan-read-settings
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-
-# read wekan config
-source $SNAP/bin/config
-
-# TODO: uncomment following, once snapctl can be called from outside the hooks
-# for key in ${keys[@]}
-# do
-# # snappy is picky about key syntax, using mapping
-# MAP_KEY="KEY_$key"
-# SNAPPY_KEY=
-# if value=$(snapctl get ${!MAP_KEY}); then
-# echo "$key='$value'"
-# export $key=$value
-# else
-# # use default value
-# default_value="DEFAULT_$key"
-# echo "using default value: $key='${!default_value}'"
-# export $key=${!default_value}
-# fi
-# done
-
-# TODO: get rid of this workaround once above can be used
-# loop through all values, and if not defined, use default value
-for key in ${keys[@]}
-do
- if [ "x" == "x${!key}" ]; then
- # use default value
- default_value="DEFAULT_$key"
- echo "using default value: $key='${!default_value}'"
- export $key=${!default_value}
- # echo "export $key='${!def_value}'" >> $SETTINGS_FILE
- else
- echo "$key='${!key}'"
- fi
-done