summaryrefslogtreecommitdiff
blob: eebca5a18a055d183e77a3b49186d1c7d219b443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo/src/catalyst/livecd/runscript-support/Attic/livecdfs-update.sh,v 1.35.2.17 2005/07/07 14:25:58 rocket Exp $

/usr/sbin/env-update
source /etc/profile

# allow root logins to the livecd by default
if [ -e /etc/sshd/sshd_config ]
then
	sed -i 's:^#PermitRootLogin\ yes:PermitRootLogin\ yes:' /etc/ssh/sshd_config
fi

# turn off udev tarball
sed -i 's:RC_DEVICE_TARBALL="yes":RC_DEVICE_TARBALL="no":' /etc/conf.d/rc

# turn bashlogin shells to actual login shells
sed -i 's:exec -l /bin/bash:exec -l /bin/bash -l:' /bin/bashlogin

# default programs that we always want to start
rc-update del iptables default
rc-update del netmount default
rc-update add autoconfig default
rc-update del keymaps
rc-update del serial
rc-update del consolefont
rc-update add modules default
rc-update add pwgen default
[ -e /etc/init.d/bootsplash ] && rc-update add bootsplash default
[ -e /etc/init.d/splash ] && rc-update add splash default
[ -e /etc/init.d/sysklogd ] && rc-update add sysklogd default
[ -e /etc/init.d/metalog ] && rc-update add metalog default
[ -e /etc/init.d/syslog-ng ] && rc-update add syslog-ng default
[ -e /etc/init.d/alsasound ] && rc-update add alsasound default

# perform any rcadd then any rcdel
if [ -n "${clst_livecd_rcadd}" ] || [ -n "${clst_livecd_rcdel}" ]
then
	if [ -n "${clst_livecd_rcadd}" ]
	then
		for x in ${clst_livecd_rcadd}
		do
			rc-update add "${x%%|*}" "${x##*|}"
		done
	fi
	
	if [ -n "${clst_livecd_rcdel}" ]
	then
		for x in ${clst_livecd_rcdel}
		do
			rc-update del "${x%%|*}" "${x##*|}"
		done
	fi
fi

# clean up the time and set to UTC
rm -f /etc/localtime
cp /usr/share/zoneinfo/UTC /etc/localtime

# setup the hostname
echo 'HOSTNAME="livecd"' > /etc/conf.d/hostname
echo 'OVERRIDE=0' > /etc/conf.d/domainname
echo 'DNSDOMAIN="gentoo"' >> /etc/conf.d/domainname
echo "127.0.0.1	livecd.gentoo livecd localhost" > /etc/hosts

# Add any users
if [ -n "${clst_livecd_users}" ]
then
	for x in ${clst_livecd_users}
	do
		useradd -G users,wheel,audio,games,cdrom,usb -c "Default LiveCD User" -m $x
	done
fi

# setup sudoers
[ -e /etc/sudoers ] && sed -i '/NOPASSWD: ALL/ s/^# //' /etc/sudoers

# we want the first user to be used when auto-starting X
if [ -n "${clst_livecd_users}" -a -e /etc/startx ]
then
	first_user=$(echo ${clst_livecd_users} | cut -d' ' -f1)
	sed -i "s/startx/su - $first_user -c startx/" /root/.bashrc
fi

# setup dhcp on all detected ethernet devices
echo "iface_eth0=\"dhcp\""> /etc/conf.d/net
echo "iface_eth1=\"dhcp\"" >> /etc/conf.d/net
echo "iface_eth2=\"dhcp\"" >> /etc/conf.d/net
echo "iface_eth3=\"dhcp\"" >> /etc/conf.d/net
echo "iface_eth4=\"dhcp\"" >> /etc/conf.d/net

# setup links for ethernet devices
cd /etc/init.d
ln -sf net.eth0 net.eth1
ln -sf net.eth0 net.eth2
ln -sf net.eth0 net.eth3
ln -sf net.eth0 net.eth4

# add this for hwsetup/mkx86config
mkdir -p /etc/sysconfig

# fstab tweaks
echo "tmpfs	/					tmpfs	defaults	0 0" > /etc/fstab
echo "tmpfs	/lib/firmware			tmpfs	defaults	0 0" >> /etc/fstab
echo "tmpfs /usr/portage			tmpfs	defaults	0 0" >> /etc/fstab
# if /usr/lib/X11/xkb/compiled then make it tmpfs
if [ -d /usr/lib/X11/xkb/compiled ]
then
	echo "tmpfs	/usr/lib/X11/xkb/compiled	tmpfs	defaults	0 0" >> /etc/fstab
fi

# devfs tweaks
sed -i '/dev-state/ s:^:#:' /etc/devfsd.conf

