diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-02-22 02:17:52 +0200 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-02-22 02:17:52 +0200 |
commit | 7498dba32c8fbf460e04af49d5fb32dc5e63ed8b (patch) | |
tree | 19d7cbfa45e4de37142e6a2dcede722b3f09a89d | |
parent | 26f66f3cf05d3ab3dd633d02399cea5aa5a99c00 (diff) | |
parent | d374cd2f813e5e88b0e10b6fe851565b36e5ab0a (diff) | |
download | wekan-7498dba32c8fbf460e04af49d5fb32dc5e63ed8b.tar.gz wekan-7498dba32c8fbf460e04af49d5fb32dc5e63ed8b.tar.bz2 wekan-7498dba32c8fbf460e04af49d5fb32dc5e63ed8b.zip |
Merge branch 'kubiko-devel' into devel
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CHANGELOG.md | 15 | ||||
-rw-r--r-- | snap-src/Caddyfile | 5 | ||||
-rwxr-xr-x | snap-src/bin/caddy-control | 12 | ||||
-rwxr-xr-x | snap-src/bin/config (renamed from snap-src/config) | 15 | ||||
-rwxr-xr-x | snap-src/bin/mongodb-backup (renamed from snap-src/mongodb-backup) | 0 | ||||
-rwxr-xr-x | snap-src/bin/mongodb-control (renamed from snap-src/mongodb-control) | 0 | ||||
-rwxr-xr-x | snap-src/bin/mongodb-restore (renamed from snap-src/mongodb-restore) | 0 | ||||
-rwxr-xr-x | snap-src/bin/wekan-control (renamed from snap-src/wekan-control) | 3 | ||||
-rwxr-xr-x | snap-src/bin/wekan-help (renamed from snap-src/wekan-help) | 17 | ||||
-rwxr-xr-x | snap-src/bin/wekan-read-settings | 29 | ||||
-rwxr-xr-x | snap-src/wekan-read-settings | 36 | ||||
-rwxr-xr-x | snap/hooks/configure | 44 | ||||
-rwxr-xr-x | snap/hooks/install | 12 | ||||
l--------- | snap/hooks/post-refresh | 1 | ||||
-rw-r--r-- | snapcraft.yaml | 26 |
16 files changed, 134 insertions, 82 deletions
@@ -14,3 +14,4 @@ package-lock.json **/stage **/prime **/*.snap +snap/.snapcraft/ diff --git a/CHANGELOG.md b/CHANGELOG.md index c4f0fea3..84bae500 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# Upcoming Wekan release + +[Snap updates](https://github.com/wekan/wekan/pull/1495): + +- cleanup of snap helper scripts +- cleanup and snapctl settings handling +- fix for snap store auto review refusal +- adding support for automatic restart of services when setting(s) are changed. + No need to call systemctl restart anymore..... +- fixing snap set functionality +- adding optional caddy service support ( by default caddy service is disabled), + it can be enabled by calling: snap set wekan caddy-enabled=true + +Thanks to GitHub user kubiko for contributions. + # v0.76 2018-02-21 Wekan release This release adds the following new features: 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..92ce70ba --- /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 + 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/config b/snap-src/bin/config index dbf8402c..c3434c8e 100755 --- a/snap-src/config +++ b/snap-src/bin/config @@ -1,12 +1,9 @@ #!/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"\ @@ -42,3 +39,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\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..08af132d 100755 --- a/snap-src/mongodb-control +++ b/snap-src/bin/mongodb-control 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..a498b9b9 100755 --- a/snap-src/wekan-help +++ b/snap-src/bin/wekan-help @@ -1,15 +1,22 @@ #!/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 "\n" -echo -e "${SNAP_NAME} has two services, to check status/restart/stop use systemd commands" +echo -e "${SNAP_NAME} has multiple services, to check status/restart/stop use systemctl" 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 "Optional caddy service" +echo -e "\t$ sudo systemctl status/start/stop/restart snap.$SNAP_NAME.caddy" 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 +49,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 diff --git a/snap/hooks/configure b/snap/hooks/configure index 1e2b0ec7..5d121e15 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -1,32 +1,26 @@ #!/bin/bash +exec >> $SNAP_COMMON/hook.log 2>&1 +echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook" + +set -x + # read wekan config . $SNAP/bin/config -# create run dir, we're going to use it for unix socket -mkdir -p $SNAP_DATA/share -mkdir -p $SNAP_DATA/shared - # settings were altered by user, safest way to get them applied is to restart service +# first check if caddy service is enabled +value=$(snapctl get caddy-enabled) +if [ "$value" = "true" ]; then + # update caddy file + bind_port=$(snapctl get caddy-bind-port) + port=$(snapctl get port) + [ "x" != "x${bind_port}" ] && sed -i 's|proxy / localhost:.* {|proxy / localhost:'"${bind_port}"' {|g' $SNAP_COMMON/Caddyfile + [ "x" != "x$port" ] && sed -i 's|http://:.*|http://:'"${port}"'|g' $SNAP_COMMON/Caddyfile + snapctl start --enable ${SNAP_NAME}.caddy 2>&1 || true +else + snapctl stop --disable ${SNAP_NAME}.caddy 2>&1 || true +fi -# TODO: remove this workaround once it's not needed -# for the moment we can't read settings outside of the hook, -# so store all settings in helpper script which is then picked by main wrapper -echo -e "#!/bin/sh\n" > $SETTINGS_FILE -for key in ${keys[@]} -do - # snappy is picky about key syntax, using mapping - MAP_KEY="KEY_$key" - if value=$(snapctl get ${!MAP_KEY}); then - echo "export $key='$value'" >> $SETTINGS_FILE - elif [ -d "${!key}" ]; then - # store back value from SETTINGS_FILE - echo "export $key='${!key}'" >> $SETTINGS_FILE - fi -done - -# set file executable -chmod 755 $SETTINGS_FILE -# we can't use snapctl to restart service, may be one day .... - -echo "Setting has been updated, restart service." +# restart all services +snapctl restart ${SNAP_NAME} 2>&1 || true diff --git a/snap/hooks/install b/snap/hooks/install new file mode 100755 index 00000000..14087eaa --- /dev/null +++ b/snap/hooks/install @@ -0,0 +1,12 @@ +#!/bin/bash + +exec >> $SNAP_COMMON/hook.log 2>&1 +echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook" + +# coppy caddy file in place +[ ! -e $SNAP_COMMON/Caddyfile ] && cp $SNAP/Caddyfile $SNAP_COMMON/Caddyfile + +# create run dir, we're going to use it for unix socket +mkdir -p $SNAP_DATA/share +mkdir -p $SNAP_DATA/shared + diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh new file mode 120000 index 00000000..f7ffc47a --- /dev/null +++ b/snap/hooks/post-refresh @@ -0,0 +1 @@ +install
\ No newline at end of file diff --git a/snapcraft.yaml b/snapcraft.yaml index 1a85f682..d1ef6856 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -38,6 +38,11 @@ apps: daemon: simple plugs: [network, network-bind] + caddy: + command: caddy-control + daemon: simple + plugs: [network, network-bind] + help: command: wekan-help @@ -85,6 +90,7 @@ parts: - npm - curl - paxctl + - execstack prepare: | echo "Cleaning environment first" rm -rf ~/.meteor ~/.npm /usr/local/lib/node_modules @@ -118,17 +124,23 @@ parts: cp -r .build/bundle/* $SNAPCRAFT_PART_INSTALL/ cp .build/bundle/.node_version.txt $SNAPCRAFT_PART_INSTALL/ rm $SNAPCRAFT_PART_INSTALL/lib/node_modules/wekan + execstack --clear-execstack $SNAPCRAFT_PART_INSTALL/programs/server/npm/node_modules/meteor/rajit_bootstrap3-datepicker/lib/bootstrap-datepicker/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs organize: README: README.wekan helpers: source: snap-src plugin: dump + + caddy: + plugin: dump + source: https://caddyserver.com/download/linux/amd64?plugins= + source-type: tar organize: - wekan-control: bin/wekan-control - mongodb-control: bin/mongodb-control - wekan-read-settings: bin/wekan-read-settings - wekan-help: bin/wekan-help - mongodb-backup: bin/mongodb-backup - mongodb-restore: bin/mongodb-restore - config: bin/config + caddy: bin/caddy + CHANGES.txt: CADDY_CHANGES.txt + EULA.txt: CADDY_EULA.txt + LICENSES.txt: CADDY_LICENSES.txt + README.txt: CADDY_README.txt + stage: + - -init |