cgit: Added cgit 0.7.3-c502865 - A CGI for git written in C
[opensde-package-nopast.git] / base / stone / stone_mod_general.sh
blob53b45a6124f8eb6af081293139c9bba5fed30a02
1 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # Filename: package/.../stone/stone_mod_general.sh
5 # Copyright (C) 2004 - 2006 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 Clifford Wolf
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
16 # [MAIN] 10 general,main Various general system configurations
17 # [SETUP] 10 general set_tmarea
18 # [SETUP] 15 general set_dtime
19 # [SETUP] 20 general set_locale
20 # # [SETUP] 30 general set_vcfont
22 set_keymap() {
23 keymap=$(ls -l /etc/default.keymap 2> /dev/null | sed 's,.*/,,')
24 [ -z "$keymap" ] && keymap="none" ; keymap="${keymap%.map.gz}"
26 # ReneR: Attention: althought this reads i386, this is nowadays valid
27 # for all (? - at least also on PowerPC where this was a long ugly
28 # bug in ROCK times) - the input layer does pass "unified" events ...
29 mapdir="`echo /usr/share/kbd/keymaps/i386`"
31 cmd="gui_menu 'general_keymap' 'Select one of the following keyboard mappings.'"
32 if [ "$keymap" != none ]; then
33 cmd="$cmd 'Current: $keymap' 'loadkeys defkeymap'"
35 cmd="$cmd 'none (kernel defaults)' 'rm -f /etc/default.keymap ; loadkeys defkeymap'"
37 cmd="$cmd $( find $mapdir -type f ! -path '*/include/*' -name '*.map.gz' -printf '%P\n' | sed 's,\(.*\)/\(.*\).map.gz$,"\2 (\1)" "ln -sf '$mapdir'/& /etc/default.keymap ; loadkeys \2",' | expand -t30 | sort | tr '\n' ' ')"
39 eval "$cmd"
42 set_vcfont() {
43 vcfont=$(ls -l /etc/default.vcfont 2> /dev/null | sed 's,.*/,,')
44 if [ -z "$vcfont" ] ; then vcfont="none"
45 else vcfont="`echo $vcfont | sed -e "s,\.\(fnt\|psf.*\)\.gz$,,"`" ; fi
46 fontdir="/usr/share/kbd/consolefonts"
48 cmd="gui_menu 'general_vcfont' 'Select one of the following console fonts.'"
49 if [ "$vcfont" != none ]; then
50 cmd="$cmd 'Current: $vcfont' 'setfont'"
52 cmd="$cmd 'none (kernel defaults)' 'rm -f /etc/default.vcfont ; setfont'"
54 cmd="$cmd $( find $fontdir -type f \( -name '*.fnt.gz' -or -name '*.psf*.gz' \) -printf '%P\n' | sed 's,\(.*\).\(fnt\|psf.*\)\.gz$,"\1" "ln -sf '$fontdir'/& /etc/default.vcfont ; setfont \1",' | expand -t30 | sort | tr '\n' ' ')"
56 eval "$cmd"
59 store_kbd(){
60 if [ -f /etc/conf/kbd ] ; then
61 sed -e "s/kbd_rate=.*/kbd_rate=$kbd_rate/" \
62 -e "s/kbd_delay=.*/kbd_delay=$kbd_delay/" < /etc/conf/kbd \
63 > /etc/conf/kbd.tmp
64 grep -q kbd_rate= /etc/conf/kbd.tmp || echo kbd_rate=$kbd_rate \
65 >> /etc/conf/kbd.tmp
66 grep -q kbd_delay= /etc/conf/kbd.tmp || echo kbd_delay=$kbd_delay \
67 >> /etc/conf/kbd.tmp
68 mv /etc/conf/kbd.tmp /etc/conf/kbd
69 else
70 echo -e "kbd_rate=$kbd_rate\nkbd_delay=$kbd_delay\n" \
71 > /etc/conf/kbd
73 [ "$kbd_rate" -a "$kbd_delay" ] && kbdrate -r $kbd_rate -d $kbd_delay
76 set_kbd_rate() {
77 gui_input "Set new console keyboard auto-repeat rate" \
78 "$kbd_rate" "kbd_rate"
79 store_kbd
82 set_kbd_delay() {
83 gui_input "Set new console keyboard auto-repeat delay" \
84 "$kbd_delay" "kbd_delay"
85 store_kbd
88 store_con(){
89 if [ -f /etc/conf/console ] ; then
90 sed -e "s/con_term=.*/con_term=$con_term/" \
91 -e "s/con_blank=.*/con_blank=$con_blank/" \
92 < /etc/conf/console > /etc/conf/console.tmp
93 grep -q con_term= /etc/conf/console.tmp || \
94 echo con_term=$con_term >> /etc/conf/console.tmp
95 grep -q con_blank= /etc/conf/console.tmp || \
96 echo con_blank=$con_blank >> /etc/conf/console.tmp
97 mv /etc/conf/console.tmp /etc/conf/console
98 else
99 echo -e "con_term=$con_term\ncon_blank=$con_blank\n" \
100 > /etc/conf/console
102 [ "$con_term" -a "$con_blank" ] && \
103 setterm -term $con_term -blank $con_blank > /dev/console
106 set_con_term() {
107 gui_input "Set new console screen terminal type" \
108 "$con_term" "con_term"
109 store_con
112 set_con_blank() {
113 gui_input "Set new console screen blank interval" \
114 "$con_blank" "con_blank"
115 store_con
118 set_tmzone() {
119 tz="$( ls -l /etc/localtime | cut -f8 -d/ )"
120 cmd="gui_menu 'general_tmzone' 'Select one of the following time zones.'"
122 if [ -n "$tz" -a -f ../usr/share/zoneinfo/$1/$tz ]; then
123 cmd="$cmd 'Current: $tz' 'ln -sf ../usr/share/zoneinfo/$1/$tz \
124 /etc/localtime'"
126 cmd="$cmd $( grep "$1/" /usr/share/zoneinfo/zone.tab | cut -f3 | \
127 cut -f2 -d/ | sort -u | tr '\n' ' ' | sed 's,[^ ]\+,& '`
128 `'"ln -sf ../usr/share/zoneinfo/$1/& /etc/localtime",g' )"
130 eval "$cmd"
133 set_tmarea() {
134 tz="$( ls -l /etc/localtime | cut -f7 -d/ )"
135 cmd="gui_menu 'general_tmarea' 'Select one of the following time areas.'"
137 cmd="$cmd 'Current: $tz' 'if set_tmzone $tz ; then tzset=1 ; fi'"
138 cmd="$cmd $( grep '^[^#]' /usr/share/zoneinfo/zone.tab | cut -f3 | \
139 cut -f1 -d/ | sort -u | tr '\n' ' ' | sed 's,[^ ]\+,& '`
140 `'"if set_tmzone & ; then tzset=1 ; fi",g' )"
142 tzset=0
143 while eval "$cmd" && [ $tzset = 0 ] ; do : ; done
146 set_dtime() {
147 local set=0
148 while [ $set = 0 ]; do
149 dtime="`date '+%m-%d %H:%M %Y'`" ; newdtime="$dtime"
150 [ -f /etc/conf/clock ] && . /etc/conf/clock
151 [ "$clock_tz" != localtime ] && clock_tz=utc
152 gui_input "Set new date and time (MM-DD hh:mm YYYY, $clock_tz)" \
153 "$dtime" "newdtime"
154 if [ "$dtime" != "$newdtime" ] ; then
155 echo "Setting new date and time ($newdtime) ..."
156 if ! date "$( echo $newdtime | sed 's,[^0-9],,g' )"; then
157 gui_message "Error setting time, invalid timespec?"
158 else
159 set=1
161 hwclock --systohc --$clock_tz
162 else
163 set=1
165 done
168 set_locale_sub() {
169 rm -f /etc/profile.d/locale
170 [ "$1" != "none" ] && echo "export LANG='$1'" > /etc/profile.d/locale
173 set_locale() {
174 unset LANG ; [ -f /etc/profile.d/locale ] && . /etc/profile.d/locale
175 locale="${LANG:-none}" ; cmd="gui_menu 'general_locale' 'Select one of the following locales.'"
177 if [ "$locale" != none ]; then
178 title=$(grep ^title /usr/share/i18n/locales/$locale | sed \
179 -e 's,.*"\(.*\)".*,\1,g' -e "s,',´,g")
180 x="$( echo -e "Current: ${title:0:41}\t$locale" | expand -t52 )"
181 cmd="$cmd '$x' 'true'"
183 x="$( echo -e "none\tnone" | expand -t52 )"
184 cmd="$cmd '$x' 'set_locale_sub none'"
186 x="$( echo -e "POSIX\tC" | expand -t52 )"
187 cmd="$cmd '$x' 'set_locale_sub C' $(
188 grep -H ^title /usr/share/i18n/locales/* | sed \
189 -e 's,.*/\(.*\):.*"\(.*\)",\1\t\2,g' \
190 -e "s,',´,g" | while read key title; do
191 echo "'${title:0:50} $key' 'set_locale_sub $key'" | expand -t53 | tr '\n' ' '
192 done
195 eval "$cmd"
198 main() {
199 while
200 unset LANG ; [ -f /etc/profile.d/locale ] && . /etc/profile.d/locale
201 locale="${LANG:-none}" ; tz="$( ls -l /etc/localtime | cut -f7- -d/ )"
202 keymap=$(ls -l /etc/default.keymap 2> /dev/null | sed 's,.*/,,')
203 [ "$keymap" ] || keymap="none" ; keymap="${keymap%.map.gz}"
204 vcfont=$(ls -l /etc/default.vcfont 2> /dev/null | sed 's,.*/,,')
205 if [ -z "$vcfont" ] ; then vcfont="none"
206 else vcfont="`echo $vcfont | sed -e "s,\.\(fnt\|psf.*\)\.gz$,,"`" ; fi
207 dtime="`date '+%m-%d %H:%M %Y'`"
208 [ -f /etc/conf/kbd ] && . /etc/conf/kbd
209 [ "$kbd_rate" ] || kbd_rate=30
210 [ "$kbd_delay" ] || kbd_delay=250
211 [ -f /etc/conf/console ] && . /etc/conf/console
212 [ "$con_term" ] || con_term=linux
213 [ "$con_blank" ] || con_blank=0
215 gui_menu general 'Various general system configurations' \
216 "Set console keyboard mapping ....... $keymap" "set_keymap" \
217 "Set console screen font ............ $vcfont" "set_vcfont" \
218 "Set system-wide time zone .......... $tz" "set_tmarea" \
219 "Set date and time (utc/localtime) .. $dtime" "set_dtime" \
220 "Set system-wide locale (language) .. $locale" "set_locale" \
221 "Set console keyboard repeat rate ... $kbd_rate" "set_kbd_rate" \
222 "Set console keyboard repeat delay .. $kbd_delay" "set_kbd_delay" \
223 "Set console screen terminal type ... $con_term" "set_con_term" \
224 "Set console screen blank interval .. $con_blank" "set_con_blank" \
225 "Run the (daily) 'cron.run' script now" "cron.run"
226 do : ; done