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/config | 44 ++++++++++++++++++++++++++++++++++++ snap-src/bin/mongodb-backup | 23 +++++++++++++++++++ snap-src/bin/mongodb-control | 31 ++++++++++++++++++++++++++ snap-src/bin/mongodb-restore | 16 ++++++++++++++ snap-src/bin/wekan-control | 26 ++++++++++++++++++++++ snap-src/bin/wekan-help | 48 ++++++++++++++++++++++++++++++++++++++++ snap-src/bin/wekan-read-settings | 36 ++++++++++++++++++++++++++++++ snap-src/config | 44 ------------------------------------ snap-src/mongodb-backup | 23 ------------------- snap-src/mongodb-control | 31 -------------------------- snap-src/mongodb-restore | 16 -------------- snap-src/wekan-control | 26 ---------------------- snap-src/wekan-help | 48 ---------------------------------------- snap-src/wekan-read-settings | 36 ------------------------------ snapcraft.yaml | 8 ------- 15 files changed, 224 insertions(+), 232 deletions(-) create mode 100755 snap-src/bin/config create mode 100755 snap-src/bin/mongodb-backup create mode 100755 snap-src/bin/mongodb-control create mode 100755 snap-src/bin/mongodb-restore create mode 100755 snap-src/bin/wekan-control create mode 100755 snap-src/bin/wekan-help create mode 100755 snap-src/bin/wekan-read-settings delete mode 100755 snap-src/config delete mode 100755 snap-src/mongodb-backup delete mode 100755 snap-src/mongodb-control delete mode 100755 snap-src/mongodb-restore delete mode 100755 snap-src/wekan-control delete mode 100755 snap-src/wekan-help delete mode 100755 snap-src/wekan-read-settings diff --git a/snap-src/bin/config b/snap-src/bin/config new file mode 100755 index 00000000..dbf8402c --- /dev/null +++ b/snap-src/bin/config @@ -0,0 +1,44 @@ +#!/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 + +# list of supported keys +keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM ROOT_URL PORT DISABLE_MONGODB" + +# 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" +DEFAULT_MONGODB_BIND_UNIX_SOCKET="$SNAP_DATA/share" +KEY_MONGODB_BIND_UNIX_SOCKET="mongodb-bind-unix-socket" + +DESCRIPTION_MONGODB_PORT="mongodb binding port: eg 27017 when using localhost" +DEFAULT_MONGODB_PORT="27019" +KEY_MONGODB_PORT='mongodb-port' + +DESCRIPTION_MONGODB_BIND_IP="mongodb binding ip address: eg 127.0.0.1 for localhost\n\t\tIf not defined default unix socket is used instead" +DEFAULT_MONGODB_BIND_IP="" +KEY_MONGODB_BIND_IP="mongodb-bind-ip" + +DESCRIPTION_MAIL_URL="wekan mail binding" +DEFAULT_MAIL_URL="smtp://user:pass@mailserver.examples.com:25/" +KEY_MAIL_URL="mail-url" + +DESCRIPTION_MAIL_FROM="wekan's admin mail from name email address" +DEFAULT_MAIL_FROM="wekan-admin@example.com" +KEY_MAIL_FROM="mail-from" + +DESCRIPTION_ROOT_URL="wekan's root url, eg http://127.0.0.1, https://example.com, https://wekan.example.com, http://example.com/wekan" +DEFAULT_ROOT_URL="http://127.0.0.1" +KEY_ROOT_URL="root-url" + +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]" +DEFAULT_DISABLE_MONGODB="false" +KEY_DISABLE_MONGODB="disable-mongodb" diff --git a/snap-src/bin/mongodb-backup b/snap-src/bin/mongodb-backup new file mode 100755 index 00000000..bef8bf9b --- /dev/null +++ b/snap-src/bin/mongodb-backup @@ -0,0 +1,23 @@ +#!/bin/bash + +# get wekan/mongo settings +source $SNAP/bin/wekan-read-settings + +# make sure we have set minimum env variables for locale +if [ -z "$LANG" ]; then + export LANG=en_US.UTF-8 +fi + +export LC_ALL=C + +if [ -z $1 ]; then + DATE=`/bin/date +%Y%m%dT%H%M%S` + mkdir -p $SNAP_COMMON/db-backups/ + ARCHIVE=$SNAP_COMMON/db-backups/wekan-$DATE.backup +else + ARCHIVE=$1 +fi +# start mongodb backup +[ "x" == "x${MONGODB_BIND_IP}" ] && MONGODB_BIND_IP="127.0.0.1" + echo "using bind ip" +mongodump --host $MONGODB_BIND_IP --port $MONGODB_PORT -d wekan --gzip --archive=${ARCHIVE} diff --git a/snap-src/bin/mongodb-control b/snap-src/bin/mongodb-control new file mode 100755 index 00000000..08af132d --- /dev/null +++ b/snap-src/bin/mongodb-control @@ -0,0 +1,31 @@ +#!/bin/bash + +# get wekan/mongo settings +source $SNAP/bin/wekan-read-settings + +if [ "true" == "${DISABLE_MONGODB}" ]; then + echo "mongodb is disabled. Not starting it" + exit 0 +fi + +# make sure we have set minimum env variables for locale +if [ -z "$LANG" ]; then + export LANG=en_US.UTF-8 +fi + +export LC_ALL=C + +# start mongo deamon +BIND_OPTIONS="" +if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x${MONGODB_BIND_UNIX_SOCKET}" ]; then + BIND_OPTIONS+=" --unixSocketPrefix $MONGODB_BIND_UNIX_SOCKET" +fi +if [ "x" != "x${MONGODB_BIND_IP}" ]; then + BIND_OPTIONS+=" --bind_ip $MONGODB_BIND_IP" +fi +if [ "x" != "x${MONGODB_PORT}" ]; then + BIND_OPTIONS+=" --port $MONGODB_PORT" +fi +echo "mongodb bind options: $BIND_OPTIONS" + +mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $BIND_OPTIONS diff --git a/snap-src/bin/mongodb-restore b/snap-src/bin/mongodb-restore new file mode 100755 index 00000000..c1c82775 --- /dev/null +++ b/snap-src/bin/mongodb-restore @@ -0,0 +1,16 @@ +#!/bin/bash + +# get wekan/mongo settings +source $SNAP/bin/wekan-read-settings + +# make sure we have set minimum env variables for locale +if [ -z "$LANG" ]; then + export LANG=en_US.UTF-8 +fi + +export LC_ALL=C + +# start mongodb backup +[ "x" == "x${MONGODB_BIND_IP}" ] && MONGODB_BIND_IP="127.0.0.1" +echo "using bind ip" +mongorestore --host $MONGODB_BIND_IP --port $MONGODB_PORT -d wekan --gzip --archive=$1 diff --git a/snap-src/bin/wekan-control b/snap-src/bin/wekan-control new file mode 100755 index 00000000..905642ed --- /dev/null +++ b/snap-src/bin/wekan-control @@ -0,0 +1,26 @@ +#!/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 + +export NODE_PATH=$SNAP/bin +# if possible we prefer to bind over unix socket +if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x$MONGODB_BIND_UNIX_SOCKET" ]; then + if [ -d $MONGODB_BIND_UNIX_SOCKET ]; then + export MONGO_URL="mongodb://$MONGODB_BIND_UNIX_SOCKET/mongodb-${MONGODB_PORT}.sock/wekan" + else + export MONGO_URL="mongodb://$SNAP_DATA/shared/$MONGODB_BIND_UNIX_SOCKET/wekan" + fi +else + [ "x" == "x$MONGODB_BIND_IP" ] && MONGODB_BIND_IP="127.0.0.1" + export MONGO_URL="mongodb://$MONGODB_BIND_IP:$MONGODB_PORT/wekan" +fi + +echo -e "MONGO_URL=$MONGO_URL" +APPLICATION_DIRECTORY=$SNAP +APPLICATION_START=main.js +cd $APPLICATION_DIRECTORY +$NODE_PATH/node $APPLICATION_START diff --git a/snap-src/bin/wekan-help b/snap-src/bin/wekan-help new file mode 100755 index 00000000..bbf0e138 --- /dev/null +++ b/snap-src/bin/wekan-help @@ -0,0 +1,48 @@ +#!/bin/bash + +source $SNAP/bin/config &>/dev/null + +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 "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 "\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:" +echo -e "\t\t${SNAP_COMMON}/db-backups" +echo -e "To list existing backups in default directory: $ ${SNAP_NAME}.database-list-backups" +echo -e "To restore wekan's database use: ${SNAP_NAME}.database-restore " +echo -e "\n" +echo -e "wekan can be configured to share mongodb with other services using content interface" +echo -e "\t-sharing mongodb from $SNAP_NAME to other snap(s):" +echo -e "\t\t-connect mongodb-slot with plug from corresponding snap(s)" +echo -e "\t\t-configure corresponding service to use mongodb unix socket in shared directory, socket file name is: mongodb-$MONGODB_PORT.sock" +echo -e "\t-sharing mongodb from other snap to $SNAP_NAME:" +echo -e "\t\t-connect mongodb-plug with slot from snap providing mongodb" +echo -e "\t\t-disable mongodb in $SNAP_NAME by calling: $ snap set $SNAP_NAME set disable-mongodb='true'" +echo -e "\t\t-set mongodb-bind-unix-socket to point to serving mongodb. Use relative path inside shared directory, e.g run/mongodb-27017.sock" +echo -e "\n" +# parse config file for supported settings keys +echo -e "wekan supports settings keys" +echo -e "values can be changed by calling\n$ snap set $SNAP_NAME =''" +echo -e "list of supported keys:" +for key in ${keys[@]} +do + default_value="DEFAULT_$key" + description="DESCRIPTION_$key" + snappy_key="KEY_$key" + echo -e "\t${!snappy_key}: ${!description}" + if [ "x" == "x${!key}" ]; then + echo -e "\t\tNo value set, using default value: '${!default_value}'" + else + 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" 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 diff --git a/snap-src/config b/snap-src/config deleted file mode 100755 index dbf8402c..00000000 --- a/snap-src/config +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 - -# list of supported keys -keys="MONGODB_BIND_UNIX_SOCKET MONGODB_BIND_IP MONGODB_PORT MAIL_URL MAIL_FROM ROOT_URL PORT DISABLE_MONGODB" - -# 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" -DEFAULT_MONGODB_BIND_UNIX_SOCKET="$SNAP_DATA/share" -KEY_MONGODB_BIND_UNIX_SOCKET="mongodb-bind-unix-socket" - -DESCRIPTION_MONGODB_PORT="mongodb binding port: eg 27017 when using localhost" -DEFAULT_MONGODB_PORT="27019" -KEY_MONGODB_PORT='mongodb-port' - -DESCRIPTION_MONGODB_BIND_IP="mongodb binding ip address: eg 127.0.0.1 for localhost\n\t\tIf not defined default unix socket is used instead" -DEFAULT_MONGODB_BIND_IP="" -KEY_MONGODB_BIND_IP="mongodb-bind-ip" - -DESCRIPTION_MAIL_URL="wekan mail binding" -DEFAULT_MAIL_URL="smtp://user:pass@mailserver.examples.com:25/" -KEY_MAIL_URL="mail-url" - -DESCRIPTION_MAIL_FROM="wekan's admin mail from name email address" -DEFAULT_MAIL_FROM="wekan-admin@example.com" -KEY_MAIL_FROM="mail-from" - -DESCRIPTION_ROOT_URL="wekan's root url, eg http://127.0.0.1, https://example.com, https://wekan.example.com, http://example.com/wekan" -DEFAULT_ROOT_URL="http://127.0.0.1" -KEY_ROOT_URL="root-url" - -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]" -DEFAULT_DISABLE_MONGODB="false" -KEY_DISABLE_MONGODB="disable-mongodb" diff --git a/snap-src/mongodb-backup b/snap-src/mongodb-backup deleted file mode 100755 index bef8bf9b..00000000 --- a/snap-src/mongodb-backup +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -# get wekan/mongo settings -source $SNAP/bin/wekan-read-settings - -# make sure we have set minimum env variables for locale -if [ -z "$LANG" ]; then - export LANG=en_US.UTF-8 -fi - -export LC_ALL=C - -if [ -z $1 ]; then - DATE=`/bin/date +%Y%m%dT%H%M%S` - mkdir -p $SNAP_COMMON/db-backups/ - ARCHIVE=$SNAP_COMMON/db-backups/wekan-$DATE.backup -else - ARCHIVE=$1 -fi -# start mongodb backup -[ "x" == "x${MONGODB_BIND_IP}" ] && MONGODB_BIND_IP="127.0.0.1" - echo "using bind ip" -mongodump --host $MONGODB_BIND_IP --port $MONGODB_PORT -d wekan --gzip --archive=${ARCHIVE} diff --git a/snap-src/mongodb-control b/snap-src/mongodb-control deleted file mode 100755 index 08af132d..00000000 --- a/snap-src/mongodb-control +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# get wekan/mongo settings -source $SNAP/bin/wekan-read-settings - -if [ "true" == "${DISABLE_MONGODB}" ]; then - echo "mongodb is disabled. Not starting it" - exit 0 -fi - -# make sure we have set minimum env variables for locale -if [ -z "$LANG" ]; then - export LANG=en_US.UTF-8 -fi - -export LC_ALL=C - -# start mongo deamon -BIND_OPTIONS="" -if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x${MONGODB_BIND_UNIX_SOCKET}" ]; then - BIND_OPTIONS+=" --unixSocketPrefix $MONGODB_BIND_UNIX_SOCKET" -fi -if [ "x" != "x${MONGODB_BIND_IP}" ]; then - BIND_OPTIONS+=" --bind_ip $MONGODB_BIND_IP" -fi -if [ "x" != "x${MONGODB_PORT}" ]; then - BIND_OPTIONS+=" --port $MONGODB_PORT" -fi -echo "mongodb bind options: $BIND_OPTIONS" - -mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $BIND_OPTIONS diff --git a/snap-src/mongodb-restore b/snap-src/mongodb-restore deleted file mode 100755 index c1c82775..00000000 --- a/snap-src/mongodb-restore +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# get wekan/mongo settings -source $SNAP/bin/wekan-read-settings - -# make sure we have set minimum env variables for locale -if [ -z "$LANG" ]; then - export LANG=en_US.UTF-8 -fi - -export LC_ALL=C - -# start mongodb backup -[ "x" == "x${MONGODB_BIND_IP}" ] && MONGODB_BIND_IP="127.0.0.1" -echo "using bind ip" -mongorestore --host $MONGODB_BIND_IP --port $MONGODB_PORT -d wekan --gzip --archive=$1 diff --git a/snap-src/wekan-control b/snap-src/wekan-control deleted file mode 100755 index 905642ed..00000000 --- a/snap-src/wekan-control +++ /dev/null @@ -1,26 +0,0 @@ -#!/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 - -export NODE_PATH=$SNAP/bin -# if possible we prefer to bind over unix socket -if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x$MONGODB_BIND_UNIX_SOCKET" ]; then - if [ -d $MONGODB_BIND_UNIX_SOCKET ]; then - export MONGO_URL="mongodb://$MONGODB_BIND_UNIX_SOCKET/mongodb-${MONGODB_PORT}.sock/wekan" - else - export MONGO_URL="mongodb://$SNAP_DATA/shared/$MONGODB_BIND_UNIX_SOCKET/wekan" - fi -else - [ "x" == "x$MONGODB_BIND_IP" ] && MONGODB_BIND_IP="127.0.0.1" - export MONGO_URL="mongodb://$MONGODB_BIND_IP:$MONGODB_PORT/wekan" -fi - -echo -e "MONGO_URL=$MONGO_URL" -APPLICATION_DIRECTORY=$SNAP -APPLICATION_START=main.js -cd $APPLICATION_DIRECTORY -$NODE_PATH/node $APPLICATION_START diff --git a/snap-src/wekan-help b/snap-src/wekan-help deleted file mode 100755 index bbf0e138..00000000 --- a/snap-src/wekan-help +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -source $SNAP/bin/config &>/dev/null - -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 "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 "\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:" -echo -e "\t\t${SNAP_COMMON}/db-backups" -echo -e "To list existing backups in default directory: $ ${SNAP_NAME}.database-list-backups" -echo -e "To restore wekan's database use: ${SNAP_NAME}.database-restore " -echo -e "\n" -echo -e "wekan can be configured to share mongodb with other services using content interface" -echo -e "\t-sharing mongodb from $SNAP_NAME to other snap(s):" -echo -e "\t\t-connect mongodb-slot with plug from corresponding snap(s)" -echo -e "\t\t-configure corresponding service to use mongodb unix socket in shared directory, socket file name is: mongodb-$MONGODB_PORT.sock" -echo -e "\t-sharing mongodb from other snap to $SNAP_NAME:" -echo -e "\t\t-connect mongodb-plug with slot from snap providing mongodb" -echo -e "\t\t-disable mongodb in $SNAP_NAME by calling: $ snap set $SNAP_NAME set disable-mongodb='true'" -echo -e "\t\t-set mongodb-bind-unix-socket to point to serving mongodb. Use relative path inside shared directory, e.g run/mongodb-27017.sock" -echo -e "\n" -# parse config file for supported settings keys -echo -e "wekan supports settings keys" -echo -e "values can be changed by calling\n$ snap set $SNAP_NAME =''" -echo -e "list of supported keys:" -for key in ${keys[@]} -do - default_value="DEFAULT_$key" - description="DESCRIPTION_$key" - snappy_key="KEY_$key" - echo -e "\t${!snappy_key}: ${!description}" - if [ "x" == "x${!key}" ]; then - echo -e "\t\tNo value set, using default value: '${!default_value}'" - else - 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" 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/snapcraft.yaml b/snapcraft.yaml index 1a85f682..7766f677 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -124,11 +124,3 @@ parts: helpers: source: snap-src plugin: dump - 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 -- cgit v1.2.3-1-g7c22 From f7fe44fcdf56ef5a761924865c6d5869539b6410 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Sat, 4 Nov 2017 19:03:31 +0000 Subject: removing unused variables Signed-off-by: Ondrej Kubik --- snap-src/bin/wekan-control | 3 --- 1 file changed, 3 deletions(-) diff --git a/snap-src/bin/wekan-control b/snap-src/bin/wekan-control index 905642ed..bc2cefde 100755 --- a/snap-src/bin/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 -- 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 +++++++++++--------------------------- snap/hooks/configure | 28 +++------------------------- snap/hooks/install | 12 ++++++++++++ snap/hooks/post-refresh | 1 + 4 files changed, 27 insertions(+), 52 deletions(-) create mode 100755 snap/hooks/install create mode 120000 snap/hooks/post-refresh 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 diff --git a/snap/hooks/configure b/snap/hooks/configure index 1e2b0ec7..60ce81e8 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -1,32 +1,10 @@ #!/bin/bash +exec >> $SNAP_COMMON/hook.log 2>&1 +echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook" + # 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 -# 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." 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 -- 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/Caddyfile | 5 +++++ snap-src/bin/caddy-control | 12 ++++++++++++ snap-src/bin/config | 12 +++++++++++- snap-src/bin/wekan-read-settings | 9 +++++++++ snap/hooks/configure | 12 ++++++++++++ snapcraft.yaml | 14 ++++++++++++++ 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 snap-src/Caddyfile create mode 100755 snap-src/bin/caddy-control 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..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 diff --git a/snap/hooks/configure b/snap/hooks/configure index 60ce81e8..fd18da33 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -7,4 +7,16 @@ echo "$(date '+%Y-%m-%d %H:%M:%S') $0: Entering hook" . $SNAP/bin/config # 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 caddy-service 2>&1 || true +else + snapctl stop caddy-service 2>&1 || true +fi diff --git a/snapcraft.yaml b/snapcraft.yaml index 7766f677..ce41bdf3 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -38,6 +38,11 @@ apps: daemon: simple plugs: [network, network-bind] + caddy-service: + command: caddy-control + daemon: simple + plugs: [network, network-bind] + help: command: wekan-help @@ -124,3 +129,12 @@ parts: helpers: source: snap-src plugin: dump + + caddy: + plugin: go + go-importpath: github.com/mholt/caddy + source: https://github.com/mholt/caddy.git + source-type: git + source-commit: 53e117802fedd5915eeb32907873d8786a4b2936 + prime: + - bin/caddy -- cgit v1.2.3-1-g7c22 From d7ea73ff8287d69583b74f779470fce6d34f30db Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Sat, 4 Nov 2017 19:24:06 +0000 Subject: adding uspport for snapctl restart Signed-off-by: Ondrej Kubik --- snap/hooks/configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snap/hooks/configure b/snap/hooks/configure index fd18da33..15d68a19 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -20,3 +20,6 @@ else snapctl stop caddy-service 2>&1 || true fi +# restart mongo and wekan service +snapctl restart mongodb 2>&1 || true +snapctl restart wekan 2>&1 || true -- cgit v1.2.3-1-g7c22 From f7920da0cf74290ffec30a967a1d70ab36d22268 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Sat, 4 Nov 2017 19:42:11 +0000 Subject: fixing go build error because of go version used on build server Signed-off-by: Ondrej Kubik --- snapcraft.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/snapcraft.yaml b/snapcraft.yaml index ce41bdf3..d9e7ccf0 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -130,11 +130,27 @@ parts: source: snap-src plugin: dump + go: + plugin: nil + prepare: | + gov=$(echo "$(go version | awk '{ print $3}' | sed 's/^..//') 1.7" | awk '{if ($1 < $2) print "old";}') + echo "$(go version)" + if [ "${gov}" = "old" ]; then \ + echo "updating to new go"; \ + curl https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz -o go1.9.2.linux-amd64.tar.gz; \ + tar -xvf go1.9.2.linux-amd64.tar.gz; \ + rm -rf /usr/lib/go; \ + mv go /usr/lib/; \ + ln -sf ../lib/go/bin/go /usr/bin/go; \ + fi + caddy: plugin: go go-importpath: github.com/mholt/caddy source: https://github.com/mholt/caddy.git source-type: git source-commit: 53e117802fedd5915eeb32907873d8786a4b2936 + after: + - go prime: - bin/caddy -- cgit v1.2.3-1-g7c22 From 19089e8930dbcb048271dcd4fa444f8ad7837fe1 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Mon, 6 Nov 2017 10:47:24 +0000 Subject: rewording helper script output Signed-off-by: Ondrej Kubik --- snap-src/bin/config | 2 +- snap-src/bin/wekan-help | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/snap-src/bin/config b/snap-src/bin/config index e0b257d7..aa1625f6 100755 --- a/snap-src/bin/config +++ b/snap-src/bin/config @@ -45,7 +45,7 @@ DESCRIPTION_DISABLE_MONGODB="Disable mongodb service: use only if binding to dat 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" +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" diff --git a/snap-src/bin/wekan-help b/snap-src/bin/wekan-help index bbf0e138..36854ddb 100755 --- a/snap-src/bin/wekan-help +++ b/snap-src/bin/wekan-help @@ -10,6 +10,8 @@ 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 +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 !!!!!" -- cgit v1.2.3-1-g7c22 From fcd7097ababeed2b396fcee23aaf76f4973a1530 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Mon, 6 Nov 2017 10:47:50 +0000 Subject: Renaming caddy service for simplicity Signed-off-by: Ondrej Kubik --- snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index d9e7ccf0..aee1af8b 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -38,7 +38,7 @@ apps: daemon: simple plugs: [network, network-bind] - caddy-service: + caddy: command: caddy-control daemon: simple plugs: [network, network-bind] -- cgit v1.2.3-1-g7c22 From 9c9694bcd127810cf37667bc3ddc9ef7558996d3 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Wed, 6 Dec 2017 14:49:18 +0000 Subject: Fixing snapctl start/stop to control service lifecycle Adding disable and enable options for snapctl start/stop Signed-off-by: Ondrej Kubik --- snap/hooks/configure | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index 15d68a19..b215cc85 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -15,11 +15,10 @@ if [ "$value" = "true" ]; then 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 caddy-service 2>&1 || true + snapctl start --enable ${SNAP_NAME}.caddy 2>&1 || true else - snapctl stop caddy-service 2>&1 || true + snapctl stop --disable ${SNAP_NAME}.caddy 2>&1 || true fi -# restart mongo and wekan service -snapctl restart mongodb 2>&1 || true -snapctl restart wekan 2>&1 || true +# restart all services +snapctl restart ${SNAP_NAME} 2>&1 || true -- cgit v1.2.3-1-g7c22 From ff320f7b3a40072de641dcdcab935c69f6f8584a Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Wed, 6 Dec 2017 17:50:39 +0000 Subject: enabling verbose logging from configure hook Signed-off-by: Ondrej Kubik --- snap/hooks/configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snap/hooks/configure b/snap/hooks/configure index b215cc85..5d121e15 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -3,6 +3,8 @@ 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 -- cgit v1.2.3-1-g7c22 From 9966c19f949824e7d82ac25dae72e4bd03975a9d Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Wed, 6 Dec 2017 17:59:44 +0000 Subject: Fixing wrong caddy file path Signed-off-by: Ondrej Kubik --- snap-src/bin/caddy-control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap-src/bin/caddy-control b/snap-src/bin/caddy-control index c6a4f0d4..92ce70ba 100755 --- a/snap-src/bin/caddy-control +++ b/snap-src/bin/caddy-control @@ -4,7 +4,7 @@ source $SNAP/bin/wekan-read-settings if [ "$CADDY_ENABLED" = "true" ]; then - env LC_ALL=C caddy -conf=$SNAP_DATA/Caddyfile -host=localhost:${CADDY_PORT} + 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 -- cgit v1.2.3-1-g7c22 From af82a80b2b389eb0ba3b27236e888121ba00c701 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Fri, 9 Feb 2018 02:04:17 +0000 Subject: Using upstream caddy instead of compiling from source Signed-off-by: Ondrej Kubik --- snapcraft.yaml | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index aee1af8b..b72ecb84 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -130,27 +130,15 @@ parts: source: snap-src plugin: dump - go: - plugin: nil - prepare: | - gov=$(echo "$(go version | awk '{ print $3}' | sed 's/^..//') 1.7" | awk '{if ($1 < $2) print "old";}') - echo "$(go version)" - if [ "${gov}" = "old" ]; then \ - echo "updating to new go"; \ - curl https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz -o go1.9.2.linux-amd64.tar.gz; \ - tar -xvf go1.9.2.linux-amd64.tar.gz; \ - rm -rf /usr/lib/go; \ - mv go /usr/lib/; \ - ln -sf ../lib/go/bin/go /usr/bin/go; \ - fi - caddy: - plugin: go - go-importpath: github.com/mholt/caddy - source: https://github.com/mholt/caddy.git - source-type: git - source-commit: 53e117802fedd5915eeb32907873d8786a4b2936 - after: - - go - prime: - - bin/caddy + plugin: dump + source: https://caddyserver.com/download/linux/amd64?plugins= + source-type: tar + organize: + 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 -- cgit v1.2.3-1-g7c22 From 62fca18feaf3d5176817e43b08df17dfd40113be Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Fri, 9 Feb 2018 02:17:02 +0000 Subject: Updating gitignore Signed-off-by: Ondrej Kubik --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 89dc3fd5..acb9bcc7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ package-lock.json **/stage **/prime **/*.snap +snap/.snapcraft/ -- cgit v1.2.3-1-g7c22 From 07fc296762275b911d9b24e8f9046f22c18f7074 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Fri, 9 Feb 2018 02:19:12 +0000 Subject: Cleaning snapctl usage Signed-off-by: Ondrej Kubik --- snap-src/bin/config | 7 +------ snap-src/bin/wekan-help | 5 +++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/snap-src/bin/config b/snap-src/bin/config index aa1625f6..c3434c8e 100755 --- a/snap-src/bin/config +++ b/snap-src/bin/config @@ -1,11 +1,6 @@ #!/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 +# 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 CADDY_ENABLED CADDY_BIND_PORT" diff --git a/snap-src/bin/wekan-help b/snap-src/bin/wekan-help index 36854ddb..14702d9a 100755 --- a/snap-src/bin/wekan-help +++ b/snap-src/bin/wekan-help @@ -1,11 +1,12 @@ #!/bin/bash -source $SNAP/bin/config &>/dev/null +# first read settings +source $SNAP/bin/wekan-read-settings &>/dev/null 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" -- cgit v1.2.3-1-g7c22 From fcd83ea7bd913d41c437aa80e5e25a9fd14a7511 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Tue, 20 Feb 2018 18:08:25 +0000 Subject: Fixing automatic review fail for snap store upload Signed-off-by: Ondrej Kubik --- snapcraft.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snapcraft.yaml b/snapcraft.yaml index b72ecb84..d1ef6856 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -90,6 +90,7 @@ parts: - npm - curl - paxctl + - execstack prepare: | echo "Cleaning environment first" rm -rf ~/.meteor ~/.npm /usr/local/lib/node_modules @@ -123,6 +124,7 @@ 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 -- cgit v1.2.3-1-g7c22 From ad1a181f6df970265500b9621cfbfa9b38b5de22 Mon Sep 17 00:00:00 2001 From: Ondrej Kubik Date: Wed, 21 Feb 2018 18:41:03 +0000 Subject: Fixing wrong port number shown in wekan.help Signed-off-by: Ondrej Kubik --- snap-src/bin/wekan-help | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snap-src/bin/wekan-help b/snap-src/bin/wekan-help index 14702d9a..a498b9b9 100755 --- a/snap-src/bin/wekan-help +++ b/snap-src/bin/wekan-help @@ -2,6 +2,10 @@ # 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" -- cgit v1.2.3-1-g7c22 From d374cd2f813e5e88b0e10b6fe851565b36e5ab0a Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 22 Feb 2018 02:09:05 +0200 Subject: Snap updates: - 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 kubiko ! Closes wekan/wekan-snap#25, closes wekan/wekan-snap#12, closes wekan/wekan-snap#29, closes wekan/wekan-snap#33 --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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: -- cgit v1.2.3-1-g7c22