{{tag> horde}}
====== Postinstall-Script zu Horde 5 ======
Das Script geht von einer frisch installierten Horde 5.1.4 in ''**/var/www/horde**'' aus. Ggf. müssen noch alte, horde3-Konfigurationen bei Apache gelöscht werden.\\
Das Script legt von der Horde-Konfiguration eine Backup-Datei an, die man ggf. zurückspielen kann: **''/etc/horde5/horde/conf.bak.php''**.
Benutzung auf eigenes Risiko!
#! /bin/bash
#
# Version 0.2 - Mai 2014
# Script verschiebt alle Conf-Dateien von Horde nach /etc/horde5
# und richtet die Konfiguration von Horde5 fuer linuxmuster-net 6.0 ein.
# Getestet für Horde 5 Version 5.1.4
#
# Pfade "wwwdir" und "etcdir" koennen angepasst werden.
wwwdir="/var/www/horde"
etcdir="/etc/horde5"
###########################################################################
if [ ! -d "$wwwdir" ]; then
echo "WARNING: Verzeichnis $wwwdir existiert nicht, Script wird beendet."
exit 1
fi
if [ -d "$etcdir" ]; then
echo "WARNING: Verzeichnis $etcdir existiert schon, Script wird beendet."
echo "Ein mehrfach-Ausfuehren des Scriptes macht die Installation unbrauchbar."
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo "Script muss als root ausgefuehrt werden!" 1>&2
exit 1
fi
###########################################################################
echo "Lege $etcdir an ..."
mkdir "$etcdir"
chown root:www-data -R "$etcdir"
chmod 755 "$etcdir"
###########################################################################
echo "Setze Rechte ..."
chown root:www-data "$wwwdir/static"
chmod 775 "$wwwdir/static"
###########################################################################
echo "Starte Conf-Verzeichnisse zu verschieben und verlinken ..."
verzliste="/horde /gollem /imp /ingo /kronolith /mnemo /nag /turba /trean"
for verz in $verzliste ; do
if [ $verz == "/horde" ] ; then
wverz="$wwwdir/config"
else
wverz="$wwwdir$verz/config"
fi
everz="$etcdir$verz"
echo " Verschieben von $wverz --> $everz"
mv $wverz $everz
ln -s $everz $wverz
chown root:www-data -R $everz
chmod 755 $everz
done
###########################################################################
echo "Richte Apache ein ..."
text="\
Alias /horde $wwwdir\n\
\n\
Options Indexes FollowSymLinks MultiViews\n\
AllowOverride All\n\
AcceptPathInfo On\n\
Order allow,deny\n\
allow from all\n\
\n"
echo -e "$text" > "$etcdir/apache.conf"
ln -s "$etcdir/apache.conf" "/etc/apache2/conf.d/horde5.conf"
###########################################################################
echo "Richte php ein ..."
pecl install lzf
echo "extension=lzf.so" > /etc/php5/apache2/conf.d/lzf.ini
pear install horde/horde_lz4
echo "extension=horde_lz4.so" > /etc/php5/apache2/conf.d/lz4.ini
echo "extension=msgpack.so" > /etc/php5/apache2/conf.d/msgpack.ini
sed -i 's|session\.gc_divisor.*|session\.gc_divisor = 10000|' /etc/php5/apache2/php.ini
service apache2 restart
###########################################################################
configfile="$etcdir/horde/conf.php"
cp $configfile "$etcdir/horde/conf.bak.php"
base=`awk '/BASE/ { print $2 } ' /etc/ldap/ldap.conf`
echo "Verwende Base-DN: $base"
###########################################################################
echo "Setze LDAP-Authentifizierung ..."
echo "Installiere horde_ldap ... bitte warten ..."
pear install -a horde/horde_ldap
sed -i "/\$conf\W\Wldap\W.*/ d" $configfile
text="\
\$conf['ldap']['hostspec'] = 'localhost';\n\
\$conf['ldap']['tls'] = false;\n\
\$conf['ldap']['version'] = 3;\n\
\$conf['ldap']['bindas'] = 'anon';\n\
\$conf['ldap']['useldap'] = true;"
sed -i "/\/\* CONFIG END\./ i $text" $configfile
z1=`grep "'count_bad_logins'" $configfile`
z2=`grep "'login_block'" $configfile`
z3=`grep "'login_block_count'" $configfile`
z4=`grep "'login_block_time'" $configfile`
sed -i "/\$conf\W\Wauth\W\W\W\Wparams\W.*/ d" $configfile
sed -i "/\$conf\W\Wauth\W\W\W\Wdriver\W.*/ d" $configfile
text="\
\$conf['auth']['params']['basedn'] = '$base';\n\
\$conf['auth']['params']['scope'] = 'sub';\n\
\$conf['auth']['params']['ad'] = false;\n\
\$conf['auth']['params']['uid'] = 'uid';\n\
\$conf['auth']['params']['encryption'] = 'ssha';\n\
\$conf['auth']['params']['newuser_objectclass'] = array('shadowAccount', 'inetOrgPerson');\n\
\$conf['auth']['params']['filter'] = '(objectclass=posixAccount)';\n\
\$conf['auth']['params']['password_expiration'] = 'no';\n\
\$conf['auth']['params']['driverconfig'] = 'horde';\n\
\$conf['auth']['driver'] = 'ldap';"
sed -i "/\/\* CONFIG END\./ i $text" $configfile
sed -i "/\/\* CONFIG END\./ i $z1" $configfile
sed -i "/\/\* CONFIG END\./ i $z2" $configfile
sed -i "/\/\* CONFIG END\./ i $z3" $configfile
sed -i "/\/\* CONFIG END\./ i $z4" $configfile
echo "Richte LDAP-Groups ein ..."
sed -i "/\$conf\W\Wgroup\W.*/ d" $configfile
text="\
\$conf['group']['params']['basedn'] = '$base';\n\
\$conf['group']['params']['scope'] = 'sub';\n\
\$conf['group']['params']['gid'] = 'cn';\n\
\$conf['group']['params']['memberuid'] = 'memberUID';\n\
\$conf['group']['params']['attrisdn'] = false;\n\
\$conf['group']['params']['newgroup_objectclass'] = array('posixGroup', 'hordeGroup');\n\
\$conf['group']['params']['search']['objectclass'] = array('posixGroup');\n\
\$conf['group']['params']['search']['filter_type'] = 'objectclass';\n\
\$conf['group']['params']['driverconfig'] = 'horde';\n\
\$conf['group']['driver'] = 'Ldap';"
sed -i "/\/\* CONFIG END\./ i $text" $configfile
echo " "$etcdir/imp/backends.local.php"
echo -e "\$servers['imap']['hordeauth'] = true;" >> "$etcdir/imp/backends.local.php"
###########################################################################
echo "Richte Dateimanager Gollem ein ..."
text="\
false,'name' => 'Server','driver' => 'smb','hordeauth' => true,\n\
'params' => array('hostspec' => 'localhost', 'port' => 139, 'share' => 'homes', 'smbclient' => '/usr/bin/smbclient','ipaddress' => '127.0.0.1'),\n\
'loginparams' => array(),\n\
'attributes' => array('type','name','edit','download','modified','size')\n\
);"
echo -e "$text" > "$etcdir/gollem/backends.d/samba.php"
rm "$etcdir/gollem/backends.d/10-webmail.php"
###########################################################################
echo "Richte Log-Datei ein ..."
mkdir /var/log/horde
chown www-data:www-data /var/log/horde
sed -i "s/\$conf.*.log.*.type.*/\$conf\[\'log\'\]\[\'type\'\] = \'file\';/" $configfile
sed -i "s/\$conf.*.log.*.name.*/\$conf\[\'log\'\]\[\'name\'\] = \'\/var\/log\/horde\/horde5\.log\';/" $configfile
###########################################################################
echo "Richte neues sicheres Kennwort für mysql ein ..."
kennwort=`pwgen -s 20 1`
sed -i "s/\$conf.*.sql.*.password\W.*/\$conf\[\'sql\'\]\[\'password\'\] = '$kennwort';/" $configfile
mysql -e "SET PASSWORD FOR h5admin@localhost = PASSWORD ('$kennwort');"
###########################################################################
exit 0