#!/bin/sh # rc.postinstall This file is executed by rc.local when the system is first # initialized after install. It must be executed only once. # # Version: 2.0 Sunday , 03/12/2006 # # Author: Jean-Philippe Guillemin, #### Set the splash screen to verbose mode #### [[ -x /sbin/splash && -e /proc/splash ]] && echo "verbose" > /proc/splash & # perform post-install config # in case everything is not mounted yet /sbin/mount -a clear # Detect soundcard and configure Alsa if [ -x /etc/rc.d/rc.alsa ]; then if [ -x /usr/sbin/alsaconf ]; then /usr/sbin/alsaconf 2>/dev/null else touch /etc/modprobe.d/sound fi fi clear # Configure system language if [ -x /usr/sbin/localeconfig ]; then /usr/sbin/localeconfig fi clear # Configure network #if [ -x /usr/sbin/networkconfig ]; then # /usr/sbin/networkconfig #fi # Choose a root password # Password dialog passbox(){ pw="$(dialog --stdout --insecure --fixed-font --no-cancel --smooth --passwordbox "${1}" 12 80)" echo -n "$pw" } # Password checking changepw(){ maxcount=20 minlength=5 count=1 ; pw='_' while [ "${pw}" != "${password}" ]; do password="" ; pw='_' if [ $count -gt $maxcount ]; then echo -n "" break fi message="Enter a password for user ${1} (#${count}) :" [ $count -ge 2 ] && message="Passwords don't match, enter password for user ${1} (#${count}) :" while [ "$(echo -n "${pw}" | wc --chars)" -lt ${minlength} ]; do pw="$(passbox "${message}")" message="Password is too short (${minlength} chars minimum), please try another one :" done password="$pw" ; pw='_' message="Enter password again for user ${1} (#${count}) :" pw="$(passbox "${message}")" count=$((count+1)) done echo -n $password } while [ "$(cat /etc/shadow | fgrep 'root:' | cut -f 2 -d :)" = "" ]; do # There is no root password pass="$(changepw root)" echo "root:${pass}" | chpasswd done clear # Add users if [ -x /usr/sbin/userconfig ]; then /usr/sbin/userconfig fi clear # Detect videocard and configure Xorg if [ -x /usr/sbin/videoconfig -a -e /usr/bin/X ]; then /usr/sbin/videoconfig silent fi # Set numlock on startup, ... or not :) answer="$(dialog --stdout --title "Numlockx" --menu \ "Should numlock be activated at login ?\n\n" \ 8 80 3 \ "Yes" "" \ "No" "")" if [ "$answer" = "Yes" ] ; then [ -e /etc/rc.d/rc.numlock ] && chmod 755 /etc/rc.d/rc.numlock else [ -e /etc/rc.d/rc.numlock ] && chmod 644 /etc/rc.d/rc.numlock fi # Let's try to optimize the way we use swap on a desktop let memsize="$(sed -n 's/^MemTotal:[ \t]*\([^ \t]*\)[ \t]*.B$/\1/p' /proc/meminfo)" if [ $memsize -gt 512000 ] ; then swappiness=0 elif [ $memsize -gt 256000 ] ; then swappiness=20 elif [ $memsize -gt 128000 ] ; then swappiness=40 fi echo ${swappiness} > /proc/sys/vm/swappiness echo "vm.swappiness=${swappiness}" >> /etc/sysctl.conf # Update the X font indexes: if [ -x /usr/bin/fc-cache ]; then /usr/bin/fc-cache 2>&1 1>/dev/null fi # Update any existing icon cache files: if find /usr/share/icons 2> /dev/null | grep -q icon-theme.cache ; then for theme_dir in /usr/share/icons/* ; do if [ -r ${theme_dir}/icon-theme.cache ]; then /usr/bin/gtk-update-icon-cache -t -f ${theme_dir} 1> /dev/null 2> /dev/null fi done if [ -r /usr/share/icons/icon-theme.cache ]; then /usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1> /dev/null 2> /dev/null fi fi # End of postinstall stage trap 'exit' INT clear dialog --infobox "Going to graphical login now (hit Ctrl-C within 5 seconds to abort)..." 4 45 sleep 10 init 4