# tweak the livecd fstab so that users know not to edit it
# http://bugs.gentoo.org/show_bug.cgi?id=60887
mv /etc/fstab /etc/fstab.old
echo "####################################################" >> /etc/fstab
echo "## ATTENTION: THIS IS THE FSTAB ON THE LIVECD     ##" >> /etc/fstab     
echo "## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##" >> /etc/fstab     
echo "####################################################" >> /etc/fstab
cat /etc/fstab.old >> /etc/fstab
rm /etc/fstab.old

# add some helpful aliases
echo "alias cp='cp -i'" >> /etc/profile
echo "alias mv='mv -i'" >> /etc/profile
echo "alias rm='rm -i'" >> /etc/profile
echo "alias ls='ls --color=auto'" >> /etc/profile
echo "alias grep='grep --color=auto'" >> /etc/profile

# make sure we have the latest pci and hotplug ids
[ -x /sbin/update-pciids ] && /sbin/update-pciids
if [ -d /usr/share/hwdata ]
then
	[ -f /usr/share/hwdata/pci.ids ] && rm -f /usr/share/hwdata/pci.ids
	[ -f /usr/share/hwdata/usb.ids ] && rm -f /usr/share/hwdata/usb.ids
	ln -s /usr/share/misc/pci.ids /usr/share/hwdata/pci.ids
	ln -s /usr/share/misc/usb.ids /usr/share/hwdata/usb.ids
fi

# setup opengl in /etc (if configured)
[ -x /usr/sbin/openglify ] && /usr/sbin/openglify

# touch /etc/asound.state
touch /etc/asound.state

# tweak the motd for gentoo releases 
if [ "${clst_livecd_type}" = "gentoo-release-universal" ]
then
	cat /etc/generic.motd.txt /etc/universal.motd.txt \
		/etc/minimal.motd.txt > /etc/motd
	sed -i 's:^##GREETING:Welcome to the Gentoo Linux Universal Installation CD!:' /etc/motd
fi

if [ "${clst_livecd_type}" = "gentoo-release-minimal" ]
then
	cat /etc/generic.motd.txt /etc/minimal.motd.txt > /etc/motd
	sed -i 's:^##GREETING:Welcome to the Gentoo Linux Minimal Installation CD!:' /etc/motd
fi

if [ "${clst_livecd_type}" = "gentoo-release-livecd" ]
then
	cat /etc/generic.motd.txt /etc/universal.motd.txt \
		/etc/minimal.motd.txt /etc/livecd.motd.txt > /etc/motd
	sed -i 's:^##GREETING:Welcome to the Gentoo Linux LiveCD!:' /etc/motd
fi

if [ "${clst_livecd_type}" = "gentoo-gamecd" ]
then
	cat /etc/generic.motd.txt /etc/gamecd.motd.txt > /etc/motd
	sed -i 's:^##GREETING:Welcome to the Gentoo Linux ##GAME_NAME GameCD!:' /etc/motd
fi

rm -f /etc/generic.motd.txt /etc/universal.motd.txt /etc/minimal.motd.txt /etc/livecd.motd.txt /etc/gamecd.motd.txt

# setup splash/bootsplash (if called for)
if [ "${clst_livecd_splash_type}" = "bootsplash" -a -n "${clst_livecd_splash_theme}" ]
then
	if [ -d /etc/bootsplash/${clst_livecd_splash_theme} ]
	then
		sed -i 's:BOOTSPLASH_THEME=\"gentoo\":BOOTSPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/bootsplash
		rm /etc/bootsplash/default
		ln -s "/etc/bootsplash/${clst_livecd_splash_theme}" /etc/bootsplash/default
	else
		echo "Error, cannot setup bootsplash theme ${clst_livecd_splash_theme}"
		exit 1
	fi

elif [ "${clst_livecd_splash_type}" = "gensplash" -a -n "${clst_livecd_splash_theme}" ]
then
	if [ -d /etc/splash/${clst_livecd_splash_theme} ]
	then
		sed -i 's:# SPLASH_THEME="gentoo":SPLASH_THEME=\"${clst_livecd_splash_theme}\":' /etc/conf.d/splash
		rm /etc/splash/default
		ln -s /etc/splash/${clst_livecd_splash_theme} /etc/splash/default
	else
		echo "Error, cannot setup splash theme ${clst_livecd_splash_theme}"
		exit 1
	fi
fi

# Create firmware directory if it does not exist
[ ! -d /lib/firmware ] && mkdir -p /lib/firmware

# tar up the firmware so that it does not get clobbered by the livecd mounts
if [ -n "$(ls /lib/firmware)" ]
then
	cd /lib/firmware
	if [ -n "$(ls /usr/lib/hotplug/firmware)" ]
	then
		cp /usr/lib/hotplug/firmware/* /lib/firmware
	fi
	/bin/tar cjpf /lib/firmware.tar.bz2 .
	rm -f /lib/firmware/*
	mkdir -p /usr/lib/hotplug
	rm -rf /usr/lib/hotplug/firmware
	ln -sf /lib/firmware /usr/lib/hotplug/firmware
fi