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}"
224 case ${clst_livecd_type} in
225 gentoo-release-minimal|gentoo-release-universal|gentoo-gamecd)
226 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}*
231 case ${clst_livecd_type} in
233 # We grab our configuration
234 if [ -e /tmp/gamecd.conf ]
236 source /tmp/gamecd.conf || exit 1
239 # Here we replace out game information into several files
240 sed -i -e "s:##GAME_NAME:${GAME_NAME}:" /etc/motd
242 # Here we setup our xinitrc
243 echo "exec ${GAME_EXECUTABLE}" > /etc/X11/xinit/xinitrc
246 # This is my hack to reduce tmpfs usage
247 mkdir -p /usr/livecd/db/pkg/x11-base
248 mv -f /var/db/pkg/x11-base/xorg* /usr/livecd/db/pkg/x11-base
253 gentoo-release-live*)
255 if [ "${clst_livecd_xsession}" == "gnome" ]
257 gconftool-2 --direct \
258 --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
259 --type string --set /desktop/gnome/interface/font_name "Sans 9"
262 # Remove locking on screensaver
263 gconftool-2 --direct \
264 --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s \
265 -t bool /apps/gnome-screensaver/lock_enabled false >/dev/null
268 if [ "${clst_livecd_xdm}" == "gdm" ]
270 if [ ! -e /etc/X11/gdm/gdm.conf ] && [ -e /usr/share/gdm/defaults.conf ]
272 if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ]
274 sedxtra="\nTimedLogin=${first_user}"
279 cp -f /etc/X11/gdm/custom.conf /etc/X11/gdm/custom.conf.old
282 -e "s:\(\[daemon\]\)$:\1\nTimedLoginEnable=true\nTimedLoginDelay=10${sedxtra}:" \
283 -e 's:\(\[greeter\]\)$:\1\nGraphicalTheme=gentoo-emergence:' \
284 /etc/X11/gdm/custom.conf
286 cp -f /etc/X11/gdm/gdm.conf /etc/X11/gdm/gdm.conf.old
288 -e 's:TimedLoginEnable=false:TimedLoginEnable=true:' \
289 -e 's:TimedLoginDelay=30:TimedLoginDelay=10:' \
290 -e 's:AllowRemoteRoot=true:AllowRemoteRoot=false:' \
291 -e ':^#GraphicalTheme=: s:^#::' \
292 -e 's:^GraphicalTheme=.*$:GraphicalTheme=gentoo-emergence:' \
293 /etc/X11/gdm/gdm.conf
295 if [ -n "${clst_livecd_users}" ] && [ -n "${first_user}" ]
298 -e "s:TimedLogin=:TimedLogin=${first_user}:" \
299 /etc/X11/gdm/gdm.conf
304 # This gives us our list of system packages for the installer
306 ### XXX: Andrew says we don't need this anymore
307 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
309 # This is my hack to reduce tmpfs usage
310 cp -r /usr/portage/profiles /usr/livecd
311 cp -r /usr/portage/eclass /usr/livecd
312 rm -rf /usr/livecd/profiles/{co*,default-{1*,a*,b*,d*,h*,i*,m*,p*,s*,x*},g*,hardened-*,n*,x*}
313 mv -f /etc/gconf /usr/livecd
314 ln -sf /usr/livecd/gconf /etc/gconf
315 mv -f /var/db /usr/livecd
316 ln -sf /usr/livecd/db /var/db
319 rm -f /var/log/lastlog && touch /var/log/lastlog
321 # Create our Handbook icon
322 [ -e /docs/handbook/index.html ] && create_handbook_icon
323 [ -n "${clst_livecd_overlay}" ] && [ -e ${clst_livecd_overlay}/docs/handbook/index.html ] && create_handbook_icon
325 # Copy our icons into place and build home directories
326 if [ -n "${clst_livecd_users}" ]
328 for username in ${clst_livecd_users}
330 mkdir -p /home/${username}/Desktop
331 # Copy our Handbook icon
332 [ -e /usr/share/applications/gentoo-handbook.desktop ] && \
333 cp -f /usr/share/applications/gentoo-handbook.desktop \
334 /home/${username}/Desktop
335 # Copy our installer icons
336 if [ -e /usr/share/applications/installer-gtk.desktop ]
338 cp -f /usr/share/applications/installer-gtk.desktop \
339 /home/${username}/Desktop
340 cp -f /usr/share/applications/installer-dialog.desktop \
341 /home/${username}/Desktop
343 's:Exec=installer-dialog:Exec=sudo installer-dialog:' \
344 /home/${username}/Desktop/installer-dialog.desktop
345 sed -i -e 's:Exec=installer-gtk:Exec=installer:' \
346 /home/${username}/Desktop/installer-gtk.desktop
348 chown -R ${username}:100 /home/${username}
353 # This is my hack to reduce tmpfs usage
358 mv -f /etc/gconf /usr/livecd
359 ln -sf /usr/livecd/gconf /etc/gconf
362 if [ -e /usr/livecd/kernelpkgs.txt ]
364 rm -f /usr/livecd/kernelpkgs.txt
370 if [ -e /usr/livecd/kernelpkgs.txt ]
372 rm -f /usr/livecd/kernelpkgs.txt
377 # We want the first user to be used when auto-starting X
378 if [ -e /etc/startx ]
381 "s:##STARTX:source /etc/profile && su - ${first_user} -c startx:" \
385 if [ -e /lib/rcscripts/addons/udev-start.sh ]
387 sed -i "s:\t\[\[ -x /sbin/evms_activate:\t\[\[ -x \${CDBOOT} \]\] \&\& \[\[ -x /sbin/evms_activate:" /lib/rcscripts/addons/udev-start.sh