This repository has been archived by the owner on Oct 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rc.salt
251 lines (250 loc) · 10.4 KB
/
rc.salt
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/bin/sh
# vim: set syn=sh ft=sh et sw=2 sts=2 ts=2 tw=0:
#
# This file is part of SaLT.
# Copyright: Cyrille Pontvieux <[email protected]>
# Licence: GPLv3+
# Version: 0.2.2
# Script to tweak the target Slackware distro
[ -e /mnt/salt/lib/libSaLT ] || exit 1
. /mnt/salt/lib/libSaLT
echoinfo '+-------------------------------------+'
echoinfo '| Starting SaLT Live configuration... |'
echoinfo '+-------------------------------------+'
LIBSUFFIX=
[ -d /usr/lib64 ] && LIBSUFFIX=64
lang=$(get_value_cmdline lang)
if [ -n "$lang" ]; then
if [ -x /usr/sbin/localesetup ]; then
/usr/sbin/localesetup $lang # Salix
elif [ -e /etc/profile.d ]; then
if [ -f /etc/profile.d/lang.sh ]; then
grep -q -i '^ *export LANG=' /etc/profile.d/lang.sh
if [ $? -eq 0 ]; then
sed -i "s/^ *\(export LANG=\).*$/\1$lang/" /etc/profile.d/lang.sh
else
echo "export LANG=$lang" >> /etc/profile.d/lang.sh
fi
fi
if [ -f /etc/profile.d/lang.csh ]; then
grep -q -i '^ *setenv LANG ' /etc/profile.d/lang.csh
if [ $? -eq 0 ]; then
sed -i "s/^ *\(setenv LANG \).*$/\1$lang/" /etc/profile.d/lang.csh
else
echo "setenv LANG $lang" >> /etc/profile.d/lang.csh
fi
fi
if [ -f /etc/kde/kdm/kdmrc ]; then
locale_noutf8=$(echo $lang | sed 's/\.utf8//')
sed -i "s/\(^\|^#\)Language=.*/Language=$locale_noutf8/" /etc/kde/kdm/kdmrc
fi
fi
if [ -e /etc/profile.d/lang.sh ]; then
. /etc/profile.d/lang.sh
fi
# Make firefox match OS locale
# Now included in Salix version, but keep it for other Slackware version or distro
if [ -w /usr/lib$LIBSUFFIX/firefox/greprefs/all.js ]; then
sed -i -e 's/pref("intl.locale.matchOS", false);/pref("intl.locale.matchOS", true);/g' /usr/lib$LIBSUFFIX/firefox/greprefs/all.js
fi
# Make thunderbird match OS locale
# Now included in Salix version, but keep it for other Slackware version or distro
if [ -w /usr/lib$LIBSUFFIX/thunderbird/greprefs/all.js ]; then
sed -i -e 's/pref("intl.locale.matchOS", false);/pref("intl.locale.matchOS", true);/g' /usr/lib$LIBSUFFIX/thunderbird/greprefs/all.js
fi
fi
restart_hal=no
synaptics=$(get_value_cmdline synaptics)
if [ "$synaptics" = "on" ]; then
if [ ! -e /etc/hal/fdi/policy/11-x11-synaptics.fdi ]; then
if [ -e /usr/share/hal/fdi/policy/10osvendor/11-x11-synaptics.fdi ]; then
mkdir -p /etc/hal/fdi/policy
cp /usr/share/hal/fdi/policy/10osvendor/11-x11-synaptics.fdi /etc/hal/fdi/policy/
restart_hal=yes
fi
fi
elif [ "$synaptics" = "off" ]; then
if [ -e /etc/hal/fdi/policy/11-x11-synaptics.fdi ]; then
rm -f /etc/hal/fdi/policy/11-x11-synaptics.fdi
restart_hal=yes
fi
fi
keyb=$(get_value_cmdline keyb)
numlock=$(get_value_cmdline numlock)
scim=$(get_value_cmdline scim)
ibus=$(get_value_cmdline ibus)
if [ -n "$keyb" ] || [-n "$numlock" ] || [ -n "$scim" ] || [ -n "$ibus" ]; then
# keyboard settting
[ -n "$keyb" ] || keyb=us
[ -n "$numlock" ] || numlock=off
[ -n "$scim" ] || scim=off
[ -n "$ibus" ] || ibus=off
if [ -x /usr/sbin/keyboardsetup ]; then # Salix
/usr/sbin/keyboardsetup -k $keyb -n $numlock -s $scim -i $ibus
restart_hal=no
else
grep "^$keyb|.*|.*|.*" /mnt/salt/lib/keymaps | sed -e "s/^.*|\(.*\)|\(.*\)|\(.*\)/\1|\2|\3/" > /tmp/xkb
xkblayout="$(sed -e "s/^\(.*\)|.*|.*/\1/" /tmp/xkb)"
xkbvariant="$(sed -e "s/^.*|\(.*\)|.*/\1/" /tmp/xkb)"
xkboptions="$(sed -e "s/^.*|.*|\(.*\)/\1/" /tmp/xkb)"
rm /tmp/xkb
# Fall back to keymap if no xkb maping available
if [ -z "$xkblayout" ]; then
xkblayout="$keyb"
xkbvariant=""
xkboptions=""
fi
/usr/bin/loadkeys -u $keyb.map 1>&2 2>/dev/null
if [ -e /etc/rc.d/rc.keymap ]; then
sed -i "s/\(^[ \t]*\/usr\/bin\/loadkeys -u\).*$/\1 $keyb.map/" /etc/rc.d/rc.keymap
fi
if [ -e /etc/X11/xorg.conf.d ]; then
cat <<EOF > /etc/X11/xorg.conf.d/10-keymap.conf
Section "InputClass"
Identifier "Keyboard settings"
MatchIsKeyboard "yes"
Driver "evdev"
Option "XkbLayout" "$xkblayout"
Option "XkbVariant" "$xkbvariant"
Option "XkbOptions" "$xkboptions"
EndSection
EOF
elif [ -e /usr/share/hal/fdi/policy/10osvendor/10-keymap.fdi ]; then
if [ ! -e /etc/hal/fdi/policy/10-keymap.fdi ]; then
mkdir -p /etc/hal/fdi/policy
cp -f /usr/share/hal/fdi/policy/10osvendor/10-keymap.fdi /etc/hal/fdi/policy/10-keymap.fdi
fi
if [ -e /etc/hal/fdi/policy/10-keymap.fdi ]; then
sed -i "s/\"input.xkb.layout\" type=\"string\">.*</\"input.xkb.layout\" type=\"string\">"$xkblayout"</;
s|\(<merge key=\"input.xkb.variant\" type=\"string\"\).*|\1>"$xkbvariant"</merge>|;
s/\"input.xkb.options\" type=\"string\">.*</\"input.xkb.options\" type=\"string\">"$xkboptions"</" /etc/hal/fdi/policy/10-keymap.fdi
fi
fi
if [ "$numlock" = "on" ]; then
[ -e /etc/rc.d/rc.numlock ] && chmod 755 /etc/rc.d/rc.numlock
for t in 1 2 3 4 5 6 7 8; do setleds +num < /dev/tty$t > /dev/null; done
if [ -f /etc/lxdm/lxdm.conf ]; then
sed -i "/numlock/d; s/\[base\]/\[base\]\nnumlock=1/" /etc/lxdm/lxdm.conf
fi
if [ -f /etc/kde/kdm/kdmrc ]; then
if [ `grep "\(^\|#\)NumLock=" /etc/kde/kdm/kdmrc` ]; then
sed -i "s/\(^\|#\)NumLock=.*/NumLock=On/" /etc/kde/kdm/kdmrc
else
sed -i "s/\[X-\*-Greeter\]/\[X-\*-Greeter\]\nNumLock=On/" /etc/kde/kdm/kdmrc
fi
fi
else
[ -e /etc/rc.d/rc.numlock ] && chmod 644 /etc/rc.d/rc.numlock
for t in 1 2 3 4 5 6 7 8; do setleds -num < /dev/tty$t > /dev/null; done
if [ -f /etc/lxdm/lxdm.conf ]; then
sed -i "/numlock/d; s/\[base\]/\[base\]\nnumlock=0/" /etc/lxdm/lxdm.conf
fi
if [ -f /etc/kde/kdm/kdmrc ]; then
if [ `grep "\(^\|#\)NumLock=" /etc/kde/kdm/kdmrc` ]; then
sed -i "s/\(^\|#\)NumLock=.*/NumLock=Off/" /etc/kde/kdm/kdmrc
else
sed -i "s/\[X-\*-Greeter\]/\[X-\*-Greeter\]\nNumLock=Off/" /etc/kde/kdm/kdmrc
fi
fi
fi
if [ "$scim" = "on" ]; then
[ -f /etc/profile.d/scim.sh ] && chmod +x /etc/profile.d/scim.sh
[ -f /etc/profile.d/scim.csh ] && chmod +x /etc/profile.d/scim.csh
else
[ -f /etc/profile.d/scim.sh ] && chmod -x /etc/profile.d/scim.sh
[ -f /etc/profile.d/scim.csh ] && chmod -x /etc/profile.d/scim.csh
fi
if [ "$ibus" = "on" ]; then
[ -f /etc/profile.d/ibus.sh ] && chmod +x /etc/profile.d/ibus.sh
[ -f /etc/profile.d/ibus.csh ] && chmod +x /etc/profile.d/ibus.csh
else
[ -f /etc/profile.d/ibus.sh ] && chmod -x /etc/profile.d/ibus.sh
[ -f /etc/profile.d/ibus.csh ] && chmod -x /etc/profile.d/ibus.csh
fi
restart_hal=yes
fi
fi
[ "$restart_hal" = "yes" ] && /etc/rc.d/rc.hald restart
passwd=$(get_value_cmdline passwd)
if [ -n "$passwd" ]; then
# root password
if [ "$passwd" = "ask" ]; then
echo -ne "\nEnter new password for root: "
read -s passwd
echo
fi
if [ -n "$passwd" ]; then
echo "root:$passwd" | /usr/sbin/chpasswd
fi
fi
if is_on_cmdline nosound; then
echoinfo 'Muting sound volume'
for SCONTROL in Master PCM Front Surround Center CD Video Wave Music AC97 Headphone; do
/usr/bin/amixer -q sset $SCONTROL 0 mute 2>/dev/null
done
else
if [ -r /etc/asound.state ]; then
/usr/sbin/alsactl restore
else
echoinfo 'Setting sound volume to 71%'
for SCONTROL in Master PCM Front Surround Center CD Video Wave Music AC97 Headphone; do
/usr/bin/amixer -q sset $SCONTROL 71% unmute 2>/dev/null
done
fi
fi
if is_on_cmdline autologin; then
[ -e /etc/gdm/custom.conf ] && sed -i 's/AutomaticLoginEnable=.*/AutomaticLoginEnable=true/' /etc/gdm/custom.conf
[ -e /etc/kde/kdm/kdmrc ] && sed -i 's/AutoLoginEnable=.*/AutoLoginEnable=true/' /etc/kde/kdm/kdmrc
else
[ -e /etc/gdm/custom.conf ] && sed -i 's/AutomaticLoginEnable=.*/AutomaticLoginEnable=false/' /etc/gdm/custom.conf
[ -e /etc/kde/kdm/kdmrc ] && sed -i 's/AutoLoginEnable=.*/AutoLoginEnable=false/' /etc/kde/kdm/kdmrc
fi
proxy=$(get_value_cmdline proxy)
if [ -n "$proxy" ]; then
# set http and ftp proxy (same for both)
cat <<EOF > /etc/profile.d/proxy.sh
#!/bin/sh
export http_proxy=$proxy
export ftp_proxy=$http_proxy
EOF
chmod +x /etc/profile.d/proxy.sh
/etc/profile.d/proxy.sh
phost=$(echo $proxy| sed 's,\(.*://\)\?\([^:]*\)\(:[0-9]*\)\?,\2,')
pport=$(echo $proxy| sed 's,\(.*://\)\?\([^:]*\)\(:[0-9]*\)\?,\3,')
which gconftool-2 >/dev/null 2>&1
if [ $? -eq 0 ] && [ -d /etc/gconf ]; then
[ -z "$pport" ] && pport=3128
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/http_proxy/host $phost
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/ftp_proxy/host $phost
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/http_proxy/port $pport
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/ftp_proxy/port $pport
fi
ffpreffile=$('ls' -1 /usr/lib$LIBSUFFIX/firefox-*/defaults/pref/all*.js 2>/dev/null)
if [ -n "$ffpreffile" ]; then
cat <<EOF > $ffpreffile
pref("network.proxy.type", 1);
pref("network.proxy.http", "$phost");
pref("network.proxy.http_port", $pport);
pref("network.proxy.ftp", "$phost");
pref("network.proxy.ftp_port", "$pport");
pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1");
EOF
fi
else
[ -e /etc/profile.d/proxy.sh ] && rm -f /etc/profile.d/proxy.sh
unset http_proxy ftp_proxy
which gconftool-2 >/dev/null 2>&1
if [ $? -eq 0 ] && [ -e /etc/gconf/gconf.xml.mandatory/system/http_proxy/\%gconf.xml ]; then
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --unset /system/http_proxy/host
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --unset /system/ftp_proxy/host
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --unset /system/http_proxy/port
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --unset /system/ftp_proxy/port
fi
ffpreffile=$('ls' -1 /usr/lib$LIBSUFFIX/firefox-*/defaults/pref/all*.js 2>/dev/null)
if [ -n "$ffpreffile" ]; then
sed -i '/proxy/d' $ffpreffile
fi
fi
echoinfo '+---------------------------------+'
echoinfo '| SaLT Live configuration applied |'
echoinfo '+---------------------------------+'