From fa8bf0f1d7f6f57f26491d210dfe673f5e49d29a Mon Sep 17 00:00:00 2001 From: Cyril Rohr Date: Thu, 10 Dec 2015 08:55:21 +0000 Subject: [PATCH] Fix postinstall to use GOGS_CUSTOM instead of symlinking --- .pkgr.yml | 2 +- packager/debian/postinst | 37 ------------------------------------- packager/hooks/postinst | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 38 deletions(-) delete mode 100755 packager/debian/postinst create mode 100755 packager/hooks/postinst diff --git a/.pkgr.yml b/.pkgr.yml index c81c91bf..9fa60ccb 100644 --- a/.pkgr.yml +++ b/.pkgr.yml @@ -24,4 +24,4 @@ before: - mv packager/.godir . after: - mv bin/main gogs -after_install: ./packager/debian/postinst +after_install: ./packager/hooks/postinst diff --git a/packager/debian/postinst b/packager/debian/postinst deleted file mode 100755 index 82f45b06..00000000 --- a/packager/debian/postinst +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -set -e - -APP_NAME="gogs" -CLI="${APP_NAME}" -APP_USER=$(${CLI} config:get APP_USER) -APP_GROUP=$(${CLI} config:get APP_GROUP) -APP_CONFIG="/etc/${APP_NAME}/conf/app.ini" - -case "$1" in - abort-upgrade|abort-remove|abort-deconfigure) - exit 0 - ;; - - configure|*) - mkdir -p $(dirname ${APP_CONFIG}) - chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG}) - [ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG} - ${CLI} config:set USER=${APP_USER} - sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG} - sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG} - - # setup symlink towards custom conf - mkdir -p /opt/${APP_NAME}/custom/conf - chown -R ${APP_USER}.${APP_GROUP} /opt/${APP_NAME}/custom - ln -f -s ${APP_CONFIG} /opt/${APP_NAME}/custom/conf/app.ini - - # scale - ${CLI} scale web=1 || true - - # restart the service - service gogs restart || true - - ;; - -esac diff --git a/packager/hooks/postinst b/packager/hooks/postinst new file mode 100755 index 00000000..561080ef --- /dev/null +++ b/packager/hooks/postinst @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +APP_NAME="gogs" +CLI="${APP_NAME}" +APP_USER=$(${CLI} config:get APP_USER) +APP_GROUP=$(${CLI} config:get APP_GROUP) +APP_CONFIG="/etc/${APP_NAME}/conf/app.ini" + +mkdir -p $(dirname ${APP_CONFIG}) +chown ${APP_USER}.${APP_GROUP} $(dirname ${APP_CONFIG}) +[ -f ${APP_CONFIG} ] || ${CLI} run cp conf/app.ini ${APP_CONFIG} +${CLI} config:set USER=${APP_USER} +sed -i "s|RUN_USER = git|RUN_USER = ${APP_USER}|" ${APP_CONFIG} +sed -i "s|RUN_MODE = dev|RUN_MODE = prod|" ${APP_CONFIG} + +${CLI} config:set GOGS_CUSTOM=/etc/${APP_NAME} + +# scale +${CLI} scale web=1 || true + +# restart the service +service gogs restart || true