diff --git a/.pkgr.yml b/.pkgr.yml index 56adefcfd..1a1429b9e 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/contrib/pkgr-postinstall.sh b/contrib/pkgr-postinstall.sh index d18cd4e00..b5f9e005e 100755 --- a/contrib/pkgr-postinstall.sh +++ b/contrib/pkgr-postinstall.sh @@ -9,19 +9,29 @@ ZAMMAD_DIR="/opt/zammad" DB="zammad_production" DB_USER="zammad" +# check which init system is used +if [ -n "$(which initctl)" ]; then + INIT_CMD="initctl" +elif [ -n "$(which systemctl)" ]; then + INIT_CMD="systemctl" +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 +50,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 +71,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