summaryrefslogtreecommitdiff
path: root/app-misc/rogentoslive-tools/files/1.0/rogentoslive
blob: 4a65b73e997d8c4d565fcef34eb6636ae4d968ff (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
#!/sbin/runscript
# Copyright 2004-2009 Fabio Erculiani
# Distributed under the terms of the GNU General Public License v2 

. /sbin/rogentos-functions.sh

depend() {
	after x-setup
	before hald
	before xdm
}

prepare_fluxbox_locked_autologin() {

	# change default wm to fluxbox
	echo "[Desktop]" > /home/${LIVE_USER}/.dmrc
	echo "Session=fluxbox" >> /home/${LIVE_USER}/.dmrc
	chown ${LIVE_USER} /home/${LIVE_USER}/.dmrc
	# Change passwords for security
	echo root:\`pwgen -s 16\` | chpasswd  > /dev/null 2>&1
	echo ${LIVE_USER}:\`pwgen -s 16\` | chpasswd  > /dev/null 2>&1

}

my_setup_desktop() {

	# create LIVE_USER if it does not exist
	sabayon_setup_live_user "${LIVE_USER}" "1000"
	if [ "${?}" = "1" ]; then
		# if user is already available, then setup skel
		# Copy ${LIVE_USER} directory
		rm -rf /home/${LIVE_USER}
		cp /etc/skel /home/${LIVE_USER} -Rp
		chown ${LIVE_USER}:users /home/${LIVE_USER} -R
	fi

	liveinst_desktop="/usr/share/applications/liveinst.desktop"
	liveinst_desktop_name="$(basename ${liveinst_desktop})"
	if [ -f "${liveinst_desktop}" ]; then
		[[ -d "/home/${LIVE_USER}/Desktop" ]] || mkdir -p /home/${LIVE_USER}/Desktop 
		cp "${liveinst_desktop}" /home/${LIVE_USER}/Desktop
		chown ${LIVE_USER}:users /home/${LIVE_USER}/Desktop -R
		chmod +x /home/${LIVE_USER}/Desktop/${liveinst_desktop_name}
		rm -f /etc/skel/Desktop/Anaconda*.desktop
		rm -f /home/${LIVE_USER}/Desktop/Anaconda*.desktop
	fi

	# Disable memory eating services
	rm -f /etc/xdg/autostart/hplip-systray.desktop
	rm -f /etc/xdg/autostart/beagle-search-autostart.desktop
	rm -f /etc/xdg/autostart/tracker*.desktop
	rm -f /etc/xdg/autostart/magneto.desktop
	rm -f /etc/xdg/autostart/beagled-autostart.desktop
	rm -f /usr/share/autostart/magneto.desktop
	rm -f /usr/share/autostart/nepomukserver.desktop

        # Remove broken entries in /etc/mtab
        sed -i '/.*newroot.*/d' /etc/mtab

	# Create /media for removable devices
	if [ ! -d /media ]; then
		mkdir /media
		chmod 755 /media
	fi

	# Add sudo to gparted exec=
	gparted_file="/home/${LIVE_USER}/Desktop/gparted.desktop"
	if [ -f "${gparted_file}" ]; then
		sed -i 's/Exec=/Exec=sudo /' "${gparted_file}"
	fi

	# create /overlay, this way df -h won't bitch
	[[ -d "/overlay" ]] || mkdir /overlay

}

my_setup_password() {

	cmdline_autoscramble_exist=$(cat /proc/cmdline | grep autoscramble)
	if [ -n "$cmdline_autoscramble_exist" ]; then
		echo
		echo -e "\E[33;36m * \E[0m\E[01;36m Autoscrambling root passwords for   S E C U R I T Y"
		echo root:\`pwgen -s 16\` | chpasswd  > /dev/null 2>&1
		echo ${LIVE_USER}:\`pwgen -s 16\` | chpasswd  > /dev/null 2>&1
		echo
	fi

}

my_setup_keymap() {

	# Check if KEYMAP is forced by cmdline
	cmdline_keymap_exist=$(cat /proc/cmdline | grep -i "KEYMAP=")
	cmdline_keymap_isolinux_exist=$(cat /proc/cmdline | grep -i "console-setup/layoutcode=")

	if [ -n "$cmdline_keymap_isolinux_exist" ]; then
		cmdline_keymap_exist="console-setup"
	fi

        if [ -n "$cmdline_keymap_exist" ];then

		if [ "$cmdline_keymap_exist" == "console-setup" ]; then
			# detect keymap
			for word in `cat /proc/cmdline` ; do
				case $word in
					console-setup/layoutcode=*)
					keymap_toset=$(echo $word | cut -d "=" -f 2)
					;;
					console-setup/modelcode=*)
					keymap_toset_model="-$(echo $word | cut -d "=" -f 2)"
					;;
				esac
			done
		else

			# detect keymap
			for word in `cat /proc/cmdline` ; do
				case $word in
					KEYMAP=*)
					keymap_toset=$(echo $word | cut -d "=" -f 2)
					;;
					keymap=*)
					keymap_toset=$(echo $word | cut -d "=" -f 2)
					;;
				esac
			done

		fi

		if [ -n "$keymap_toset" ]; then
			aggregated_keymap="${keymap_toset}${keymap_toset_model}"
			/sbin/keyboard-setup-2 ${aggregated_keymap} all &> /dev/null
			if [ "${?}" = "0" ]; then
				/etc/init.d/keymaps restart --nodeps
			fi
		fi
	
	fi

}

my_wait_opengl_config() {

	echo -en "\E[33;36m * \E[0m \E[01;32m Waiting for Graphical Configurator to finish... \E[0m"
	while [ -e "/etc/x-setup-configuration-running" ]
           do
	      # waiting...
	      sleep 1
	   done
	echo -e "Done"

}

my_setup_locale() {

        cmdline_lang_exist=$(cat /proc/cmdline | grep -i "lang=")
        cmdline_locale_exist=$(cat /proc/cmdline | grep -i "locale=")

	if [ -n "$cmdline_locale_exist" ]; then
		cmdline_lang_exist="locale-setup"
	fi

        if [ -n "$cmdline_lang_exist" ];then

		if [ "$cmdline_lang_exist" == "locale-setup" ]; then
			# detect keymap
			for word in `cat /proc/cmdline` ; do
				case $word in
					locale=*)
					lang_toset=$(echo $word | cut -d "=" -f 2)
					;;
				esac
			done
		else
			for word in `cat /proc/cmdline` ; do
				case $word in
					LANG=*)
					lang_toset=$(echo $word | cut -d "=" -f 2)
					;;
					lang=*)
					lang_toset=$(echo $word | cut -d "=" -f 2)
					;;
				esac
			done
		fi
		
		# Setup Language
		if [ -n "$lang_toset" ]; then
			/sbin/language-setup $lang_toset &> /dev/null
		fi

        fi

}

start() {

	# Perform configuration only in live mode
	if ! sabayon_is_live; then
		einfo "Skipping live mode configuration"
		return 0
	fi

	my_setup_desktop
	my_setup_password
	my_setup_keymap
	my_wait_opengl_config
	# MOVED HERE TO AVOID RACE CONDITIONS ON WRITING /etc/profile.env variables
	# Check if LANG is forced by cmdline
	my_setup_locale
	# setup autologin for all the supported Login managers
	sabayon_setup_autologin
	# override autostart stuff if required:
	sabayon_setup_motd
	sabayon_setup_vt_autologin
	sabayon_setup_oem_livecd

}