From ff59c925e123505760ea4b865bf08d7b090865b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Thu, 27 Oct 2016 12:15:51 +0200 Subject: [PATCH] add sles 12 to pkgr.yml and check for used initservioce in pkgr-postinstall.sh --- .pkgr.yml | 4 +- ...l - packager.io complains about double use | 0 contrib/pkgr-postinstall.sh | 37 +++++++++++-------- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 Gemfile.local from .pkgr.yml - packager.io complains about double use diff --git a/.pkgr.yml b/.pkgr.yml index 56adefcfd..b01e6fe15 100644 --- a/.pkgr.yml +++ b/.pkgr.yml @@ -18,11 +18,13 @@ targets: ubuntu-16.04: dependencies: - postgresql + sles-12 + dependencies: + - postgresql before: - uname -a - ruby -v - env - - cp config/database.yml.pkgr config/database.yml - echo "gem 'mysql2'" >> Gemfile.local - "cat Gemfile.lock" - contrib/cleanup.sh diff --git a/Gemfile.local from .pkgr.yml - packager.io complains about double use b/Gemfile.local from .pkgr.yml - packager.io complains about double use new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/pkgr-postinstall.sh b/contrib/pkgr-postinstall.sh index d18cd4e00..7469a5a48 100755 --- a/contrib/pkgr-postinstall.sh +++ b/contrib/pkgr-postinstall.sh @@ -9,19 +9,32 @@ ZAMMAD_DIR="/opt/zammad" DB="zammad_production" DB_USER="zammad" +# check which init system is used +SYSTEMD="$(which systemd)" +UPSTART="$(which initctl)" + +if [ -n ${UPSTART} ]; then + INIT_COMMAND="initctl" +elif [ -n ${SYSTEMD} ]; then + INIT_CMD="systemd" +else + function sysvinit () { + service $2 $1 + } + + INIT_CMD="sysvinit" +fi + echo "# (Re)creating init scripts" zammad scale web=1 websocket=1 worker=1 echo "# Stopping Zammad" -systemctl stop zammad - -# check if database.yml.bak exists -if [ -f ${ZAMMAD_DIR}/config/database.yml.bak ]; then - # copy database.yml.bak to database.yml - cp ${ZAMMAD_DIR}/config/database.yml.bak ${ZAMMAD_DIR}/config/database.yml +${INIT_CMD} stop zammad +# check if database.yml exists +if [ -f ${ZAMMAD_DIR}/config/database.yml ]; then # db migration - echo "# database.yml.bak exists. Updating db..." + echo "# database.yml exists. Updating db..." zammad run rake db:migrate else # create new password @@ -40,19 +53,13 @@ else # update configfile sed "s/.*password:.*/ password: ${DB_PASS}/" < ${ZAMMAD_DIR}/config/database.yml.pkgr > ${ZAMMAD_DIR}/config/database.yml - # save database config for updates - cp ${ZAMMAD_DIR}/config/database.yml ${ZAMMAD_DIR}/config/database.yml.bak - - # zammad config set - zammad config:set DATABASE_URL=postgres://${DB_USER}:${DB_PASS}@127.0.0.1/${DB} - # fill database zammad run rake db:migrate zammad run rake db:seed fi echo "# Starting Zammad" -systemctl start zammad +${INIT_CMD} start zammad # nginx config if [ -d /etc/nginx/sites-enabled ]; then @@ -67,7 +74,7 @@ if [ -d /etc/nginx/sites-enabled ]; then fi echo "# Restarting Nginx" - systemctl restart nginx + ${INIT_CMD} restart nginx echo -e "\nOpen http://localhost in your browser to start using Zammad!\n" else