From a533caa9447c78fd007dfb7ada15c41390e97e05 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Sat, 4 Nov 2017 18:56:35 +0000 Subject: rearranging helper scripts in snap-src Signed-off-by: Ondrej Kubik --- snap-src/bin/wekan-read-settings | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 snap-src/bin/wekan-read-settings (limited to 'snap-src/bin/wekan-read-settings') diff --git a/snap-src/bin/wekan-read-settings b/snap-src/bin/wekan-read-settings new file mode 100755 index 00000000..aec05bba --- /dev/null +++ b/snap-src/bin/wekan-read-settings @@ -0,0 +1,36 @@ +#!/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 -- cgit v1.2.3-1-g7c22 From 3665a9131c4f0bac07727a5f908905e9a6348535 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Sat, 4 Nov 2017 19:20:37 +0000 Subject: splitting hooks and using snapctl instead of local settings file Signed-off-by: Ondrej Kubik --- snap-src/bin/wekan-read-settings | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'snap-src/bin/wekan-read-settings') diff --git a/snap-src/bin/wekan-read-settings b/snap-src/bin/wekan-read-settings index aec05bba..a924eaea 100755 --- a/snap-src/bin/wekan-read-settings +++ b/snap-src/bin/wekan-read-settings @@ -3,34 +3,18 @@ # 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 + 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 -- cgit v1.2.3-1-g7c22 From e077c85d003fb3cfd837ad8064ade767fa8fe04f Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Sat, 4 Nov 2017 19:23:28 +0000 Subject: Adding caddy support Signed-off-by: Ondrej Kubik --- snap-src/bin/wekan-read-settings | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'snap-src/bin/wekan-read-settings') 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 -- cgit v1.2.3-1-g7c22