Rev 234 | Rev 267 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/bin/bash
#
################################################################
#
# Used to build a MINI LiveCD
# - save diskspace by moving folders to /mini
# disable this with "-nomove" option !
# - direct login to icewm as LOCALUSER
# or as root (option -rootlogin)
# - configure icewm
# - run "minil-livecd -restore" to restore files from /mini again
#
# Urs Beyerle
#
################################################################
# source livecd.conf
. livecd.conf
###############################################################
### -----------------------------------------------------------
### List of folders (or files) to move:
### -----------------------------------------------------------
FOLDERS="/usr/src \
/usr/share/doc \
/usr/share/info \
/usr/share/anaconda \
/usr/share/gdm \
/var/cache/yum \
/etc/cups/ppds.dat \
/etc/gconf/gconf.xml.defaults \
/usr/X11R6/lib/X11/doc \
/usr/share/vim/vim70/doc \
/usr/share/vim/vim70/lang \
/usr/share/emacs/21.4/etc/DOC-21.4.1 \
/usr/share/pixmaps/nautilus \
/usr/share/cups \
/usr/share/icons"
# /var/lib/rpm \
### -----------------------------------------------------------
### locales we don't need, we keep: en, de, fr
### -----------------------------------------------------------
### /usr/share/locale
### -----------------------------------------------------------
# do we restore?
if [ -d /mini/usr/share/locale/zh_TW.Big5 ]; then
MOVE_LOCALE=$( find /mini/usr/share/locale/* -maxdepth 0 -type d \
| while read f; do echo ${f##/mini}; done )
else
MOVE_LOCALE=$( find /usr/share/locale/* -maxdepth 0 -type d \
| grep -v en | grep -v de | grep -v fr )
fi
# add to FOLDERS
FOLDERS="$FOLDERS $MOVE_LOCALE"
### /mini/usr/share/backgrounds/images/
mv /mini/usr/share/backgrounds/images/* /usr/share/backgrounds/images/ 2>/dev/null
### /usr/lib/locale
### -----------------------------------------------------------
# do we restore?
if [ -d /mini/usr/lib/locale/zh_TW ]; then
MOVE_LOCALE=$( find /mini/usr/lib/locale/* -maxdepth 0 -type d \
| while read f; do echo ${f##/mini}; done )
else
MOVE_LOCALE=$( find /usr/lib/locale/* -maxdepth 0 -type d \
| grep -v en | grep -v de | grep -v fr )
fi
# add to FOLDERS
FOLDERS="$FOLDERS $MOVE_LOCALE"
### /usr/share/i18n/locales
### -----------------------------------------------------------
# do we restore?
if [ -d /mini/usr/share/i18n/locales/zh_TW ]; then
MOVE_LOCALE=$( find /mini/usr/share/i18n/locales/* -maxdepth 0 -type f \
| while read f; do echo ${f##/mini}; done )
else
MOVE_LOCALE=$( find /usr/share/i18n/locales/* -maxdepth 0 -type f \
| grep -v en | grep -v de | grep -v fr | grep -v POSIX )
fi
# add to FOLDERS
FOLDERS="$FOLDERS $MOVE_LOCALE"
### -----------------------------------------------------------
function usage() {
## Usage
# ----------------------------------------------------------
cat <<EOF
Options:
-h: print this screen
-restore: restores the folders saved in /mini
-nomove: do not move to /mini
-rootlogin: login directly as root and not as LOCALUSER
-psi: build for PSI
EOF
}
### -----------------------------------------------------------
### read options from command-line
RESTORE=""
while [ $# -gt 0 ]; do
case "$1" in
-h)
usage; exit;;
-restore)
RESTORE="-restore"; shift; continue;;
-psi)
PSI="-psi"; shift; continue;;
-nomove)
NOMOVE="-nomove"; shift; continue;;
-rootlogin)
ROOTLOGIN="-rootlogin"; shift; continue;;
*)
usage; exit;;
esac
done
### -----------------------------------------------------------
### LOCALUSER name?
if [ $PSI ]; then
LOCALUSER=l_psi
else
LOCALUSER=sluser
fi
### -----------------------------------------------------------
### Modifications for Mini LiveCD
if [ ! $RESTORE ]; then
if [ ! $NOMOVE ]; then
echo
echo "--------------------------------------------"
echo "Save diskspace by moving folders to /mini:"
echo "--------------------------------------------"
mkdir -p /mini
for folder in $FOLDERS; do
echo "Move $folder"
name=$( basename $folder )
base=${folder%$name}
mkdir -p /mini/${base}
mv ${folder} /mini${base}
done
fi
### force default runlevel equal 3, if neither xdm, kdm nor gdm is installed
which xdm >/dev/null 2>&1 || which kdm >/dev/null 2>&1 || which gdm >/dev/null 2>&1
if [ "$?" != "0" ]; then
sed -i "s/id\:.\:initdefault/id\:3\:initdefault/" /etc/inittab
fi
### enable auto login
echo "Enable auto login..."
customize/livecd-autologin -u $LOCALUSER on >/dev/null 2>&1
echo "### enable auto login for user $LOCALUSER (livecd-autologin)" >> /etc/rc.d/init.d/runlast
echo "livecd-autologin -u $LOCALUSER on >/dev/null 2>&1" >> /etc/rc.d/init.d/runlast
### run updatedb
echo "Run updatedb..."
. /etc/updatedb.conf 2>/dev/null
rpm -q mlocate >/dev/null
if [ "$?" = "0" ]; then
/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
else
/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
fi
echo "done."
### -----------------------------------------------------------
### Restores some modifications
else
if [ ! $NOMOVE ]; then
### remove default html page
rm /usr/share/doc/HTML/index.html
rm -rf /usr/share/doc/livecd
rmdir /usr/share/doc/HTML
rmdir /usr/share/doc
echo
echo "--------------------------------------------"
echo "Restore folders saved in /mini:"
echo "--------------------------------------------"
for folder in $FOLDERS; do
echo "Restore $folder"
name=$( basename $folder )
base=${folder%$name}
mv /mini${folder} ${base}
done
mv /mini/usr/share/i18n/locales/* /usr/share/i18n/locales/
echo "done."
fi
### disable auto login
echo "Disable auto login..."
customize/livecd-autologin -u $LOCALUSER off >/dev/null 2>&1
sed -i "/.*livecd-autologin.*/d" /etc/rc.d/init.d/runlast
fi
echo "--------------------------------------------"
echo "End of mini-livecd.sh"
echo "--------------------------------------------"
echo