3 # Source debconf library.
4 . /usr/share/debconf/confmodule
6 CONFIGFILE="/etc/alternc/local.sh"
15 grep -Eq "^ *$var=" $CONFIGFILE || echo "$var=" >> $CONFIGFILE
16 SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\"
19 # summary of how this script can be called:
20 # * <postinst> `configure' <most-recently-configured-version>
21 # * <old-postinst> `abort-upgrade' <new version>
22 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
24 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
25 # <failed-install-package> <version> `removing'
26 # <conflicting-package> <version>
27 # for details, see http://www.debian.org/doc/debian-policy/ or
28 # the debian-policy package
30 # quoting from the policy:
31 # Any necessary prompting should almost always be confined to the
32 # post-installation script, and should be protected with a conditional
33 # so that unnecessary prompting doesn't happen if a package's
34 # installation fails and the `postinst' is called with `abort-upgrade',
35 # `abort-remove' or `abort-deconfigure'.
40 # ajoute l'user postfix au groupe sasl
41 adduser --quiet postfix sasl
43 # corriger les permissions du chroot
44 mkdir -p /var/spool/postfix/var/run/saslauthd || true
45 if ! dpkg-statoverride --list /var/spool/postfix/var/run/saslauthd >/dev/null ; then
46 dpkg-statoverride --quiet --update --add root sasl 710 /var/spool/postfix/var/run/saslauthd || true
49 db_get "alternc/alternc_mail"
51 if ! getent group vmail; then
52 addgroup --gid 1998 vmail
54 if ! getent passwd vmail; then
55 useradd -g vmail -u 1998 vmail -d "$VMAIL_HOME" -m
57 test -d "$VMAIL_HOME" || mkdir -p "$VMAIL_HOME"
58 chown vmail:vmail "$VMAIL_HOME"
59 chown vmail:vmail "$VMAIL_HOME"/* 2>/dev/null || true # It may be empty
60 chmod 770 "$VMAIL_HOME"
61 chmod 770 "$VMAIL_HOME"/* 2>/dev/null || true # It may be empty
63 # build local.sh if it does not exist
64 if [ ! -f $CONFIGFILE ]; then
65 cat > $CONFIGFILE <<EOF
68 # AlternC - Web Hosting System - Configuration
69 # This file will be modified on package configuration
70 # (e.g. upgrade or dpkg-reconfigure alternc)
72 # Hosting service name
75 # Primary hostname for this box (will be used to access the management panel)
82 # (most of the time, should be equal to PUBLIC_IP, unless you are behind
83 # firewall doing address translation)
86 # Monitoring IP or network (will be allowed to access Apache status)
89 # Primary DNS hostname
92 # Secondary DNS hostname
95 # Mail server hostname
98 # Secondary mail server hostname
99 DEFAULT_SECONDARY_MX=""
101 # Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf
103 # quels clients mysql sont permis (%, localhost, etc)
106 # the type of backup created by the sql backup script
107 # valid options are "rotate" (newsyslog-style) or "date" (suffix is the date)
110 # overwrite existing files when backing up
111 SQLBACKUP_OVERWRITE=""
113 # known slave servers, empty for none, localhost is special (no ssh)
116 # File to look at for forced launch of update_domain (use incron)
117 INOTIFY_UPDATE_DOMAIN="/run/alternc/inotify_update_domain.lock"
119 # File to look at for forced launch of do_actions (use incron)
120 INOTIFY_DO_ACTION="/run/alternc/inotify_do_action.lock"
127 # Custom directory for archived logs. ALTERNC_LOGS is used by default to view logs files on the panel.
128 # But you may merge your logs in other directory. In order to view them,
129 # Uncomment and complete the following variable to use it instead of ALTERNC_LOGS.
130 #ALTERNC_LOGS_ARCHIVE=""
132 # Shall we enable QUOTA over NFS ?
133 # the default is NO, since this dramatically block /usr/lib/alternc/quota* functions
134 # called from the panel. To enable quota-over-NFS, put yes here
139 chown root:alterncpanel $CONFIGFILE
140 chmod 640 $CONFIGFILE
144 # 1. use cp to keep permissions
145 # 2. add missing variable to local.sh
146 # 3. use sed to set variables with current values
147 echo "Updating $CONFIGFILE"
148 cp -a -f $CONFIGFILE $CONFIGFILE.tmp
149 # SED_SCRIPT will be modified by update_var
151 update_var alternc/hostingname HOSTING
152 update_var alternc/desktopname FQDN
153 update_var alternc/public_ip PUBLIC_IP
154 update_var alternc/internal_ip INTERNAL_IP
155 update_var alternc/monitor_ip MONITOR_IP
156 update_var alternc/ns1 NS1_HOSTNAME
157 update_var alternc/ns2 NS2_HOSTNAME
158 update_var alternc/default_mx DEFAULT_MX
159 update_var alternc/default_mx2 DEFAULT_SECONDARY_MX
160 update_var alternc/mysql/client MYSQL_CLIENT
161 update_var alternc/sql/backup_type SQLBACKUP_TYPE
162 update_var alternc/sql/backup_overwrite SQLBACKUP_OVERWRITE
163 update_var alternc/slaves ALTERNC_SLAVES
164 update_var alternc/alternc_html ALTERNC_HTML
165 update_var alternc/alternc_mail ALTERNC_MAIL
166 update_var alternc/alternc_logs ALTERNC_LOGS
167 sed -e "$SED_SCRIPT" < $CONFIGFILE > $CONFIGFILE.tmp
168 mv -f $CONFIGFILE.tmp $CONFIGFILE
170 # Add NFS_QUOTA instructions if they are not in the config file:
171 grep -Eq "^ *NFS_QUOTA=" $CONFIGFILE || echo "
172 # Shall we enable QUOTA over NFS ?
173 # the default is NO, since this dramatically block /usr/lib/alternc/quota* functions
174 # called from the panel. To enable quota-over-NFS, put yes here
175 NFS_QUOTA=no" >> $CONFIGFILE
177 # Erase all apacheconf file
178 # They will be regenerated without the bug by upgrade_check.sh below.
179 if dpkg --compare-versions "$2" le "0.9.3.9-globenet14"; then
180 rm -f /var/alternc/apacheconf/*/* # Old AlternC version
183 # we store the version where we upgrade from, for AlternC < 3.1.1 || < 3.2.1
184 # where we switch to database-based version control
185 echo "$2" >/var/lib/alternc/backups/lastversion
188 db_get "alternc/mysql/host"
190 if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then
191 # compatibility shims with my.cnf
193 db_get "alternc/mysql/db"
195 db_get "alternc/mysql/user"
197 db_get "alternc/mysql/password"
199 db_get "alternc/mysql/alternc_mail_user"
200 alternc_mail_user="$RET"
201 db_get "alternc/mysql/alternc_mail_password"
202 alternc_mail_password="$RET"
204 # we source (instead of forking) mysql.sh so that it gets the local environment above
205 . /usr/share/alternc/install/mysql.sh
208 if [ -e $CONFIGFILE ]; then
209 # source local.sh variables
213 # multi-server configuration: we create an alternc account with
214 # authorized keys. since this is the master, we do not give him a
215 # valid shell, but we still need the user for proper perms
216 ALTERNC_USER_HOME="$ALTERNC_HTML"
217 if [ ! -z "$ALTERNC_SLAVES" ] && [ "$ALTERNC_SLAVES" != "localhost" ] ; then
218 if ! grep -q alternc /etc/passwd ; then
219 echo "Creating alternc account"
220 adduser --quiet --system --uid 342 --home $ALTERNC_HTML --shell /bin/false --ingroup adm alternc
222 chown alternc "$ALTERNC_USER_HOME"
223 if [ -r ~root/.ssh/id_dsa.pub ]; then
224 key=`cat ~root/.ssh/id_dsa.pub`
225 if ! grep -q "$key" $ALTERNC_USER_HOME/.ssh/authorized_keys ; then
226 echo "Authorizing root ssh key to access the common alternc account"
227 mkdir -p $ALTERNC_USER_HOME/.ssh
228 echo "$key" >> $ALTERNC_USER_HOME/.ssh/authorized_keys
229 chown -R alternc:adm $ALTERNC_USER_HOME/.ssh
230 chmod -R og-rwx $ALTERNC_USER_HOME/.ssh
233 echo "No SSH key in "~root/.ssh/id_dsa.pub
234 echo "create one and reconfigure alternc to propagate SSH keys"
237 echo "AlternC slaves not configured ($ALTERNC_SLAVES)"
240 # /var/alternc/dns/d/www.example.com
241 FQDN_LETTER="`echo $FQDN | sed -e 's/.*\.\([^\.]\)[^\.]*\.[^\.]*$/\1/'`"
242 if [ "$FQDN_LETTER" = "$FQDN" ]
247 #clean old access to the management panel
248 # We don't use this anymore : (FIXME : shall we remove /var/alternc/dns while upgrading ?)
249 #find /var/alternc/dns/ -type l -lname /var/alternc/bureau -exec rm {} \;
252 touch /var/lib/alternc/bind/automatic.conf /var/lib/alternc/bind/slaveip.conf
253 chown root:bind /var/lib/alternc/bind/automatic.conf /var/lib/alternc/bind/slaveip.conf
254 chmod 640 /var/lib/alternc/bind/automatic.conf /var/lib/alternc/bind/slaveip.conf
255 mkdir -p /run/alternc && chown alterncpanel:alterncpanel /run/alternc
256 touch /run/alternc/refresh_slave
257 /usr/lib/alternc/slave_dns
258 # Apache will not start without this file
259 touch /var/lib/alternc/apache-vhost/vhosts_all.conf
261 # important: postinst freezes without that:
264 echo -e "\033[31m**********************************************"
266 echo "* ALTERNC ACTION REQUESTED *"
268 echo "* Please run alternc.install to fully deploy *"
270 echo "**********************************************"
274 abort-upgrade|abort-remove|abort-deconfigure)
279 echo "postinst called with unknown argument \`$1'" >&2
285 # dh_installdeb will replace this with shell code automatically
286 # generated by other debhelper scripts.
290 # important: postrm freezes withtout that: