5 # Source debconf library.
6 . /usr/share/debconf/confmodule
8 CONFIGFILE="/etc/alternc/local.sh"
16 if [ ! -z "$RET" ]; then
17 grep -Eq "^ *$var=" $CONFIGFILE || echo "$var=" >> $CONFIGFILE
18 SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\"
22 # summary of how this script can be called:
23 # * <postinst> `configure' <most-recently-configured-version>
24 # * <old-postinst> `abort-upgrade' <new version>
25 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
27 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
28 # <failed-install-package> <version> `removing'
29 # <conflicting-package> <version>
30 # for details, see http://www.debian.org/doc/debian-policy/ or
31 # the debian-policy package
33 # quoting from the policy:
34 # Any necessary prompting should almost always be confined to the
35 # post-installation script, and should be protected with a conditional
36 # so that unnecessary prompting doesn't happen if a package's
37 # installation fails and the `postinst' is called with `abort-upgrade',
38 # `abort-remove' or `abort-deconfigure'.
43 # Create AlternC Panel user for web server
44 if ! getent group alterncpanel; then
45 addgroup --system --gid 1999 alterncpanel
47 if ! getent passwd alterncpanel; then
48 adduser --system --home "/etc/alternc/.alterncpanel" \
49 --disabled-password --uid 1999 --ingroup alterncpanel alterncpanel
52 # ajoute l'user postfix au groupe sasl
53 adduser --quiet postfix sasl
55 # corriger les permissions du chroot
56 mkdir -p /var/spool/postfix/var/run/saslauthd || true
57 dpkg-statoverride --quiet --update --add root sasl 710 /var/spool/postfix/var/run/saslauthd || true
59 # build local.sh if it does not exist
60 if [ ! -f $CONFIGFILE ]; then
61 cat > $CONFIGFILE <<EOF
64 # AlternC - Web Hosting System - Configuration
65 # This file will be modified on package configuration
66 # (e.g. upgrade or dpkg-reconfigure alternc)
68 # Hosting service name
71 # Primary hostname for this box (will be used to access the management panel)
78 # (most of the time, should be equal to PUBLIC_IP, unless you are behind
79 # firewall doing address translation)
82 # Monitoring IP or network (will be allowed to access Apache status)
85 # Primary DNS hostname
88 # Secondary DNS hostname
91 # Mail server hostname
94 # Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf
96 # quels clients mysql sont permis (%, localhost, etc)
99 # Folder holding data (used for quota management)
102 # the type of backup created by the sql backup script
103 # valid options are "rotate" (newsyslog-style) or "date" (suffix is the date)
106 # overwrite existing files when backing up
107 SQLBACKUP_OVERWRITE=""
110 chown root:www-data $CONFIGFILE
111 chmod 640 $CONFIGFILE
115 # 1. use cp to keep permissions
116 # 2. add missing variable to local.sh
117 # 3. use sed to set variables with current values
118 echo "Updating $CONFIGFILE"
119 cp -a -f $CONFIGFILE $CONFIGFILE.tmp
120 # SED_SCRIPT will be modified by update_var
122 update_var alternc-slave/hostingname HOSTING
123 update_var alternc-slave/desktopname FQDN
124 update_var alternc-slave/public_ip PUBLIC_IP
125 update_var alternc-slave/internal_ip INTERNAL_IP
126 update_var alternc-slave/monitor_ip MONITOR_IP
127 update_var alternc-slave/ns1 NS1_HOSTNAME
128 update_var alternc-slave/ns2 NS2_HOSTNAME
129 update_var alternc-slave/default_mx DEFAULT_MX
130 update_var alternc-slave/mysql/client MYSQL_CLIENT
131 update_var alternc-slave/sql/backup_type SQLBACKUP_TYPE
132 update_var alternc-slave/sql/backup_overwrite SQLBACKUP_OVERWRITE
133 update_var alternc-slave/alternc_location ALTERNC_LOC
134 sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
135 mv -f $CONFIGFILE.tmp $CONFIGFILE
137 if [ -e $CONFIGFILE ]; then
138 # source local.sh variables
142 if grep -q alternc-mergelog /etc/passwd ; then
143 echo "Reusing the alternc-mergelog account as a generic alternc account"
144 # the uid is ugly. we should request allocation from
145 # base-passwd instead
146 usermod --uid 342 --shell /bin/rbash --login alternc alternc-mergelog
147 # this is a separate step otherwise usermod will look for
148 # files to chown in /var/alternc, which takes a long time
149 usermod --home $ALTERNC_LOC alternc
151 if [ -d /var/run/alternc-mergelog/.ssh ]; then
152 echo "Cleaning up old alternc-mergelog home"
153 mv /var/run/alternc-mergelog/.ssh $ALTERNC_LOC/.ssh && rmdir /var/run/alternc-mergelog
155 if ! grep -q alternc /etc/passwd ; then
156 echo "Creating alternc account"
157 # this uid is ugly. we should request allocation from
158 # base-password instead
159 adduser --quiet --system --uid 342 --home $ALTERNC_LOC --shell /bin/rbash --ingroup adm alternc
162 echo "config phpmyadmin"
163 include_str='include("/etc/alternc/phpmyadmin.inc.php")'
164 pma_config=/etc/phpmyadmin/config.inc.php
165 if ! grep -e "$include_str" $pma_config > /dev/null 2>&1; then
166 echo "<?php $include_str ?>" >> $pma_config
169 if ! grep -q '## ALTERNC START' /etc/sudoers; then
170 # XXX: this is not proper locking
171 if [ -e /etc/sudoers.tmp ]; then
172 echo "sudoers file being edited, aborting"
175 cp /etc/sudoers /etc/sudoers.tmp
176 cat >> /etc/sudoers.tmp <<EOF
178 ## do not change anything between those lines
179 alternc ALL=NOPASSWD: /usr/sbin/invoke-rc.d apache reload
180 alternc ALL=NOPASSWD: /usr/sbin/invoke-rc.d apache2 reload
181 alternc ALL=NOPASSWD: /usr/sbin/rndc reload *
182 alternc ALL=NOPASSWD: /usr/sbin/rndc reload
185 mv /etc/sudoers.tmp /etc/sudoers
189 # important: postinst gele sans ca
192 echo "running alternc.install"
196 abort-upgrade|abort-remove|abort-deconfigure)
201 echo "postinst called with unknown argument \`$1'" >&2
207 # dh_installdeb will replace this with shell code automatically
208 # generated by other debhelper scripts.