#!/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 1>/dev/null 2>/dev/null clear # Checks for configuration files to update. dotnewlist="$(find /etc -name "*.new")" if [ "$dotnewlist" ] ; then for file in $dotnewlist ; do origfile="$(echo $file|sed -e 's/.new//')" cp -f $file $origfile rm -f $file done fi # Detect soundcard and configure Alsa, if needed if ! ls /dev/snd/* 2>/dev/null 1>&2 ; then if [ -x /usr/sbin/alsaconf ]; then /usr/sbin/alsaconf 2>/dev/null fi fi touch /etc/modprobe.d/sound.conf clear # Configure system language if [ -x /usr/sbin/localeconfig ]; then /usr/sbin/localeconfig fi clear # 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 password="zenwalk" 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 -e "${pass}\n${pass}\n" | passwd root 1>/dev/null 2>&1 done clear # Add users if [ -x /usr/sbin/userconfig ]; then /usr/sbin/userconfig fi clear # Configure Xorg if [ -x /usr/sbin/videoconfig -a -e /usr/bin/X ]; then /usr/sbin/videoconfig silent else sed -i "s/^id:.*:initdefault:$/id:3:initdefault:/" /etc/inittab fi # Set numlock on startup, ... or not :) # answer="$(dialog --stdout --title "Numlockx" --menu \ # "Should numlock be activated at login ?\n\n" \ # 9 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=10 elif [ $memsize -gt 256000 ] ; then swappiness=40 elif [ $memsize -gt 128000 ] ; then swappiness=60 fi echo ${swappiness} > /proc/sys/vm/swappiness 2>/dev/null echo "vm.swappiness=${swappiness}" >> /etc/sysctl.conf 2>/dev/null # Font caching for fontdir in cyrillic OTF TTF 100dpi 75dpi misc Type1 Speedo util encodings; do [ -d /usr/share/fonts/${fontdir} ] && \ ( [ -x /usr/bin/mkfontscale ] && ( chroot . /usr/bin/mkfontscale /usr/share/fonts/${fontdir} > /dev/null 2>&1 ) [ -x /usr/bin/mkfontdir ] && ( chroot . /usr/bin/mkfontdir /usr/share/fonts/${fontdir} > /dev/null 2>&1 ) ) done du /usr/share/fonts > /etc/fonts.list 2>/dev/null # Update the X font indexes: if [ -d /var/cache/fontconfig ]; then rm -rf /var/cache/fontconfig 2>/dev/null mkdir -p /var/cache/fontconfig 2>/dev/null fi [ -x /usr/bin/fc-cache ] && /usr/bin/fc-cache -rf > /dev/null 2>&1 # 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 # Update the pango.modules file: if [ -x /usr/bin/pango-querymodules ]; then /usr/bin/pango-querymodules 2>/dev/null 1>&2 fi if [ -x /usr/bin/gdk-pixbuf-query-loaders ]; then /usr/bin/gdk-pixbuf-query-loaders --update-cache >/dev/null 2>&1 fi # Let's configure basic networking in case no wicd if [ ! -e /etc/rc.d/rc.wicd ]; then /sbin/netconfig fi # End of postinstall stage if [ -x /usr/sbin/videoconfig -a -e /usr/bin/X ]; then trap 'exit' INT clear dialog --infobox "Going to graphical login now (hit Ctrl-C within 5 seconds to abort)..." 4 45 sleep 7 init 4 fi