Post-installation Scripts:FreeBSD 8
From WebSoftSolus Documentation
#!/bin/sh ########################################################################### # Remplace "YOUR_EMAIL_ADDRESS" by your email address name # ########################################################################### Email='YOUR_EMAIL_ADDRESS' DNS=8.8.8.8 IP=`ifconfig | grep broadcast | awk '{print $2}'` HOST=`host $IP $DNS| tail -1 | awk '{print $5}' | awk -F'.' '{print $1"\."$2"\."$3}'` TestIP=`echo $IP | egrep "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"` TestHost=`echo $HOST | egrep '(ovh|kimsufi)'` cat > /root/.ssh/authorized_keys2 << EOF from="213.186.50.100" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAt3XaIhEoRK5sEKm6wtYyazLOx3w+Yv9+bpfEvLftHr2hxZ2TY2A655iwMbgvhHqsMuGEjK9yGkZIQbUgB6HvOgOWOwJSX6Gc9Ac7GuH11xSU8tHDuTQot6fVtgcm2Y/VUFi65Knz9rLHz7h/Zy29ek+UYav5T7juhBIuk57cDxs= from="::ffff:213.186.50.100" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAt3XaIhEoRK5sEKm6wtYyazLOx3w+Yv9+bpfEvLftHr2hxZ2TY2A655iwMbgvhHqsMuGEjK9yGkZIQbUgB6HvOgOWOwJSX6Gc9Ac7GuH11xSU8tHDuTQot6fVtgcm2Y/VUFi65Knz9rLHz7h/Zy29ek+UYav5T7juhBIuk57cDxs= EOF apply(){ hostname $HOST cat > /etc/resolv.conf << EOF nameserver 213.186.33.99 nameserver 8.8.8.8 nameserver 8.8.4.4 EOF rm -f /etc/resolv.conf.save sed -i -e s/"ovh.*"//g /etc/group sed -i -e s/"hostname.*"/"hostname : $HOST"/g /etc/issue sed -i -e s/"hostname.*"/"hostname : $HOST"/g /etc/motd sed -i -e s/"ovh.*"//g /etc/master.passwd sed -i -e s/"ovh.*"//g /etc/passwd sed -i -e s/"hostname=.*"/"hostname=\"$HOST\""/g /etc/rc.conf sed -i -e s/" root@.*"//g /etc/ssh/ssh_host_dsa_key.pub sed -i -e s/" root@.*"//g /etc/ssh/ssh_host_key.pub sed -i -e s/" root@.*"//g /etc/ssh/ssh_host_rsa_key.pub rm -f /etc/ssh/ssh_host_dsa_key.pub-e rm -f /etc/ssh/ssh_host_key.pub-e rm -f /etc/ssh/ssh_host_rsa_key.pub-e rm -f /etc/passwd-e rm -f /etc/motd-e rm -f /etc/group-e rm -f /etc/issue-e rm -f /etc/master.passwd-e rm -f /etc/rc.conf-e rm -f /usr/local/rtm/scripts/daily/release.sh rm -f /var/run/dmesg.boot cat /dev/null > /var/log/lastlog cat /dev/null > /var/log/auth.log cat /dev/null > /var/log/userlog rm -f /root/.history history -c } verify(){ grepovh=`egrep -R '(ovh|kimsufi)' /etc/ | grep -v 'Binary file'` if [ -n "$grepovh" ] then pass=`head -c 200 /dev/urandom | tr -cd '0-9a-zA-Z' | head -c 8` echo "$pass" > /root/.p echo " Erreur lors de l'installation du serveur $IP Hostname : $HOST Mot de pass : $pass " |mail -s "ERREUR INSTALLATION" $Email pw usermod root -h stdin < /root/.p rm -f /root/.p exit 255 else exit 0 fi } if [ -n $TestIP ] && [ -z $TestHost ] then apply verify else pass=`head -c 200 /dev/urandom | tr -cd '0-9a-zA-Z' | head -c 8` echo "$pass" > /root/.p echo " Erreur lors de l'installation du serveur $IP Hostname : $HOST Mot de pass : $pass " |mail -s "ERREUR INSTALLATION" $Email pw usermod root -h stdin < /root/.p rm -f /root/.p exit 254 fi