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.11 2005/04/21 14:23:12 rocket 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 # Comment out current getty settings
19 sed -i -e '/^c[0-9]/ s/^/#/' /etc/inittab
21 # Add our own getty settings
24 echo "c${x}:12345:respawn:/sbin/agetty -nl /bin/bashlogin 38400 tty${x} linux" >> /etc/inittab
27 # Do some livecd_type specific inittab changes
28 case ${clst_livecd_type} in
30 sed -i "s/^#c1:/c1:/" /etc/inittab
31 sed -i "/^.*bashlogin.*$/ d" /etc/inittab
35 # clean up the time and set to UTC
37 cp /usr/share/zoneinfo/UTC /etc/localtime
40 case ${clst_livecd_type} in
42 echo "gentoo" > /etc/dnsdomainname
43 echo "127.0.0.1 livecd.gentoo livecd localhost" > /etc/hosts
46 echo "gamecd" > /etc/hostname
47 echo "gentoo" > /etc/dnsdomainname
48 echo "127.0.0.1 gamecd.gentoo gamecd localhost" > /etc/hosts
51 echo "livecd" > /etc/hostname
52 echo "gentoo" > /etc/dnsdomainname
53 echo "127.0.0.1 livecd.gentoo livecd localhost" > /etc/hosts
56 echo "catalyst-livecd" > /etc/hostname
57 echo "gentoo" > /etc/dnsdomainname
58 echo "127.0.0.1 catalyst-livecd.gentoo livecd localhost" > /etc/hosts
63 if [ -n "${clst_livecd_users}" ]
65 for x in ${clst_livecd_users}
67 useradd -G users,wheel,audio,games,cdrom,usb -c "Default LiveCD User" -m $x
72 if [ -f /etc/sudoers ]
74 sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers
77 # we want the first user to be used when auto-starting X
78 if [ -n "${clst_livecd_users}" -a -e /etc/startx ]
80 first_user=$(echo ${clst_livecd_users} | cut -d' ' -f1)
81 sed -i "s/startx/su - $first_user -c startx/" /root/.bashrc
84 # setup dhcp on all detected ethernet devices
85 echo "iface_eth0=\"dhcp\""> /etc/conf.d/net
86 echo "iface_eth1=\"dhcp\"" >> /etc/conf.d/net
87 echo "iface_eth2=\"dhcp\"" >> /etc/conf.d/net
88 echo "iface_eth3=\"dhcp\"" >> /etc/conf.d/net
89 echo "iface_eth4=\"dhcp\"" >> /etc/conf.d/net
91 # setup links for ethernet devices
93 ln -sf net.eth0 net.eth1
94 ln -sf net.eth0 net.eth2
95 ln -sf net.eth0 net.eth3
96 ln -sf net.eth0 net.eth4
98 # add this for hwsetup/mkx86config
99 mkdir -p /etc/sysconfig
102 echo "tmpfs / tmpfs defaults 0 0" > /etc/fstab
103 echo "tmpfs /lib/firmware tmpfs defaults 0 0" >> /etc/fstab
104 # if /usr/lib/X11/xkb/compiled then make it tmpfs
105 if [ -d /usr/lib/X11/xkb/compiled ]
107 echo "tmpfs /usr/lib/X11/xkb/compiled tmpfs defaults 0 0" >> /etc/fstab
111 sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf
113 # tweak the livecd fstab so that users know not to edit it
114 # http://bugs.gentoo.org/show_bug.cgi?id=60887
115 mv /etc/fstab /etc/fstab.old
116 echo "####################################################" >> /etc/fstab
117 echo "## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##" >> /etc/fstab
118 echo "## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##" >> /etc/fstab
119 echo "####################################################" >> /etc/fstab
120 cat /etc/fstab.old >> /etc/fstab
123 # add some helpful aliases
124 echo "alias cp='cp -i'" >> /etc/profile
125 echo "alias mv='mv -i'" >> /etc/profile
126 echo "alias rm='rm -i'" >> /etc/profile
127 echo "alias ls='ls --color=auto'" >> /etc/profile
128 echo "alias grep='grep --color=auto'" >> /etc/profile
130 # make sure we have the latest pci and hotplug ids
131 if [ -d /usr/share/hwdata ]
133 [ -f /usr/share/hwdata/pci.ids ] && rm -f /usr/share/hwdata/pci.ids
134 [ -f /usr/share/hwdata/usb.ids ] && rm -f /usr/share/hwdata/usb.ids
135 ln -s /usr/share/misc/pci.ids /usr/share/hwdata/pci.ids
136 ln -s /usr/share/misc/usb.ids /usr/share/hwdata/usb.ids
139 # setup opengl in /etc (if configured)
140 #[ -x /usr/sbin/openglify ] && /usr/sbin/openglify
143 # touch /etc/asound.state
144 touch /etc/asound.state
146 # tweak the motd for gentoo releases
147 case ${clst_livecd_type} in
148 gentoo-release-universal )
149 cat /etc/generic.motd.txt /etc/universal.motd.txt \
150 /etc/minimal.motd.txt > /etc/motd
151 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd
153 gentoo-release-minimal )
154 cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd
155 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd
157 gentoo-release-livecd )
158 cat /etc/generic.motd.txt /etc/universal.motd.txt \
159 /etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd
160 sed -i 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' /etc/motd
163 cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd
164 sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd
168 rm -f /etc/generic.motd.txt /etc/universal.motd.txt /etc/minimal.motd.txt /etc/livecd.motd.txt /etc/gamecd.motd.txt
170 # setup splash/bootsplash (if called for)
171 if [ "${clst_livecd_splash_type}" == "bootsplash" -a -n "${clst_livecd_splash_theme}" ]
173 if [ -d /etc/bootsplash/${clst_livecd_splash_theme} ]
175 sed -i 's:BOOTSPLASH_THEME=\"gentoo\":BOOTSPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/bootsplash
176 rm /etc/bootsplash/default
177 ln -s "/etc/bootsplash/${clst_livecd_splash_theme}" /etc/bootsplash/default
179 echo "Error, cannot setup bootsplash theme ${clst_livecd_splash_theme}"
183 elif [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
185 if [ -d /etc/splash/${clst_livecd_splash_theme} ]
187 sed -i 's:# SPLASH_THEME="gentoo":SPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/splash
188 rm /etc/splash/default
189 ln -s /etc/splash/${clst_livecd_splash_theme} /etc/splash/default
191 echo "Error, cannot setup splash theme ${clst_livecd_splash_theme}"
196 # Create firmware directory if it does not exist
197 [ ! -d /lib/firmware ] && mkdir -p /lib/firmware
199 # tar up the firmware so that it does not get clobbered by the livecd mounts
200 if [ -n "$(ls /lib/firmware)" ]
203 if [ -n "$(ls /usr/lib/hotplug/firmware)" ]
205 cp /usr/lib/hotplug/firmware/* /lib/firmware
207 tar cvjpf /lib/firmware.tar.bz2 .
208 rm -f /lib/firmware/*
209 mkdir -p /usr/lib/hotplug
210 rm -rf /usr/lib/hotplug/firmware
211 ln -sf /lib/firmware /usr/lib/hotplug/firmware
215 case ${clst_livecd_type} in
217 # we grab our configuration
218 if [ -e /tmp/gamecd.conf ]
221 source /tmp/gamecd.conf || exit 1
224 # here we replace out game information into several files
225 sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd
227 # here we setup our xinitrc
228 echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc
231 # This is my hack to reduce tmpfs usage
232 mkdir -p /usr/livecd/db/pkg/x11-base
233 mv -f /var/db/pkg/x11-base/xorg* /usr/livecd/db/pkg/x11-base
238 gentoo-release-livecd )
239 # first we setup the livecd-kernel package
240 if [ -e /opt/installer/misc/mkvardb ]
242 chmod +x /opt/installer/misc/mkvardb
243 /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)
246 # This is my hack to reduce tmpfs usage
248 mv -f /usr/portage/profiles /usr/livecd
249 rm -rf /usr/livecd/profiles/{co*,default-{1*,a*,b*,d*,h*,i*,m*,p*,s*,x*},g*,hardened-*,n*,x*}
250 mv -f /etc/gconf /usr/livecd
251 mv -f /var/db /usr/livecd
254 # This is my hack to reduce tmpfs usage
256 mv -f /etc/gconf /usr/livecd