Project

General

Profile

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

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

. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/postinst

# 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'

# Database setup
dbc_generate_include='template:/etc/foreman/database.yml'
dbc_generate_include_owner='foreman:foreman'
dbc_generate_include_perms='640'
dbc_dbfile_owner='foreman:foreman'
dbc_dbfile_perms='0660'

db_get foreman/database-type || true
DB_TYPE=${RET}

case "${DB_TYPE}" in
sqlite3)
dbc_generate_include_args='-o template_infile=/usr/share/foreman/templates/database-sqlite.yml.template'
;;
mysql|pgsql)
dbc_generate_include_args='-o template_infile=/usr/share/foreman/templates/database.yml.template'
;;
*)
exit 1;
;;
esac

dbc_go foreman $@

# initialize/migrate the database
su - foreman -s /bin/sh -c /usr/share/foreman/extras/dbmigrate >/dev/null 2>&1

#DEBHELPER#

exit 0
(14-14/18)