Inhaltsverzeichnis

Passwort/IP-Änder-Skripte

/.config/root_passwd
/.config/server_ip

IP ändern

Datein, die die IP Adresse enthalten

/etc/hosts
/etc/dhcpd.conf (da gehört einiges berechnet)
/etc/apache2/listen.conf
/etc/sysconfig/network/ifcfg-eth0

Skript

#!/bin/bash
array=( "/etc/hosts" "/etc/apache2/listen.conf" "/etc/sysconfig/network/ifcfg-eth0" )
ip=`cat /.config/server_ip`
if [ 0 -eq `echo ${#ip}` ]; then
  echo "Error: IP cannot be empty"
  exit 1
fi
echo "Starting s4e script to change the IP to $ip"
for ((i=0; i<${#array[*]}; i++)) do
  file=${array[$i]};
  echo -n "editing file $file"
  sed 's/192.168.1.1/'$ip'/g' $file > $file.s4enew
  mv $file $file.s4esave
  mv $file.s4enew $file
  echo " ...done"
done
echo -n "Changing IP in this script"
file="$(basename "$0")"
sed 's/192.168.1.1/'$ip'/g' $file > $file.s4enew
mv $file $file.s4esave
mv $file.s4enew $file
echo " ...done"
exit 0

Passwort

Dateien, die das Passwort enthalten

/etc/openldap/slapd.conf (verschlüsselt)
/var/lib/s4e/conf/bind.conf
/var/lib/s4e/ldapbrowser/s4e2009.cfg
/srv/www/htdocs/configuration.php
/srv/www/htdocs/moodle/config.php
/srv/www/htdocs/gallery/albums/.users/userdb.dat (komisch verschlüsselt, ist besser wenn wir da gar keines setzen)

Befehle, die ausgeführt werden müssen

mysqladmin -u root password open23
mysqladmin -u s4e password open23
/var/lib/s4e/bin/ldap_passwd profil open23
/var/lib/s4e/bin/ldap_passwd sambakeeper open23
smbpasswd -w open23
smbpasswd -a sambakeeper -w open23
echo "open23" | passwd --stdin root

Skript

#!/bin/bash
array=( "/var/lib/s4e/conf/bind.conf" "/var/lib/s4e/ldapbrowser/s4e2009.cfg" "/srv/www/htdocs/configuration.php" "/srv/www/htdocs/moodle/config.php" )
password=`cat /.config/root_passwd`
origpassword="open23"
if [ 0 -eq `echo ${#password}` ]; then
  echo "Error: password cannot be empty"
  exit 1
fi
echo "Starting s4e script to change the root password"
for ((i=0; i<${#array[*]}; i++)) do
  file=${array[$i]};
  echo -n "editing file $file"
  sed 's/'$origpassword'/'$password'/g' $file > $file.s4enew
  mv $file $file.s4esave
  mv $file.s4enew $file
  echo " ...done"
done
# editing /etc/openldap/slapd.conf
file="/etc/openldap/slapd.conf"
echo -n "editing file $file"
passwordhash=`slappasswd -ns $password`
sed 's#.*rootpw.*#rootpw          '$passwordhash'#g' $file > $file.s4enew
mv $file $file.s4esave
mv $file.s4enew $file
echo " ...done"
echo -n "editing mysql password..."
mysqladmin -u root -p$origpassword password $password
echo " ...done"
echo "editing ldap passwords..."
/var/lib/s4e/bin/ldap_passwd profil $password
/var/lib/s4e/bin/ldap_passwd sambakeeper $password
echo "editing samba passwords..."
smbpasswd -w $password
smbpasswd -a sambakeeper -w $password
echo -n "editing system root password"
echo $password | passwd --stdin root
echo " ...done"
echo -n "Changing root password in this script"
file="$(basename "$0")"
sed 's/'$origpassword'/'$password'/g' $file > $file.s4enew
mv $file $file.s4esave
mv $file.s4enew $file
echo " ...done"
echo "s4e script for changing the root password successfully finished"
exit 0