3 source /tmp/chroot-functions.sh
7 # Allow root logins to our CD by default
8 if [ -e /etc/sshd/sshd_config ]
10 sed -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' \
14 # Turn off udev tarball
15 sed -i 's:RC_DEVICE_TARBALL="yes":RC_DEVICE_TARBALL="no":' /etc/conf.d/rc
17 # Turn off udev coldplugging
18 sed -i 's:RC_COLDPLUG="yes":RC_COLDPLUG="no":' /etc/conf.d/rc
20 # Clean up the time and set to UTC
22 cp /usr/share/zoneinfo/UTC /etc/localtime
25 if [ "${clst_livecd_type}" == "gentoo-gamecd" ]
27 echo 'HOSTNAME="gamecd"' > /etc/conf.d/hostname
28 echo "127.0.0.1 gamecd.gentoo gamecd localhost" > /etc/hosts
30 echo 'HOSTNAME="livecd"' > /etc/conf.d/hostname
31 echo "127.0.0.1 livecd.gentoo livecd localhost" > /etc/hosts
33 echo 'OVERRIDE=0' > /etc/conf.d/domainname
34 echo 'DNSDOMAIN="gentoo"' >> /etc/conf.d/domainname
37 if [ -n "${clst_livecd_users}" ]
39 first_user=$(echo ${clst_livecd_users} | cut -d' ' -f1)
41 # Here we check to see if games exists for bug #125498
42 if [ "$(getent group games | cut -d: -f1)" != "games" ]
44 echo "Adding games group"
47 for x in ${clst_livecd_users}
49 useradd -G users,wheel,audio,games,cdrom,usb -c "Default LiveCD User" \
51 chown -R ${x}:users /home/${x}
52 if [ -n "${clst_livecd_xdm}" -a -n "${clst_livecd_xsession}" ]
54 echo "[Desktop]" > /home/${x}/.dmrc
55 echo "Session=${clst_livecd_xsession}" >> /home/${x}/.dmrc
56 chown -R ${x}:users /home/${x}
62 if [ -f /etc/sudoers ]
64 sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers
67 # Setup links for ethernet devices
69 ln -sf net.lo net.eth1
70 ln -sf net.lo net.eth2
71 ln -sf net.lo net.eth3
72 ln -sf net.lo net.eth4
74 # Add this for hwsetup/mkx86config
75 mkdir -p /etc/sysconfig
77 # Tweak the livecd fstab so that users know not to edit it
78 # http://bugs.gentoo.org/show_bug.cgi?id=60887
79 echo "####################################################" > /etc/fstab
80 echo "## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##" >> /etc/fstab
81 echo "## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##" >> /etc/fstab
82 echo "####################################################" >> /etc/fstab
85 echo "tmpfs / tmpfs defaults 0 0" >> /etc/fstab
86 echo "tmpfs /lib/firmware tmpfs defaults 0 0" >> /etc/fstab
87 echo "tmpfs /usr/portage tmpfs defaults 0 0" >> /etc/fstab
88 # If /usr/lib/X11/xkb/compiled then make it tmpfs
89 if [ -d /usr/lib/X11/xkb/compiled ]
91 echo "tmpfs /usr/lib/X11/xkb/compiled tmpfs defaults 0 0" >> \
95 # Tweak the livecd make.conf so that users know not to edit it
96 # http://bugs.gentoo.org/show_bug.cgi?id=144647
97 mv /etc/make.conf /etc/make.conf.old
98 echo "####################################################" >> /etc/make.conf
99 echo "## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ##" >> /etc/make.conf
100 echo "## PLEASE EDIT /mnt/gentoo/etc/make.conf INSTEAD ##" >> /etc/make.conf
101 echo "####################################################" >> /etc/make.conf
102 cat /etc/make.conf.old >> /etc/make.conf
105 [ -e /etc/devfsd.conf ] && sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf
107 # Add some helpful aliases
108 echo "alias cp='cp -i'" >> /etc/profile
109 echo "alias mv='mv -i'" >> /etc/profile
110 echo "alias rm='rm -i'" >> /etc/profile
111 echo "alias ls='ls --color=auto'" >> /etc/profile
112 echo "alias ll='ls -l'" >> /etc/profile
113 echo "alias grep='grep --color=auto'" >> /etc/profile
115 # Make sure we have the latest pci,usb and hotplug ids
116 [ -x /sbin/update-pciids ] && /sbin/update-pciids
117 [ -x /sbin/update-usbids ] && /sbin/update-usbids
118 if [ -d /usr/share/hwdata ]
120 [ -f /usr/share/hwdata/pci.ids ] && rm -f /usr/share/hwdata/pci.ids
121 [ -f /usr/share/hwdata/usb.ids ] && rm -f /usr/share/hwdata/usb.ids
122 ln -s /usr/share/misc/pci.ids /usr/share/hwdata/pci.ids
123 ln -s /usr/share/misc/usb.ids /usr/share/hwdata/usb.ids
126 # Setup opengl in /etc (if configured)
127 [ -x /usr/sbin/openglify ] && /usr/sbin/openglify
129 # Setup configured display manager
130 if [ -n "${clst_livecd_xdm}" ]
133 -e "s:DISPLAYMANAGER=\"xdm\":DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \
134 -e ":^DISPLAYMANAGER: s:^#::" \
137 -e "s:DISPLAYMANAGER=\"xdm\":DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \
141 # Setup configured default X Session
142 if [ -n "${clst_livecd_xsession}" ]
144 sed -i "s:#XSESSION=\"Gnome\":XSESSION=\"${clst_livecd_xsession}\":" \
148 # touch /etc/asound.state
149 touch /etc/asound.state
151 # Tweak the MOTD for Gentoo releases
152 case ${clst_livecd_type} in
153 gentoo-release-universal )
154 cat /etc/generic.motd.txt /etc/universal.motd.txt \
155 /etc/minimal.motd.txt > /etc/motd
156 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd
158 gentoo-release-minimal )
159 cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd
160 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd
162 gentoo-release-livecd )
163 cat /etc/generic.motd.txt \
164 /etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd
165 sed -i -e 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' \
166 -e "s:##DISPLAY_MANAGER:${clst_livecd_xdm}:" /etc/motd
169 cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd
170 sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd
174 rm -f /etc/generic.motd.txt /etc/universal.motd.txt /etc/minimal.motd.txt /etc/livecd.motd.txt /etc/gamecd.motd.txt
176 # Setup splash/bootsplash (if called for)
177 if [ "${clst_livecd_splash_type}" == "bootsplash" -a -n \
178 "${clst_livecd_splash_theme}" ]
180 if [ -d /etc/bootsplash/${clst_livecd_splash_theme} ]
182 sed -i 's:BOOTSPLASH_THEME=\"gentoo\":BOOTSPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/bootsplash
183 rm -f /etc/bootsplash/default
184 ln -s "/etc/bootsplash/${clst_livecd_splash_theme}" \
185 /etc/bootsplash/default
187 echo "Error, cannot setup bootsplash theme ${clst_livecd_splash_theme}"
190 elif [ "${clst_livecd_splash_type}" == "gensplash" -a -n \
191 "${clst_livecd_splash_theme}" ]
193 if [ -d /etc/splash/${clst_livecd_splash_theme} ]
196 -e "s:# SPLASH_THEME=\"gentoo\":SPLASH_THEME=\"${clst_livecd_splash_theme}\":" \
197 -e "/^# SPLASH_TTYS=/ s/^#//" \
199 rm -f /etc/splash/default
200 ln -s /etc/splash/${clst_livecd_splash_theme} /etc/splash/default
202 echo "Error, cannot setup splash theme ${clst_livecd_splash_theme}"
207 # Create firmware directory if it does not exist
208 [ ! -d /lib/firmware ] && mkdir -p /lib/firmware
210 # tar up the firmware so that it does not get clobbered by the livecd mounts
211 if [ -n "$(ls /lib/firmware)" ]
214 if [ -n "$(ls /usr/lib/hotplug/firmware)" ]
216 cp -r /usr/lib/hotplug/firmware/* /lib/firmware
218 /bin/tar cjpf /lib/firmware.tar.bz2 .
219 rm -rf /lib/firmware/*
220 mkdir -p /usr/lib/hotplug
221 rm -rf /usr/lib/hotplug/firmware
222 ln -sf /lib/firmware /usr/lib/hotplug/firmware
226 case ${clst_livecd_type} in
227 gentoo-release-minimal|gentoo-release-universal|gentoo-gamecd)
228 rm -rf /usr/lib/locale/{a,b,c,d,e{l,n_{A,B,C,D,G,H,I,N,P,S,US.,Z},s,t,u},f,g,h,i,j,k,l,m,n,o,p,r,s,t,u,v,w,x,y,z}*
233 case ${clst_livecd_type} in
235 # We grab our configuration
236 if [ -e /tmp/gamecd.conf ]
238 source /tmp/gamecd.conf || exit 1
241 # Here we replace out game information into several files
242 sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd
244 # Here we setup our xinitrc
245 echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc
248 # This is my hack to reduce tmpfs usage
249 mkdir -p /usr/livecd/db/pkg/x11-base
250 mv -f /var/db/pkg/x11-base/xorg* /usr/livecd/db/pkg/x11-base
255 gentoo-release-livecd )
256 # First we setup the livecd-kernel package
257 if [ -e /opt/installer/misc/mkvardb ]
259 chmod +x /opt/installer/misc/mkvardb
260 /opt/installer/misc/mkvardb -p livecd-kernel -c sys-kernel -v ${clst_version_stamp} --provide "virtual/alsa" /boot/System* /boot/kernel* /boot/initr* $(for i in $(find "/lib/modules/" -type f); do grep --quiet "${i}" /var/db/pkg/*/*/CONTENTS || echo ${i}; done)
264 if [ "${clst_livecd_xsession}" == "gnome" ]
266 gconftool-2 --direct \
267 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
268 --type string --set /desktop/gnome/interface/theme Clearlooks
269 gconftool-2 --direct \
270 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
271 --type string --set /apps/metacity/general/theme Clearlooks
272 gconftool-2 --direct \
273 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
274 --type string --set /desktop/gnome/interface/gtk_key_theme \
276 gconftool-2 --direct \
277 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
278 --type string --set /desktop/gnome/interface/gtk_theme \
280 gconftool-2 --direct \
281 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
282 --type string --set /desktop/gnome/interface/font_name "Sans 9"
286 if [ "${clst_livecd_xdm}" == "gdm" ]
288 if [ ! -e /etc/X11/gdm/gdm.conf ] && [ -e /usr/share/gdm/defaults.conf ]
290 if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ]
292 sedxtra="\nTimedLogin=${first_user}"
297 cp -f /etc/X11/gdm/custom.conf /etc/X11/gdm/custom.conf.old
300 -e "s:\(\[daemon\]\)$:\1\nTimedLoginEnable=true\nTimedLoginDelay=10${sedxtra}:" \
301 -e 's:\(\[greeter\]\)$:\1\nGraphicalTheme=gentoo-emergence:' \
302 /etc/X11/gdm/custom.conf
304 cp -f /etc/X11/gdm/gdm.conf /etc/X11/gdm/gdm.conf.old
306 -e 's:TimedLoginEnable=false:TimedLoginEnable=true:' \
307 -e 's:TimedLoginDelay=30:TimedLoginDelay=10:' \
308 -e 's:AllowRemoteRoot=true:AllowRemoteRoot=false:' \
309 -e ':^#GraphicalTheme=: s:^#::' \
310 -e 's:^GraphicalTheme=.*$:GraphicalTheme=gentoo-emergence:' \
311 /etc/X11/gdm/gdm.conf
313 if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ]
316 -e "s:TimedLogin=:TimedLogin=${first_user}:" \
317 /etc/X11/gdm/gdm.conf
322 # This gives us our list of system packages for the installer
324 USE="-* $(cat /var/db/pkg/sys-libs/glibc*/USE)" emerge -eqp system | grep -e '^\[ebuild' | sed -e 's:^\[ebuild .\+\] ::' -e 's: .\+$::' > /usr/livecd/systempkgs.txt
326 # This is my hack to reduce tmpfs usage
327 cp -r /usr/portage/profiles /usr/livecd
328 cp -r /usr/portage/eclass /usr/livecd
329 rm -rf /usr/livecd/profiles/{co*,default-{1*,a*,b*,d*,h*,i*,m*,p*,s*,x*},g*,hardened-*,n*,x*}
330 mv -f /etc/gconf /usr/livecd
331 mv -f /var/db /usr/livecd
333 # This gives us a proper cache for portage/installer
334 tar cjf /usr/livecd/metadata.tar.bz2 /var/cache/edb/dep/usr/portage
336 # We remove kernel sources from our vdb
337 rm -rf /usr/livecd/db/pkg/sys-kernel/*sources*
340 rm -f /var/log/lastlog && touch /var/log/lastlog
342 # Create our Handbook icon
345 # Copy our icons into place and build home directories
346 if [ -n "${clst_livecd_users}" ]
348 for username in ${clst_livecd_users}
350 mkdir -p /home/${username}/Desktop
351 # Copy our Handbook icon
352 cp -f /usr/share/applications/gentoo-handbook.desktop \
353 /home/${username}/Desktop
354 # Copy our installer icons
355 if [ -e /usr/share/applications/installer-gtk.desktop ]
357 cp -f /usr/share/applications/installer-gtk.desktop \
358 /home/${username}/Desktop
359 cp -f /usr/share/applications/installer-dialog.desktop \
360 /home/${username}/Desktop
362 's:Exec=installer-dialog:Exec=sudo installer-dialog:' \
363 /home/${username}/Desktop/installer-dialog.desktop
364 sed -i -e 's:Exec=installer-gtk:Exec=installer:' \
365 /home/${username}/Desktop/installer-gtk.desktop
367 chown -R ${username}:100 /home/${username}
372 # This is my hack to reduce tmpfs usage
374 [ -d /etc/gconf ] && mv -f /etc/gconf /usr/livecd
375 if [ -e /usr/livecd/grppkgs.txt ]
377 rm -f /usr/livecd/grppkgs.txt
379 if [ -e /usr/livecd/kernelpkgs.txt ]
381 rm -f /usr/livecd/kernelpkgs.txt
387 if [ -e /usr/livecd/grppkgs.txt ]
389 rm -f /usr/livecd/grppkgs.txt
391 if [ -e /usr/livecd/kernelpkgs.txt ]
393 rm -f /usr/livecd/kernelpkgs.txt
398 # We want the first user to be used when auto-starting X
399 if [ -e /etc/startx ]
402 "s:##STARTX:source /etc/profile && su - ${first_user} -c startx:" \
406 if [ -e /lib/rcscripts/addons/udev-start.sh ]
408 sed -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} \]\] \&\& \[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh