2 # Copyright 1999-2004 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo/src/catalyst/targets/support/livecdfs-update.sh,v 1.16 2005/06/22 13:29:13 wolf31o2 Exp $
6 . /tmp/chroot-functions.sh
9 # allow root logins to the livecd by default
10 if [ -e /etc/sshd/sshd_config ]
12 sed -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' /etc/ssh/sshd_config
15 # turn off udev tarball
16 sed -i 's:RC_DEVICE_TARBALL="yes":RC_DEVICE_TARBALL="no":' /etc/conf.d/rc
18 # Do some livecd_type specific inittab changes
19 case ${clst_livecd_type} in
21 sed -i "s/^#c1:/c1:/" /etc/inittab
22 sed -i "/^.*bashlogin.*$/ d" /etc/inittab
26 # clean up the time and set to UTC
28 cp /usr/share/zoneinfo/UTC /etc/localtime
31 if [ "${clst_livecd_type}" == "gentoo-gamecd" ]
33 echo 'HOSTNAME="gamecd"' > /etc/conf.d/hostname
34 echo "127.0.0.1 gamecd.gentoo gamecd localhost" > /etc/hosts
36 echo 'HOSTNAME="livecd"' > /etc/conf.d/hostname
37 echo "127.0.0.1 livecd.gentoo livecd localhost" > /etc/hosts
39 echo 'OVERRIDE=0' > /etc/conf.d/domainname
40 echo 'DNSDOMAIN="gentoo"' >> /etc/conf.d/domainname
43 if [ -n "${clst_livecd_users}" ]
45 for x in ${clst_livecd_users}
47 useradd -G users,wheel,audio,games,cdrom,usb -c "Default LiveCD User" -m $x
52 if [ -f /etc/sudoers ]
54 sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers
57 # we want the first user to be used when auto-starting X
58 if [ -n "${clst_livecd_users}" -a -e /etc/startx ]
60 first_user=$(echo ${clst_livecd_users} | cut -d' ' -f1)
61 sed -i "s/startx/su - $first_user -c startx/" /root/.bashrc
64 # setup dhcp on all detected ethernet devices
65 echo "iface_eth0=\"dhcp\""> /etc/conf.d/net
66 echo "iface_eth1=\"dhcp\"" >> /etc/conf.d/net
67 echo "iface_eth2=\"dhcp\"" >> /etc/conf.d/net
68 echo "iface_eth3=\"dhcp\"" >> /etc/conf.d/net
69 echo "iface_eth4=\"dhcp\"" >> /etc/conf.d/net
71 # setup links for ethernet devices
73 ln -sf net.eth0 net.eth1
74 ln -sf net.eth0 net.eth2
75 ln -sf net.eth0 net.eth3
76 ln -sf net.eth0 net.eth4
78 # add this for hwsetup/mkx86config
79 mkdir -p /etc/sysconfig
82 echo "tmpfs / tmpfs defaults 0 0" > /etc/fstab
83 echo "tmpfs /lib/firmware tmpfs defaults 0 0" >> /etc/fstab
84 # if /usr/lib/X11/xkb/compiled then make it tmpfs
85 if [ -d /usr/lib/X11/xkb/compiled ]
87 echo "tmpfs /usr/lib/X11/xkb/compiled tmpfs defaults 0 0" >> /etc/fstab
91 sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf
93 # tweak the livecd fstab so that users know not to edit it
94 # http://bugs.gentoo.org/show_bug.cgi?id=60887
95 mv /etc/fstab /etc/fstab.old
96 echo "####################################################" >> /etc/fstab
97 echo "## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##" >> /etc/fstab
98 echo "## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##" >> /etc/fstab
99 echo "####################################################" >> /etc/fstab
100 cat /etc/fstab.old >> /etc/fstab
103 # add some helpful aliases
104 echo "alias cp='cp -i'" >> /etc/profile
105 echo "alias mv='mv -i'" >> /etc/profile
106 echo "alias rm='rm -i'" >> /etc/profile
107 echo "alias ls='ls --color=auto'" >> /etc/profile
108 echo "alias grep='grep --color=auto'" >> /etc/profile
110 # make sure we have the latest pci and hotplug ids
111 if [ -d /usr/share/hwdata ]
113 [ -f /usr/share/hwdata/pci.ids ] && rm -f /usr/share/hwdata/pci.ids
114 [ -f /usr/share/hwdata/usb.ids ] && rm -f /usr/share/hwdata/usb.ids
115 ln -s /usr/share/misc/pci.ids /usr/share/hwdata/pci.ids
116 ln -s /usr/share/misc/usb.ids /usr/share/hwdata/usb.ids
119 # setup opengl in /etc (if configured)
120 [ -x /usr/sbin/openglify ] && /usr/sbin/openglify
122 # touch /etc/asound.state
123 touch /etc/asound.state
125 # tweak the motd for gentoo releases
126 case ${clst_livecd_type} in
127 gentoo-release-universal )
128 cat /etc/generic.motd.txt /etc/universal.motd.txt \
129 /etc/minimal.motd.txt > /etc/motd
130 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd
132 gentoo-release-minimal )
133 cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd
134 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd
136 gentoo-release-livecd )
137 cat /etc/generic.motd.txt /etc/universal.motd.txt \
138 /etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd
139 sed -i 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' /etc/motd
142 cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd
143 sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd
147 rm -f /etc/generic.motd.txt /etc/universal.motd.txt /etc/minimal.motd.txt /etc/livecd.motd.txt /etc/gamecd.motd.txt
149 # setup splash/bootsplash (if called for)
150 if [ "${clst_livecd_splash_type}" == "bootsplash" -a -n "${clst_livecd_splash_theme}" ]
152 if [ -d /etc/bootsplash/${clst_livecd_splash_theme} ]
154 sed -i 's:BOOTSPLASH_THEME=\"gentoo\":BOOTSPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/bootsplash
155 rm /etc/bootsplash/default
156 ln -s "/etc/bootsplash/${clst_livecd_splash_theme}" /etc/bootsplash/default
158 echo "Error, cannot setup bootsplash theme ${clst_livecd_splash_theme}"
162 elif [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
164 if [ -d /etc/splash/${clst_livecd_splash_theme} ]
166 sed -i 's:# SPLASH_THEME="gentoo":SPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/splash
167 rm /etc/splash/default
168 ln -s /etc/splash/${clst_livecd_splash_theme} /etc/splash/default
170 echo "Error, cannot setup splash theme ${clst_livecd_splash_theme}"
175 # Create firmware directory if it does not exist
176 [ ! -d /lib/firmware ] && mkdir -p /lib/firmware
178 # tar up the firmware so that it does not get clobbered by the livecd mounts
179 if [ -n "$(ls /lib/firmware)" ]
182 if [ -n "$(ls /usr/lib/hotplug/firmware)" ]
184 cp /usr/lib/hotplug/firmware/* /lib/firmware
186 tar cvjpf /lib/firmware.tar.bz2 .
187 rm -f /lib/firmware/*
188 mkdir -p /usr/lib/hotplug
189 rm -rf /usr/lib/hotplug/firmware
190 ln -sf /lib/firmware /usr/lib/hotplug/firmware
194 case ${clst_livecd_type} in
196 # we grab our configuration
197 if [ -e /tmp/gamecd.conf ]
200 source /tmp/gamecd.conf || exit 1
203 # here we replace out game information into several files
204 sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd
206 # here we setup our xinitrc
207 echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc
210 # This is my hack to reduce tmpfs usage
211 mkdir -p /usr/livecd/db/pkg/x11-base
212 mv -f /var/db/pkg/x11-base/xorg* /usr/livecd/db/pkg/x11-base
217 gentoo-release-livecd )
218 # first we setup the livecd-kernel package
219 if [ -e /opt/installer/misc/mkvardb ]
221 chmod +x /opt/installer/misc/mkvardb
222 /opt/installer/misc/mkvardb -p livecd-kernel -c sys-kernel -v 2005.0 /boot/kernel* /boot/initrd* $(for i in $(find "/lib/modules/$(uname -r)" -type f); do grep --quiet "${i}" /var/db/pkg/*/*/CONTENTS || echo ${i}; done)
225 # This is my hack to reduce tmpfs usage
227 mv -f /usr/portage/profiles /usr/livecd
228 rm -rf /usr/livecd/profiles/{co*,default-{1*,a*,b*,d*,h*,i*,m*,p*,s*,x*},g*,hardened-*,n*,x*}
229 mv -f /etc/gconf /usr/livecd
230 mv -f /var/db /usr/livecd
233 # This is my hack to reduce tmpfs usage
235 mv -f /etc/gconf /usr/livecd