5 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
34 # Since we're an official Gentoo release, we do things the official Gentoo way.
35 # As such, we override livecd/users.
36 case ${clst_livecd_type} in
38 user_comment="Gentoo default user"
39 clst_livecd_users="gentoo"
42 user_comment="Gentoo GameCD default user"
43 clst_livecd_users="gamecd"
48 if [ -n "${clst_livecd_users}" ]
50 first_user=$(echo ${clst_livecd_users} | cut -d' ' -f1)
51 default_comment="Default LiveCD User"
52 [ -z "${user_comment}" ] && user_comment=${default_comment}
54 # Here we check to see if games exists for bug #125498
55 if [ "$(getent group games | cut -d: -f1)" != "games" ]
57 echo "Adding games group"
60 if [ "$(getent group plugdev | cut -d: -f1)" != "plugdev" ]
62 echo "Adding plugdev group"
65 for x in ${clst_livecd_users}
67 useradd -G users,wheel,audio,plugdev,games,cdrom,disk,floppy,usb \
68 -g 100 -c "${user_comment}" -m ${x}
69 chown -R ${x}:users /home/${x}
70 if [ -n "${clst_livecd_xdm}" -a -n "${clst_livecd_xsession}" ]
72 echo "[Desktop]" > /home/${x}/.dmrc
73 echo "Session=${clst_livecd_xsession}" >> /home/${x}/.dmrc
74 chown -R ${x}:users /home/${x}
80 if [ -f /etc/sudoers ]
82 sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers
85 # Setup links for ethernet devices
87 ln -sf net.lo net.eth1
88 ln -sf net.lo net.eth2
89 ln -sf net.lo net.eth3
90 ln -sf net.lo net.eth4
92 # Add this for hwsetup/mkx86config
93 mkdir -p /etc/sysconfig
95 # Tweak the livecd fstab so that users know not to edit it
96 # http://bugs.gentoo.org/show_bug.cgi?id=60887
97 echo "####################################################" > /etc/fstab
98 echo "## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##" >> /etc/fstab
99 echo "## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##" >> /etc/fstab
100 echo "####################################################" >> /etc/fstab
103 echo "tmpfs / tmpfs defaults 0 0" >> /etc/fstab
104 echo "tmpfs /lib/firmware tmpfs defaults 0 0" >> /etc/fstab
105 echo "tmpfs /usr/portage tmpfs defaults 0 0" >> /etc/fstab
106 # If /usr/lib/X11/xkb/compiled then make it tmpfs
107 if [ -d /usr/lib/X11/xkb/compiled ]
109 echo "tmpfs /usr/lib/X11/xkb/compiled tmpfs defaults 0 0" >> \
113 # Tweak the livecd make.conf so that users know not to edit it
114 # http://bugs.gentoo.org/show_bug.cgi?id=144647
115 mv /etc/portage/make.conf /etc/portage/make.conf.old
116 echo "####################################################" >> /etc/portage/make.conf
117 echo "## ATTENTION: THIS IS THE MAKE.CONF ON THE LIVECD ##" >> /etc/portage/make.conf
118 echo "## PLEASE EDIT /mnt/gentoo/etc/portage/make.conf INSTEAD ##" >> /etc/portage/make.conf
119 echo "####################################################" >> /etc/portage/make.conf
120 cat /etc/portage/make.conf.old >> /etc/portage/make.conf
123 [ -e /etc/devfsd.conf ] && sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf
125 # Add some helpful aliases
126 echo "alias cp='cp -i'" >> /etc/profile
127 echo "alias mv='mv -i'" >> /etc/profile
128 echo "alias rm='rm -i'" >> /etc/profile
129 echo "alias ls='ls --color=auto'" >> /etc/profile
130 echo "alias ll='ls -l'" >> /etc/profile
131 echo "alias grep='grep --color=auto'" >> /etc/profile
133 # Make sure we have the latest pci,usb and hotplug ids. Older versions of
134 # pciutils and usbutils used /sbin, where newer versions use /usr/sbin.
135 [ -x /sbin/update-pciids ] && /sbin/update-pciids
136 [ -x /sbin/update-usbids ] && /sbin/update-usbids
137 [ -x /usr/sbin/update-pciids ] && /usr/sbin/update-pciids
138 [ -x /usr/sbin/update-usbids ] && /usr/sbin/update-usbids
139 if [ -d /usr/share/hwdata ]
141 # If we have uncompressed pci and usb ids files, symlink them.
142 [ -f /usr/share/misc/pci.ids ] && [ -f /usr/share/hwdata/pci.ids ] && \
143 rm -f /usr/share/hwdata/pci.ids && ln -s /usr/share/misc/pci.ids \
144 /usr/share/hwdata/pci.ids
145 [ -f /usr/share/misc/usb.ids ] && [ -f /usr/share/hwdata/usb.ids ] && \
146 rm -f /usr/share/hwdata/usb.ids && ln -s /usr/share/misc/usb.ids \
147 /usr/share/hwdata/usb.ids
148 # If we have compressed pci and usb files, we download our own copies.
149 [ -f /usr/share/misc/pci.ids.gz ] && [ -f /usr/share/hwdata/pci.ids ] && \
150 rm -f /usr/share/hwdata/pci.ids && wget -O /usr/share/hwdata/pci.ids \
151 http://pciids.sourceforge.net/v2.2/pci.ids
152 [ -f /usr/share/misc/usb.ids.gz ] && [ -f /usr/share/hwdata/usb.ids ] && \
153 rm -f /usr/share/hwdata/usb.ids && wget -O /usr/share/hwdata/usb.ids \
154 http://www.linux-usb.org/usb.ids
157 # Setup opengl in /etc (if configured)
158 [ -x /usr/sbin/openglify ] && /usr/sbin/openglify
160 # Setup configured display manager
161 if [ -n "${clst_livecd_xdm}" ]
164 -e "s:^#\\?DISPLAYMANAGER=.\+$:DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \
167 -e "s:^#\\?DISPLAYMANAGER=.\+$:DISPLAYMANAGER=\"${clst_livecd_xdm}\":" \
171 # Setup configured default X Session
172 if [ -n "${clst_livecd_xsession}" ]
174 sed -i "s:#XSESSION=\"Gnome\":XSESSION=\"${clst_livecd_xsession}\":" \
178 # touch /etc/asound.state
179 touch /etc/asound.state
181 # Tweak the MOTD for Gentoo releases
182 case ${clst_livecd_type} in
183 gentoo-release-universal)
184 cat /etc/generic.motd.txt /etc/universal.motd.txt \
185 /etc/minimal.motd.txt > /etc/motd
186 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd
188 gentoo-release-minimal)
189 cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd
190 sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd
192 gentoo-release-live*)
193 cat /etc/generic.motd.txt \
194 /etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd
195 sed -i -e 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' \
196 -e "s:##DISPLAY_MANAGER:${clst_livecd_xdm}:" /etc/motd
199 cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd
200 sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd
204 rm -f /etc/generic.motd.txt /etc/universal.motd.txt /etc/minimal.motd.txt /etc/livecd.motd.txt /etc/gamecd.motd.txt
206 # Setup splash (if called for)
207 if [ -n "${clst_livecd_splash_theme}" ]
209 if [ -d /etc/splash/${clst_livecd_splash_theme} ]
212 -e "s:# SPLASH_THEME=\"gentoo\":SPLASH_THEME=\"${clst_livecd_splash_theme}\":" \
213 -e "/^# SPLASH_TTYS=/ s/^#//" \
215 rm -f /etc/splash/default
216 ln -s /etc/splash/${clst_livecd_splash_theme} /etc/splash/default
218 echo "Error, cannot setup splash theme ${clst_livecd_splash_theme}"
223 # Create firmware directory if it does not exist
224 [ ! -d /lib/firmware ] && mkdir -p /lib/firmware
226 # tar up the firmware so that it does not get clobbered by the livecd mounts
227 if [ -n "$(ls /lib/firmware)" ]
230 /bin/tar -I bzip2 -cpf /lib/firmware.tar.bz2 .
231 rm -rf /lib/firmware/*
235 case ${clst_livecd_type} in
236 gentoo-release-minimal|gentoo-release-universal|gentoo-gamecd)
237 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}*
242 case ${clst_livecd_type} in
244 # We grab our configuration
245 if [ -e /tmp/gamecd.conf ]
247 source /tmp/gamecd.conf || exit 1
250 # Here we replace out game information into several files
251 sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd
253 # Here we setup our xinitrc
254 echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc
257 # This is my hack to reduce tmpfs usage
258 mkdir -p /usr/livecd/db/pkg/x11-base
259 mv -f /var/db/pkg/x11-base/xorg* /usr/livecd/db/pkg/x11-base
264 gentoo-release-live*)
266 if [ "${clst_livecd_xsession}" == "gnome" ]
268 gconftool-2 --direct \
269 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
270 --type string --set /desktop/gnome/interface/font_name "Sans 9"
273 # Remove locking on screensaver
274 gconftool-2 --direct \
275 --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s \
276 -t bool /apps/gnome-screensaver/lock_enabled false >/dev/null
279 if [ "${clst_livecd_xdm}" == "gdm" ]
281 if [ ! -e /etc/X11/gdm/gdm.conf ] && [ -e /usr/share/gdm/defaults.conf ]
283 if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ]
285 sedxtra="\nTimedLogin=${first_user}"
290 cp -f /etc/X11/gdm/custom.conf /etc/X11/gdm/custom.conf.old
293 -e "s:\(\[daemon\]\)$:\1\nTimedLoginEnable=true\nTimedLoginDelay=10${sedxtra}:" \
294 -e 's:\(\[greeter\]\)$:\1\nGraphicalTheme=gentoo-emergence:' \
295 /etc/X11/gdm/custom.conf
297 cp -f /etc/X11/gdm/gdm.conf /etc/X11/gdm/gdm.conf.old
299 -e 's:TimedLoginEnable=false:TimedLoginEnable=true:' \
300 -e 's:TimedLoginDelay=30:TimedLoginDelay=10:' \
301 -e 's:AllowRemoteRoot=true:AllowRemoteRoot=false:' \
302 -e ':^#GraphicalTheme=: s:^#::' \
303 -e 's:^GraphicalTheme=.*$:GraphicalTheme=gentoo-emergence:' \
304 /etc/X11/gdm/gdm.conf
306 if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ]
309 -e "s:TimedLogin=:TimedLogin=${first_user}:" \
310 /etc/X11/gdm/gdm.conf
315 # This gives us our list of system packages for the installer
317 ### XXX: Andrew says we don't need this anymore
318 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
320 # This is my hack to reduce tmpfs usage
321 cp -r /usr/portage/profiles /usr/livecd
322 cp -r /usr/portage/eclass /usr/livecd
323 rm -rf /usr/livecd/profiles/{co*,default-{1*,a*,b*,d*,h*,i*,m*,p*,s*,x*},g*,hardened-*,n*,x*}
324 mv -f /etc/gconf /usr/livecd
325 ln -sf /usr/livecd/gconf /etc/gconf
326 mv -f /var/db /usr/livecd
327 ln -sf /usr/livecd/db /var/db
330 rm -f /var/log/lastlog && touch /var/log/lastlog
332 # Create our Handbook icon
333 [ -e /docs/handbook/index.html ] && create_handbook_icon
334 [ -n "${clst_livecd_overlay}" ] && [ -e ${clst_livecd_overlay}/docs/handbook/index.html ] && create_handbook_icon
336 # Copy our icons into place and build home directories
337 if [ -n "${clst_livecd_users}" ]
339 for username in ${clst_livecd_users}
341 mkdir -p /home/${username}/Desktop
342 # Copy our Handbook icon
343 [ -e /usr/share/applications/gentoo-handbook.desktop ] && \
344 cp -f /usr/share/applications/gentoo-handbook.desktop \
345 /home/${username}/Desktop
346 # Copy our installer icons
347 if [ -e /usr/share/applications/installer-gtk.desktop ]
349 cp -f /usr/share/applications/installer-gtk.desktop \
350 /home/${username}/Desktop
351 cp -f /usr/share/applications/installer-dialog.desktop \
352 /home/${username}/Desktop
354 's:Exec=installer-dialog:Exec=sudo installer-dialog:' \
355 /home/${username}/Desktop/installer-dialog.desktop
356 sed -i -e 's:Exec=installer-gtk:Exec=installer:' \
357 /home/${username}/Desktop/installer-gtk.desktop
359 chown -R ${username}:100 /home/${username}
364 # This is my hack to reduce tmpfs usage
369 mv -f /etc/gconf /usr/livecd
370 ln -sf /usr/livecd/gconf /etc/gconf
373 if [ -e /usr/livecd/kernelpkgs.txt ]
375 rm -f /usr/livecd/kernelpkgs.txt
381 if [ -e /usr/livecd/kernelpkgs.txt ]
383 rm -f /usr/livecd/kernelpkgs.txt
388 # We want the first user to be used when auto-starting X
389 if [ -e /etc/startx ]
392 "s:##STARTX:source /etc/profile \&\& su - ${first_user} -c startx:" \
396 if [ -e /lib/rcscripts/addons/udev-start.sh ]
398 sed -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} \]\] \&\& \[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh