Project

General

Profile

Download (1.59 KB) Statistics
| Branch: | Tag: | Revision:
#!/bin/sh
# postinst script for foreman
#
# see: dh_installdeb(1)

if [ ! -z "${DEBUG}" ]; then
set -x
else
set -e
fi

. /usr/share/debconf/confmodule

# if this script aborts with an error dpkg can hang if a debconf can
# hang if daemons have been started
trap db_stop EXIT

# Add the "foreman" user and group
getent group foreman >/dev/null || groupadd -r foreman
getent passwd foreman >/dev/null || \
useradd -r -g foreman -G puppet -d /usr/share/foreman -s /usr/sbin/nologin -c "Foreman" foreman

chown -Rf foreman:foreman '/var/log/foreman'
chown -Rf foreman:foreman '/var/cache/foreman'
chown -Rf foreman:foreman '/var/lib/foreman'
chmod 755 '/var/lib/foreman'
chmod 755 '/var/lib/foreman/db'
chmod 755 '/var/lib/foreman/public'
chmod 755 '/var/lib/foreman/public/images'
chmod 755 '/var/lib/foreman/public/images/hosts'
chmod 755 '/var/lib/foreman/public/javascripts'
chmod 755 '/var/lib/foreman/public/stylesheets'
chmod 755 '/var/cache/foreman'

# Bundle install works even if we're already installed, so always use it
cd /usr/share/foreman
if [ ! -z "${DEBUG}" ]; then
bundle install --path ./vendor/ --local --no-prune
else
bundle install --path ./vendor/ --local --no-prune 2>&1 >/dev/null
fi

# Run a db:migrate if the user has created a dbfile
if [ -f /usr/share/foreman/config/database.yml ]; then
if [ ! -z "${DEBUG}" ]; then
su - foreman -s /bin/sh -c /usr/share/foreman/extras/dbmigrate || true
else
su - foreman -s /bin/sh -c /usr/share/foreman/extras/dbmigrate >/dev/null 2>&1 || true
fi
fi

# Own all the core files
chown -Rf foreman:foreman '/usr/share/foreman'

#DEBHELPER#

exit 0
(42-42/48)