1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#!/bin/sh
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
WARN='\033[0;33m'
INFO='\033[0;37m'
NC='\033[0m'
case "$1" in
configure)
# Add ara user
if ! getent passwd ara > /dev/null; then
adduser --quiet --system --home /var/lib/ara-server \
--group --gecos "Ara user" ara || true
fi
if [ ! -d /etc/ara-server ]; then
mkdir -p /etc/ara-server
chown ara:ara /etc/ara-server || true
fi
if [ ! -d /var/lib/ara-server ]; then
mkdir -p /var/lib/ara-server
chown ara:ara /var/lib/ara-server || true
fi
# Code below will generate config, place
# to /var/lib/ara-server.
# Second move to /etc/ara-server and replace
# config under /var/lib/ara-server by symlink
# pointing to /etc/ara-server
ARA_BASE_DIR=/var/lib/ara-server ara-manage migrate
if [ ! -L /var/lib/ara-server/settings.yaml ]; then
mv /var/lib/ara-server/settings.yaml /etc/ara-server/settings.yaml
ln -s /etc/ara-server/settings.yaml /var/lib/ara-server/settings.yaml
fi
ARA_BASE_DIR=/var/lib/ara-server ara-manage collectstatic --clear --noinput
find /var/lib/ara-server | xargs chown ara:ara
# Inform user that it is needed to configure ara
if [ -e /etc/ara-server/settings.yaml ]; then
if grep DATABASE_ENGINE /etc/ara-server/settings.yaml | grep -q sqlite3; then
echo "${WARN}[w] ara-server: Ara is using sqlite3 db backend currently, you should switch to mysql db in production.${NC}"
fi
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
:
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|