summaryrefslogtreecommitdiffstats
path: root/debian/welco.postinst
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2015-07-15 16:37:50 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2015-09-29 16:12:41 (GMT)
commit7688d998bb347624742299804f165ca23960bc62 (patch)
tree2f766d181b52f2ab02578fa523ad09b5673e4026 /debian/welco.postinst
parent0e93097856c193a7db83b706695d2c16171df212 (diff)
downloadwelco-7688d998bb347624742299804f165ca23960bc62.zip
welco-7688d998bb347624742299804f165ca23960bc62.tar.gz
welco-7688d998bb347624742299804f165ca23960bc62.tar.bz2
debian: basic packaging
Diffstat (limited to 'debian/welco.postinst')
-rw-r--r--debian/welco.postinst44
1 files changed, 44 insertions, 0 deletions
diff --git a/debian/welco.postinst b/debian/welco.postinst
new file mode 100644
index 0000000..ee073d7
--- /dev/null
+++ b/debian/welco.postinst
@@ -0,0 +1,44 @@
+#! /bin/sh
+
+set -e
+
+NAME="welco"
+USER=$NAME
+GROUP=$NAME
+CONFIG_DIR="/etc/$NAME"
+
+case "$1" in
+ configure)
+
+ # make sure the administrative user exists
+ if ! getent passwd $USER >/dev/null; then
+ adduser --disabled-password --quiet --system \
+ --no-create-home --home /var/lib/$NAME \
+ --gecos "$NAME user" --group $USER
+ fi
+ # ensure dirs ownership
+ chown $USER:$GROUP /var/log/$NAME
+ chown $USER:$GROUP /var/lib/$NAME/collectstatic
+ chown $USER:$GROUP /var/lib/$NAME/tenants
+ # create a secret file
+ SECRET_FILE=$CONFIG_DIR/secret
+ if [ ! -f $SECRET_FILE ]; then
+ echo -n "Generating Django secret..." >&2
+ cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE
+ chown root:$GROUP $SECRET_FILE
+ chmod 0440 $SECRET_FILE
+ fi
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0