#!/bin/sh STAMP_DIR="/var/run/lliurex-biblioteca" STAMP_FILE="$STAMP_DIR/lliurex-biblioteca.stamp" DBC_PMB_CONFFILE_DIR="/usr/share/llxcfg/config" DBC_PMB_CONFFILE="pmb/conf/pmb.conf" DBC_DEBIAN_DB="/etc/pmb/debian-db.php" DBC_PMB="/etc/dbconfig-common/pmb.conf" DBC_PMB_MODDED="/etc/pmb/pmb_modded.conf" PMB_INST_PERMS="600" PMB_CONFFILE_OWNER="root" PMB_CONFFILE_WWW="root" PMB_CONFFILE_GROUP="root" PMB_PASSWD_FILE="/etc/pmb/pmb_passwd" PMB_PASSWD="" create_passwd() { PMB_PASSWD="$(pwgen -s -B -1)" echo $PMB_PASSWD > $PMB_PASSWD_FILE 2>/dev/null || true chown root:root $PMB_PASSWD_FILE 2>/dev/null || true chmod 600 $PMB_PASSWD_FILE 2>/dev/null || true } case "$1" in enable) mkdir -p "$STAMP_DIR" 2>/dev/null touch "$STAMP_FILE" ;; disable) rm -f "$STAMP_FILE" 2>/dev/null ;; test) [ ! -e "$STAMP_FILE" ] || exit 0 exit 1 ;; initialize) if [ ! -f "$DBC_DEBIAN_DB" ]; then if [ -f "$PMB_PASSWD_FILE" ]; then PMB_PASSWD="$(cat $PMB_PASSWD_FILE 2>/dev/null | head -1)" [ -z $PMB_PASSWD ] && create_passwd else create_passwd fi llxcfg-config read "$DBC_PMB_CONFFILE" | sed -e "s%__PMB_PASS__%$PMB_PASSWD%g" > "$DBC_PMB_MODDED" chown $PMB_CONFFILE_OWNER:$PMB_CONFFILE_GROUP "$DBC_PMB_MODDED" chmod $PMB_INST_PERMS "$DBC_PMB_MODDED" dbconfig-generate-include -f sh -a -U $DBC_PMB_MODDED $DBC_PMB dbconfig-generate-include -f php -a -U $DBC_PMB_MODDED $DBC_DEBIAN_DB export DEBIAN_FRONTEND=noninteractive export DEBCONF_FRONTEND=noninteractive debconf-set-selections /var/lib/llxcfg/cpkg/packages/pmb/pmb_first_load.pressed dpkg-reconfigure pmb sleep 5 dbconfig-generate-include -f template -a -o template_infile=$DBC_PMB_MODDED $DBC_PMB_MODDED $DBC_PMB debconf-set-selections /var/lib/llxcfg/cpkg/packages/pmb/pmb.pressed dpkg-reconfigure pmb llxcfg-cpkg configure pmb llxcfg-cpkg postconfigure pmb rm -f /usr/share/llxcfg-httpd/httpd/pmb rm -f /usr/share/llxcfg-httpd/httpd/biblioteca ln -sf /usr/share/pmb/www /usr/share/llxcfg-httpd/httpd/pmb ln -sf /usr/share/pmb/www /usr/share/llxcfg-httpd/httpd/biblioteca [ -x /etc/init.d/apache2 ] && invoke-rc.d apache2 reload fi ;; esac exit 0