rev |
line source |
pankso@42
|
1 #!/bin/sh
|
pankso@42
|
2 #
|
pankso@42
|
3 # System settings CGI interface: user, locale, keyboard, date. Since we
|
paul@205
|
4 # don't have multiple pages here there is only one case used to get command
|
paul@205
|
5 # values and the full content is followed directly.
|
pankso@42
|
6 #
|
al@419
|
7 # Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License
|
pankso@42
|
8 #
|
pankso@42
|
9
|
al@419
|
10
|
pankso@42
|
11 # Common functions from libtazpanel
|
al@419
|
12
|
pankso@42
|
13 . lib/libtazpanel
|
pankso@42
|
14 get_config
|
pankso@42
|
15
|
al@501
|
16 TITLE=$(_ 'System settings')
|
pankso@42
|
17
|
al@419
|
18
|
al@437
|
19 listdb() {
|
al@498
|
20 for item in $(getdb $1 | cut -d: -f1); do
|
pascal@336
|
21 echo "<option>$item</option>\n"
|
pascal@336
|
22 done
|
pascal@336
|
23 }
|
pascal@336
|
24
|
al@498
|
25
|
al@476
|
26 restart_lxpanel() {
|
al@476
|
27 # `lxpanelctl restart` exists, but it breaks often leaving us without any panel
|
al@489
|
28
|
al@521
|
29 # parameters needed to run graphical application from script
|
al@521
|
30 if [ -z "$XAUTHORITY" ]; then
|
al@521
|
31 if [ -e "$HOME/.Xauthority" ]; then
|
al@521
|
32 export XAUTHORITY="$HOME/.Xauthority"
|
al@521
|
33 elif [ -e '/var/run/slim.auth' ]; then
|
al@521
|
34 export XAUTHORITY='/var/run/slim.auth'
|
al@521
|
35 fi
|
al@489
|
36 fi
|
al@521
|
37 [ -z "$DISPLAY" ] && export DISPLAY=':0.0'
|
al@521
|
38
|
al@521
|
39 # find LXPanel ProcessID, filter out zombie '[lxpanel]' (if any)
|
psychomaniak@589
|
40 lxpanel_pid="$(ps -o comm,pid,args | grep lxpanel | grep -v -E 'grep|sh|\[' | awk '{print $2}')"
|
al@521
|
41
|
al@521
|
42 # if LXPanel not running, just run it with default option
|
al@521
|
43 if [ -z "$lxpanel_pid" ]; then
|
psychomaniak@590
|
44 (pstree | grep -q pcmanfm) && pcmanfm /etc/xdg/autostart/lxpanel.desktop ||
|
psychomaniak@590
|
45 sh -l -c "lxpanel -p slitaz" &
|
al@521
|
46 else
|
al@521
|
47 # who started LXPanel?..
|
al@521
|
48 lxpanel_user="$(ps -o pid,user | fgrep "$lxpanel_pid " | awk '{print $2}')"
|
al@521
|
49
|
al@521
|
50 # ... current user?
|
al@521
|
51 if [ "$USER" == "$lxpanel_user" ]; then
|
al@521
|
52 # custom command?
|
al@521
|
53 lxpanel_comm="$(ps -o pid,args | grep -e "^\ *$lxpanel_pid " | awk '{$1="";print}')"
|
al@521
|
54 [ -z "$lxpanel_comm" ] && lxpanel_comm='lxpanel -p slitaz'
|
al@521
|
55
|
al@521
|
56 # stop LXPanel and start it again with the same command
|
al@521
|
57 kill $lxpanel_pid
|
psychomaniak@590
|
58 (pstree | grep -q pcmanfm) && pcmanfm /etc/xdg/autostart/lxpanel.desktop ||
|
psychomaniak@590
|
59 sh -l -c "$lxpanel_comm" &
|
al@521
|
60 fi
|
al@521
|
61 fi
|
al@521
|
62
|
al@476
|
63 }
|
al@419
|
64
|
al@419
|
65
|
al@419
|
66
|
pankso@42
|
67 #
|
pankso@42
|
68 # Commands executed before page loading.
|
pankso@42
|
69 #
|
pankso@42
|
70
|
pascal@81
|
71 case " $(GET) " in
|
pascal@115
|
72 *\ do\ *)
|
al@419
|
73 users=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="user") print $2}')
|
al@419
|
74 groups=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="group")print $2}')
|
al@419
|
75
|
al@419
|
76 case $(GET do) in
|
al@419
|
77
|
al@419
|
78 # Groups page
|
al@498
|
79 delgroups) for i in $groups; do delgroup $i; done ;;
|
al@498
|
80 addgroup) addgroup $groups ;;
|
al@498
|
81 addmember) addgroup $(GET member) $groups ;;
|
al@498
|
82 delmember) delgroup $(GET member) $groups ;;
|
al@419
|
83
|
al@419
|
84 # Users page
|
al@498
|
85 delusers) for i in $users; do deluser $i; done ;;
|
al@498
|
86 lockusers) for i in $users; do passwd -l $i | log; done ;;
|
al@498
|
87 unlockusers) for i in $users; do passwd -u $i | log; done ;;
|
al@498
|
88 chpasswd) echo "$users:$(GET password)" | chpasswd -m | log ;;
|
al@419
|
89 adduser)
|
al@419
|
90 if [ -n "$users" ]; then
|
al@498
|
91 name="$(GET name)"
|
al@498
|
92 adduser -D -s /bin/sh -g "${name:-SliTaz User}" -G users -h /home/$users $users
|
al@419
|
93 echo "$user:$(GET passwd)" | chpasswd -m | log
|
al@419
|
94 for i in audio cdrom floppy video tty; do addgroup $users $i; done
|
al@498
|
95 passwd -u $users | log
|
al@419
|
96 fi ;;
|
al@419
|
97
|
al@419
|
98 # System time
|
al@558
|
99 calendar)
|
al@558
|
100 # display Yad date picker (AJAX)
|
al@498
|
101 new_date="$(DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' \
|
al@498
|
102 yad --calendar --on-top --mouse --undecorated \
|
al@498
|
103 --window-icon=config-date --title="$(_ 'Set date')" \
|
al@498
|
104 --date-format='%x<span style="display:none">%F</span>')"
|
al@498
|
105 header
|
al@498
|
106 echo "$new_date"; exit 0;;
|
al@498
|
107
|
al@558
|
108 settz)
|
al@558
|
109 # set timezone
|
al@498
|
110 GET tz > /etc/TZ ;;
|
al@498
|
111
|
al@558
|
112 date)
|
al@558
|
113 # only accepted format is MMDDhhmm[[YY]YY][.ss]
|
al@498
|
114 if [ -n "$(GET dateFull)" ]; then
|
al@498
|
115 dateFull="$(GET dateFull)" # %F = YYYY-MM-DD
|
al@498
|
116 date $(printf '%02d%02d%02d%02d%d.%02d' "${dateFull:5:2}" \
|
al@498
|
117 "${dateFull:8:2}" "$(GET hour)" "$(GET min)" \
|
al@498
|
118 "${dateFull:0:4}" "$(GET sec)") >/dev/null
|
al@498
|
119 else
|
al@498
|
120 date $(printf '%02d%02d%02d%02d%d.%02d' "$(GET month)" \
|
al@498
|
121 "$(GET day)" "$(GET hour)" "$(GET min)" "$(GET year)" \
|
al@498
|
122 "$(GET sec)") >/dev/null
|
al@498
|
123 fi;;
|
al@498
|
124
|
al@558
|
125 rdate)
|
al@558
|
126 # get and possibly set the system date/time from a remote host
|
psychomaniak@589
|
127 sh -l -c "rdate -s tick.greyware.com" ;;
|
al@498
|
128
|
al@558
|
129 hwclock)
|
al@558
|
130 # query and set hardware clock (RTC)
|
al@419
|
131 hwclock -w -u ;;
|
al@419
|
132
|
al@558
|
133 gethwclock)
|
al@558
|
134 # get date/time from hardware clock (AJAX)
|
psychomaniak@589
|
135 header; sh -l -c "hwclock -ur | sed 's|0.000000 seconds||'"; exit 0;;
|
al@498
|
136
|
al@419
|
137 esac
|
al@419
|
138 ;;
|
al@419
|
139
|
al@419
|
140
|
al@498
|
141 *\ gen_locale\ *) new_locale=$(GET gen_locale) ;;
|
al@498
|
142 *\ gen_keymap\ *) new_keymap=$(GET gen_keymap) ;;
|
al@498
|
143
|
pascal@142
|
144 *\ apply_xorg_kbd\ *)
|
pascal@142
|
145 sed -i "s/XkbLayout.*/XkbLayout \" \"$(GET apply_xorg_kbd)\"/" \
|
pascal@142
|
146 /etc/X11/xorg.conf.d/40-Keyboard.conf ;;
|
pankso@110
|
147 *\ style*)
|
pankso@110
|
148 sed -i s/'^STYLE.*'/"STYLE=\"$(GET style)\""/ $CONFIG
|
al@292
|
149 . $CONFIG ;;
|
al@474
|
150
|
al@474
|
151
|
al@474
|
152 *\ tweak\ *)
|
pascal@507
|
153 HOME="$(getdb passwd | awk -F: -vu=$REMOTE_USER '$1==u{print $6}')"
|
al@521
|
154 [ ! -d "$HOME" ] && exit 0
|
al@474
|
155
|
al@476
|
156 dd="$HOME/.local/share/desktop-directories"; sd="$dd/SliTazMenu.directory"
|
al@476
|
157
|
al@498
|
158 case "$REMOTE_USER" in
|
al@498
|
159 root) color='31'; ind='#';;
|
al@498
|
160 *) color='32'; ind='$';;
|
al@474
|
161 esac
|
al@474
|
162
|
al@474
|
163 case $(GET tweak) in
|
al@474
|
164 monochrome)
|
al@474
|
165 # PS1='\u@\h:\w\$ '
|
al@474
|
166 sed -i "s|^PS1=.*|PS1='\\\\u@\\\\h:\\\\w\\\\$ind '|" $HOME/.profile;;
|
al@474
|
167 colored)
|
al@474
|
168 # PS1='\[\e[0;32m\]\u@\h\[\e[0m\]:\[\e[0;33m\]\w\[\e[0m\]\$ '
|
al@474
|
169 sed -i "s|^PS1=.*|PS1='\\\\\\[\\\\e\[0;${color}m\\\\\\]\\\\u@\\\\h\\\\\\[\\\\e\\[0m\\\\\\]:\\\\\\[\\\\e\\[0;33m\\\\\\]\\\\w\\\\\\[\\\\e\\[0m\\\\\\]\\\\$ind '|" $HOME/.profile;;
|
al@474
|
170 slitaz-*)
|
al@474
|
171 lxpanel="$HOME/.config/lxpanel"
|
al@474
|
172 if [ ! -e "$lxpanel" ]; then
|
al@474
|
173 mkdir -p "$lxpanel"; cp /etc/lxpanel/default /etc/lxpanel/slitaz $lxpanel
|
al@474
|
174 fi
|
al@489
|
175
|
al@476
|
176 for panel in $(find $lxpanel -type f -iname panel); do
|
al@474
|
177 awk -vicon="/usr/share/pixmaps/$(GET tweak).png" '
|
al@474
|
178 BEGIN{ found = "0"; }
|
al@474
|
179 {
|
al@474
|
180 if ($1 == "Plugin") { found = "1"; }
|
al@474
|
181
|
al@474
|
182 if (found == "1" && $1 == "type") {
|
al@474
|
183 if ($3 == "menu") found = "2"; else found = "0";
|
al@474
|
184 }
|
al@474
|
185
|
al@474
|
186 if (found == "2" && $1 == "Plugin") { found = "0"; }
|
al@474
|
187
|
al@474
|
188 if (found == "2" && index($1, "image")) {
|
al@474
|
189 printf " image=%s\n", icon;
|
al@474
|
190 found = 0;
|
al@474
|
191 } else {
|
al@474
|
192 print;
|
al@474
|
193 }
|
al@474
|
194 }
|
al@474
|
195 ' $panel > $panel.new
|
al@474
|
196 mv -f $panel.new $panel
|
al@474
|
197 done
|
al@474
|
198
|
al@476
|
199 restart_lxpanel;;
|
al@474
|
200 menu-notext)
|
al@474
|
201 mkdir -p $dd
|
al@476
|
202 echo -e '[Desktop Entry]\nType=Directory\nName=' > $sd
|
al@476
|
203 restart_lxpanel;;
|
al@474
|
204 menu-text)
|
al@476
|
205 [ -f "$sd" ] && rm "$sd"
|
al@476
|
206 restart_lxpanel;;
|
al@474
|
207 esac
|
al@474
|
208 exit 0
|
al@474
|
209 ;;
|
al@474
|
210
|
al@474
|
211
|
al@558
|
212 *\ menuIcon\ *)
|
al@558
|
213 # return specified image (AJAX)
|
al@474
|
214 icon="/usr/share/pixmaps/$(GET menuIcon).png"
|
al@474
|
215 [ ! -r $icon ] && exit 0
|
al@474
|
216 header "Content-Type: image/png"; cat $icon; exit 0
|
al@474
|
217 ;;
|
pankso@42
|
218 esac
|
pankso@42
|
219
|
al@419
|
220
|
al@419
|
221
|
al@419
|
222
|
al@419
|
223
|
pankso@42
|
224 #
|
pankso@42
|
225 # Default xHTML content
|
pankso@42
|
226 #
|
al@419
|
227
|
al@474
|
228 header
|
pankso@67
|
229
|
pankso@110
|
230 case " $(GET) " in
|
pascal@336
|
231 *\ group*)
|
pascal@336
|
232 #
|
pascal@336
|
233 # Groups management
|
pascal@336
|
234 #
|
al@501
|
235 xhtml_header "$(_ 'Manage groups')"
|
al@474
|
236 check_root_tazpanel
|
al@474
|
237
|
pascal@336
|
238 cat <<EOT
|
al@501
|
239 <section id="groups">
|
al@419
|
240 <form class="wide">
|
al@419
|
241 <header>
|
al@419
|
242 <input type="hidden" name="groups"/>
|
al@443
|
243 <!-- $(_ 'Selection:') -->
|
al@558
|
244 <button name="do" value="delgroups" data-icon="@delete@">$(_ 'Delete group')</button>
|
al@419
|
245 </header>
|
al@419
|
246
|
al@419
|
247 <div class="scroll">
|
al@419
|
248 <table class="wide zebra scroll">
|
al@419
|
249 <thead>
|
al@419
|
250 <tr class="thead">
|
al@443
|
251 <td>$(_ 'Group')</td>
|
al@443
|
252 <td>$(_ 'Group ID')</td>
|
al@443
|
253 <td>$(_ 'Members')</td>
|
al@419
|
254 </tr>
|
al@419
|
255 </thead>
|
al@419
|
256 <tbody>
|
pascal@336
|
257 EOT
|
al@498
|
258 for group in $(getdb group | cut -d: -f1); do
|
pascal@336
|
259 IFS=':'
|
pascal@336
|
260 set -- $(getdb group | grep "^$group:")
|
pascal@336
|
261 unset IFS
|
pascal@336
|
262 cat <<EOT
|
al@419
|
263 <tr>
|
al@419
|
264 <td><input type="checkbox" name="group" value="$group" id="$group"/>
|
al@558
|
265 <label for="$group" data-icon="@group@">$group</label></td>
|
al@498
|
266 <td>$3</td>
|
al@498
|
267 <td>${4//,/, }</td>
|
al@419
|
268 </tr>
|
pascal@336
|
269 EOT
|
pascal@336
|
270 done
|
al@419
|
271 cat <<EOT
|
al@419
|
272 </tbody>
|
al@419
|
273 </table>
|
al@419
|
274 </div>
|
al@419
|
275 </form>
|
al@419
|
276 </section>
|
al@419
|
277
|
pascal@336
|
278
|
pascal@336
|
279 <section>
|
al@443
|
280 <header>$(_ 'Add a new group')</header>
|
al@498
|
281 <form class="wide">
|
al@419
|
282 <input type="hidden" name="groups"/>
|
al@498
|
283 <footer>$(_ 'Group name:') <input type="text" name="group"/>
|
al@558
|
284 <button type="submit" name="do" value="addgroup" data-icon="@add@">$(_ 'Create group')</button>
|
al@498
|
285 </footer>
|
al@419
|
286 </form>
|
pascal@336
|
287 </section>
|
pascal@336
|
288
|
al@419
|
289
|
pascal@336
|
290 <section>
|
al@443
|
291 <header>$(_ 'Manage group membership')</header>
|
al@498
|
292 <form class="wide">
|
al@419
|
293 <input type="hidden" name="groups"/>
|
al@498
|
294 <div>
|
al@498
|
295 $(_ 'Group name:') <select name="group">$(listdb group)</select>
|
al@541
|
296 $(_ 'User login:') <select name="member">$(listdb passwd)</select>
|
al@498
|
297 </div>
|
al@498
|
298 <footer>
|
al@558
|
299 <button name="do" value="addmember" data-icon="@add@">$(_ 'Add user')</button>
|
al@558
|
300 <button name="do" value="delmember" data-icon="@delete@">$(_ 'Remove user')</button>
|
al@498
|
301 </footer>
|
al@419
|
302 </form>
|
pascal@336
|
303 </section>
|
pascal@336
|
304
|
pascal@336
|
305 EOT
|
pascal@336
|
306 ;;
|
pascal@336
|
307
|
al@419
|
308
|
pankso@110
|
309 *\ user*)
|
pankso@110
|
310 #
|
pankso@110
|
311 # Users management
|
pankso@110
|
312 #
|
al@501
|
313 xhtml_header "$(_ 'Manage users')"
|
al@474
|
314 check_root_tazpanel
|
al@474
|
315
|
pankso@110
|
316 cat <<EOT
|
al@501
|
317 <section id="users">
|
al@419
|
318 <form class="wide">
|
al@419
|
319 <header>
|
al@443
|
320 <!--$(_ 'Selection:')-->
|
al@558
|
321 <button name="do" value="delusers" data-icon="@delete@">$(_ 'Delete user')</button>
|
al@558
|
322 <button name="do" value="lockusers" data-icon="@lock@" >$(_ 'Lock user' )</button>
|
al@558
|
323 <button name="do" value="unlockusers" data-icon="@unlock@">$(_ 'Unlock user')</button>
|
al@419
|
324 </header>
|
al@303
|
325
|
al@419
|
326 <table class="wide zebra center">
|
al@419
|
327 <thead>
|
al@419
|
328 <tr>
|
al@443
|
329 <td>$(_ 'Login')</td>
|
al@443
|
330 <td>$(_ 'User ID')</td>
|
al@498
|
331 <td>$(_ 'User Name')</td>
|
al@443
|
332 <td>$(_ 'Home')</td>
|
al@443
|
333 <td>$(_ 'Shell')</td>
|
al@419
|
334 </tr>
|
al@419
|
335 </thead>
|
al@419
|
336 </tbody>
|
pascal@115
|
337 EOT
|
al@498
|
338 for login in $(getdb passwd | cut -d: -f1); do
|
al@498
|
339 if [ -d "/home/$login" ]; then
|
al@558
|
340 blocked=''; usericon='@user@'
|
pascal@507
|
341 if getdb shadow | grep -qs "^$login:!"; then
|
al@498
|
342 blocked='class="color31"'
|
al@558
|
343 usericon='@lock@'
|
al@498
|
344 fi
|
pascal@115
|
345 IFS=':'
|
pascal@336
|
346 set -- $(getdb passwd | grep "^$login:")
|
pascal@115
|
347 unset IFS
|
pascal@115
|
348 cat <<EOT
|
pascal@115
|
349 <tr>
|
al@419
|
350 <td style="white-space: nowrap">
|
al@419
|
351 <input type="checkbox" name="user" value="$login" id="$login"/>
|
al@498
|
352 <label for="$login" data-icon="$usericon" $blocked>$login</label></td>
|
al@419
|
353 <td>$3:$4</td>
|
al@419
|
354 <td>$(echo $5 | sed s/,.*//)</td>
|
al@419
|
355 <td>$6</td>
|
al@419
|
356 <td>$7</td>
|
pascal@115
|
357 </tr>
|
pascal@115
|
358 EOT
|
pankso@110
|
359 fi
|
pankso@110
|
360 done
|
al@419
|
361 cat <<EOT
|
al@419
|
362 </tbody>
|
al@419
|
363 </table>
|
al@303
|
364 EOT
|
al@419
|
365 cat <<EOT
|
al@419
|
366 <footer>
|
al@498
|
367 $(_ 'Password:')
|
al@519
|
368 <input type="password" name="password" placeholder="$(_ 'New password')"/>
|
al@558
|
369 <button type="submit" name="do" value="chpasswd" data-icon="@ok@">$(_ 'Change password')</button>
|
al@419
|
370 </footer>
|
al@419
|
371 </form>
|
al@419
|
372 </section>
|
al@419
|
373
|
pankso@42
|
374
|
al@312
|
375 <section>
|
al@443
|
376 <header>$(_ 'Add a new user')</header>
|
al@303
|
377
|
al@419
|
378 <form>
|
al@419
|
379 <input type="hidden" name="users"/>
|
al@419
|
380 <table class="summary">
|
al@443
|
381 <tr><td>$(_ 'User login:')</td>
|
al@419
|
382 <td><input type="text" name="user" size="30" pattern="[a-z]*"/></td></tr>
|
al@443
|
383 <tr><td>$(_ 'User name:')</td>
|
al@419
|
384 <td><input type="text" name="name" size="30"/></td></tr>
|
al@443
|
385 <tr><td>$(_ 'User password:')</td>
|
al@419
|
386 <td><input type="password" name="passwd" size="30"/></td></tr>
|
al@419
|
387 </table>
|
al@419
|
388
|
al@419
|
389 <footer>
|
al@558
|
390 <button type="submit" name="do" value="adduser" data-icon="@add@">$(_ 'Create user')</button>
|
al@419
|
391 </footer>
|
al@419
|
392 </form>
|
al@312
|
393 </section>
|
al@470
|
394 EOT
|
pascal@147
|
395
|
al@498
|
396 # `who` output is empty in the SLiM sessions
|
al@470
|
397 if [ -n "$(who)" ]; then
|
al@470
|
398 cat <<EOT
|
al@312
|
399 <section>
|
al@443
|
400 <header>$(_ 'Current user sessions')</header>
|
al@419
|
401 <pre>$(who)</pre>
|
al@312
|
402 </section>
|
al@470
|
403 EOT
|
al@470
|
404 fi
|
al@303
|
405
|
al@470
|
406 # `last` output is empty (just header) in the Live mode
|
al@470
|
407 if [ "$(last | wc -l)" != "1" ]; then
|
al@470
|
408 cat <<EOT
|
al@312
|
409 <section>
|
al@443
|
410 <header>$(_ 'Last user sessions')</header>
|
al@419
|
411 <div class="scroll"><pre>$(last)</pre></div>
|
al@312
|
412 </section>
|
pankso@42
|
413 EOT
|
al@470
|
414 fi
|
pankso@110
|
415 ;;
|
al@313
|
416
|
al@313
|
417
|
al@313
|
418 *\ locale*)
|
al@313
|
419 #
|
al@313
|
420 # Choose locale
|
al@313
|
421 #
|
al@501
|
422 xhtml_header "$(_ 'Choose locale')"
|
al@474
|
423 check_root_tazpanel
|
al@474
|
424
|
al@498
|
425 loading_msg "$(_ 'Please wait...')"
|
al@419
|
426
|
al@313
|
427 cur_loc=$(locale | grep LANG | cut -d= -f2)
|
al@419
|
428 cat <<EOT
|
al@501
|
429 <section id="locale">
|
al@443
|
430 <header>$(_ 'Current locale settings:')</header>
|
al@419
|
431 <div>
|
al@419
|
432 <pre>$(locale)</pre>
|
al@419
|
433 </div>
|
al@419
|
434 </section>
|
al@313
|
435
|
al@419
|
436 <section>
|
al@443
|
437 <header>$(_ 'Locales that are currently installed on the machine:')</header>
|
al@419
|
438 <div>
|
al@419
|
439 <pre>$(locale -a)</pre>
|
al@419
|
440 </div>
|
al@419
|
441 </section>
|
al@318
|
442 EOT
|
al@313
|
443
|
al@318
|
444 is_installed "glibc-locale"
|
al@318
|
445 [ $? = 1 ] &&
|
al@443
|
446 msg tip $(_ \
|
paul@319
|
447 "Can't see your language?<br/>You can \
|
pascal@441
|
448 <a href='pkgs.cgi?do=Install&glibc-locale'>install glibc-locale</a> \
|
paul@319
|
449 to see a larger list of available locales.")
|
al@318
|
450
|
al@313
|
451
|
al@419
|
452 cat <<EOT
|
al@419
|
453 <section>
|
al@443
|
454 <header>$(_ 'Available locales:')</header>
|
al@419
|
455 <form class="wide">
|
al@419
|
456 <table class="wide zebra">
|
al@419
|
457 <thead>
|
al@443
|
458 <tr><td>$(_ 'Code')</td>
|
al@443
|
459 <td>$(_ 'Language')</td>
|
al@443
|
460 <td>$(_ 'Territory')</td>
|
al@443
|
461 <td>$(_ 'Description')</td>
|
al@419
|
462 </tr>
|
al@419
|
463 </thead>
|
al@419
|
464 <tbody>
|
al@313
|
465 EOT
|
al@419
|
466 for locale in $(find /usr/share/i18n/locales -type f | sort); do
|
al@313
|
467 locale_name=$(basename $locale)
|
al@313
|
468 locale_title=$(grep -m 1 -e '^ *title' $locale | cut -d'"' -f2)
|
al@313
|
469 if [ -n "$locale_title" ]; then
|
al@419
|
470 sel=''; [ "$locale_name" == "$cur_loc" ] && sel='checked="checked"'
|
al@419
|
471 cat <<EOT
|
al@419
|
472 <tr>
|
al@419
|
473 <td>
|
al@419
|
474 <input type="radio" name="gen_locale" value="$locale_name" $sel id="$locale_name"/>
|
al@419
|
475 <label for="$locale_name">$locale_name</label>
|
al@419
|
476 </td>
|
al@419
|
477 <td>$(gettext -d iso_639 "$(grep -m 1 -e '^ *language' $locale | cut -d '"' -f2)")</td>
|
al@419
|
478 <td>$(gettext -d iso_3166 "$(grep -m 1 -e '^ *territory' $locale | cut -d '"' -f2)")</td>
|
al@419
|
479 <td>$locale_title</td>
|
al@419
|
480 </tr>
|
al@313
|
481 EOT
|
al@313
|
482 fi
|
al@313
|
483 done
|
al@419
|
484 cat <<EOT
|
al@419
|
485 </tbody>
|
al@419
|
486 </table>
|
al@419
|
487
|
al@419
|
488 <footer>
|
al@558
|
489 <button type="submit" data-icon="@ok@">$(_ 'Activate')</button>
|
al@419
|
490 </footer>
|
al@419
|
491 </form>
|
al@419
|
492 </section>
|
al@313
|
493 EOT
|
al@313
|
494 ;;
|
al@313
|
495
|
al@313
|
496
|
al@474
|
497 *\ tweaks\ *)
|
al@474
|
498 #
|
al@474
|
499 # Small tweaks for user
|
al@474
|
500 #
|
al@501
|
501 user="$REMOTE_USER"; host="$(hostname)"
|
al@501
|
502 xhtml_header "$(_ 'Small quick tweaks for user %s' "$user")"
|
al@474
|
503
|
pascal@507
|
504 HOME="$(getdb passwd | awk -F: -vu=$user '$1==u{print $6}')"
|
al@474
|
505 font="${TERM_FONT:-monospace}"; palette=$(echo $TERM_PALETTE | tr A-Z a-z)
|
al@474
|
506 case $user in
|
al@474
|
507 root) color=31; ind="#";;
|
al@474
|
508 *) color=32; ind="$";;
|
al@474
|
509 esac
|
al@474
|
510
|
al@474
|
511 prompt_bw="$user@$host:/usr/bin$ind"
|
al@474
|
512 prompt_c="<span class=\"color$color\">$user@$host</span>:<span class=\"color33\">/usr/bin</span>$ind"
|
al@474
|
513 cursor="<span class=\"color47\">_</span>"
|
al@474
|
514 cat <<EOT
|
al@474
|
515 <script type="text/javascript">
|
al@474
|
516 function tweak(tweakName) {
|
al@474
|
517 // Send request to the server
|
al@474
|
518 var hiddenImg = document.createElement('IMG');
|
al@474
|
519 hiddenImg.src = "settings.cgi?tweak=" + tweakName;
|
al@474
|
520 }
|
al@474
|
521 </script>
|
al@474
|
522
|
al@474
|
523 <section>
|
al@474
|
524 <header>$(_ 'Small quick tweaks for user %s' "$user")</header>
|
al@474
|
525
|
al@498
|
526 <div>
|
al@474
|
527 <fieldset><legend>$(_ 'Terminal prompt')</legend>
|
al@474
|
528 <table class="wide">
|
al@474
|
529 <tr>
|
al@474
|
530 <td>
|
al@474
|
531 <label>
|
al@474
|
532 <input type="radio" name="termPrompt" onclick="tweak('monochrome')"/>
|
al@474
|
533 $(_ 'Monochrome')
|
al@474
|
534 </label>
|
al@474
|
535 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
|
al@474
|
536 $prompt_bw uname -r<br/>$(uname -r)<br/>$prompt_bw date<br/>$(date)<br/>$prompt_bw $cursor
|
al@474
|
537 </pre>
|
al@474
|
538 </td>
|
al@474
|
539 <td>
|
al@474
|
540 <label>
|
al@474
|
541 <input type="radio" name="termPrompt" onclick="tweak('colored')"/>
|
al@474
|
542 $(_ 'Colored')
|
al@474
|
543 </label>
|
al@474
|
544 <pre class="term $palette" style="font-family: '$font'; height: 5rem;">
|
al@474
|
545 $prompt_c uname -r<br/>$(uname -r)<br/>$prompt_c date<br/>$(date)<br/>$prompt_c $cursor
|
al@474
|
546 </pre>
|
al@474
|
547 </td>
|
al@474
|
548 </tr>
|
al@474
|
549 </table>
|
al@474
|
550
|
al@558
|
551 <p>$(_ 'Manual edit: %s' "<a data-icon=\"@conf@\" href="index.cgi?file=$HOME/.profile">~/.profile</a>")<br/>
|
al@474
|
552 $(_ 'To take effect: log out and log in to system or execute command in the terminal:')</p>
|
al@474
|
553
|
al@474
|
554 <pre>. ~/.profile</pre>
|
al@474
|
555 </fieldset>
|
al@474
|
556
|
al@474
|
557 <br/>
|
al@474
|
558
|
al@474
|
559 <fieldset>
|
al@474
|
560 <legend>$(_ 'Menu button appearance')</legend>
|
al@474
|
561 <table class="wide">
|
al@474
|
562 <tr>
|
al@474
|
563 <td style="vertical-align: top">
|
al@474
|
564 <fieldset>
|
al@474
|
565 <legend>$(_ 'Icon:')</legend>
|
al@474
|
566 <label>
|
al@474
|
567 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu-empty')"/>
|
al@474
|
568 $(_ 'Do not show')
|
al@474
|
569 </label><br/>
|
al@474
|
570 <label>
|
al@474
|
571 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button-red')"/>
|
al@474
|
572 <img src="?menuIcon=slitaz-button-red"/>
|
al@474
|
573 </label><br/>
|
al@474
|
574 <label>
|
al@474
|
575 <input type="radio" name="menuIcon" onclick="tweak('slitaz-menu')"/>
|
al@474
|
576 <img src="?menuIcon=slitaz-menu"/>
|
al@474
|
577 </label><br/>
|
al@474
|
578 <label>
|
al@474
|
579 <input type="radio" name="menuIcon" onclick="tweak('slitaz-button')"/>
|
al@474
|
580 <img src="?menuIcon=slitaz-button"/>
|
al@474
|
581 </label>
|
al@474
|
582 </fieldset>
|
al@474
|
583 </td>
|
al@474
|
584 <td style="vertical-align: top">
|
al@474
|
585 <fieldset>
|
al@474
|
586 <legend>$(_ 'Text:')</legend>
|
al@474
|
587 <label>
|
al@474
|
588 <input type="radio" name="menuText" onclick="tweak('menu-notext')"/>
|
al@474
|
589 $(_ 'Do not show')
|
al@474
|
590 </label><br/>
|
al@474
|
591 <label>
|
al@474
|
592 <input type="radio" name="menuText" onclick="tweak('menu-text')"/>
|
al@474
|
593 $(_ 'Show text')
|
al@474
|
594 </label>
|
al@474
|
595 </fieldset>
|
al@474
|
596 </td>
|
al@474
|
597 </tr>
|
al@474
|
598 </table>
|
al@474
|
599 <p>$(_ 'Manual edit: %s' \
|
al@558
|
600 "<a data-icon=\"@conf@\" href=\"index.cgi?file=$HOME/.local/share/desktop-directories/SliTazMenu.directory\">~/.local/share/desktop-directories/SliTazMenu.directory</a>
|
al@474
|
601 $(
|
al@474
|
602 find $HOME/.config/lxpanel -type f -name panel | awk -vh="$HOME" \
|
al@558
|
603 '{ printf "<a data-icon=\"@conf@\" href=\"index.cgi?file=%s\">%s</a> ", $1, gensub(h, "~", "")}'
|
al@474
|
604 )")</p>
|
al@474
|
605 </fieldset>
|
al@498
|
606 </div>
|
al@474
|
607 </section>
|
al@474
|
608 EOT
|
al@474
|
609 ;;
|
al@474
|
610
|
al@474
|
611
|
pankso@110
|
612 *)
|
pankso@110
|
613 #
|
paul@385
|
614 # Default system settings page
|
pankso@110
|
615 #
|
al@501
|
616 xhtml_header "$(_ 'Manage system time, users or language settings')"
|
al@474
|
617 check_root_tazpanel
|
al@422
|
618
|
al@419
|
619 cat <<EOT
|
al@419
|
620 <form><!--
|
al@558
|
621 --><button name="users" data-icon="@user@" >$(_ 'Manage users' )</button><!--
|
al@558
|
622 --><button name="groups" data-icon="@group@">$(_ 'Manage groups')</button>
|
al@419
|
623 </form>
|
pankso@42
|
624
|
al@312
|
625 <section>
|
al@443
|
626 <header>$(_ 'System time')</header>
|
al@419
|
627 <div>
|
al@498
|
628 <form class="wide" id="sysTimeForm">
|
al@443
|
629 <fieldset><legend>$(_ 'Time zone:')</legend>
|
al@419
|
630 <select name="tz">
|
al@419
|
631 $(cd /usr/share/zoneinfo; find * -type f ! -name '*.tab' | sort | \
|
al@419
|
632 awk -vtz="$(cat /etc/TZ)" \
|
al@419
|
633 '{printf("<option%s>%s</option>", ($1 == tz)?" selected":"", $1)}')
|
al@419
|
634 </select>
|
al@558
|
635 <button name="do" value="settz" data-icon="@ok@">$(_ 'Change')</button>
|
al@419
|
636 </fieldset>
|
al@437
|
637
|
al@443
|
638 <fieldset><legend>$(_ 'System time:')</legend>
|
psychomaniak@589
|
639 $(sh -l -c date | sed 's|[0-9][0-9]:[0-9:]*|<span id="time">&</span>|')
|
al@558
|
640 <button name="do" value="rdate" data-icon="@sync@">$(_ 'Sync online')</button>
|
al@419
|
641 </fieldset>
|
al@437
|
642
|
al@443
|
643 <fieldset id="hwclock1"><legend>$(_ 'Hardware clock:')</legend>
|
al@498
|
644 <span id="hwclocks">$(hwclock -ur | sed 's|0.000000 seconds||')</span>
|
al@558
|
645 <button name="do" value="hwclock" id="hwclock" data-icon="@clock@">$(_ 'Set hardware clock')</button>
|
al@419
|
646 </fieldset>
|
al@437
|
647
|
al@443
|
648 <fieldset><legend>$(_ 'Set date')</legend>
|
al@498
|
649 EOT
|
al@498
|
650 if [ -z "$(which yad)" ]; then
|
al@498
|
651 cat <<EOT
|
al@419
|
652 <input type="number" name="day" value="$(date +%d)" min="1" max="31" size="4" required/>
|
al@419
|
653 <select name="month" value="$(date +%m)">
|
al@419
|
654 $(for i in $(seq 12); do
|
al@437
|
655 sel=''; [ "$i" == "$(date +%-m)" ] && sel=' selected'
|
al@437
|
656 printf "<option value=\"%s\"$sel>%s</option>" $(date -d $i.01-01:01 '+%m %B')
|
al@419
|
657 done)
|
al@419
|
658 </select>
|
al@419
|
659 <input type="number" name="year" value="$(date +%Y)" min="2015" max="2030" size="6" required/>
|
al@498
|
660 EOT
|
al@498
|
661 else
|
al@498
|
662 cat <<EOT
|
al@498
|
663 <button onclick="datePicker(); return false">
|
al@558
|
664 <span id="dateTime" data-icon="@calendar@">$(date +%x)<span style="display:none">$(date +%F)</span></span>
|
al@498
|
665 </button>
|
al@498
|
666 EOT
|
al@498
|
667 fi
|
al@498
|
668 cat <<EOT
|
al@419
|
669 - <input type="number" name="hour" value="$(date +%H)" min="0" max="23" size="4" required/><!--
|
al@419
|
670 -->:<input type="number" name="min" value="$(date +%M)" min="0" max="59" size="4" required/><!--
|
al@419
|
671 -->:<input type="number" name="sec" value="00" min="0" max="59" size="4" required/>
|
al@498
|
672 EOT
|
al@498
|
673 if [ -z "$(which yad)" ]; then
|
al@498
|
674 cat <<EOT
|
al@558
|
675 <button name="do" value="date" data-icon="@ok@">$(_ 'Set date')</button>
|
al@498
|
676 EOT
|
al@498
|
677 else
|
al@498
|
678 cat <<EOT
|
al@498
|
679
|
al@558
|
680 <button data-icon="@ok@" onclick="submitSysTimeForm()">$(_ 'Set date')</button>
|
al@498
|
681 EOT
|
al@498
|
682 fi
|
al@498
|
683 cat <<EOT
|
al@419
|
684 </fieldset>
|
al@419
|
685 </form>
|
al@419
|
686 </div>
|
al@303
|
687
|
al@419
|
688 <script type="text/javascript">
|
al@419
|
689 // Live time on page
|
al@419
|
690 Date.prototype.timeNow = function() {
|
al@419
|
691 return ((this.getHours() < 10)?"0":"") + this.getHours() + ":" + ((this.getMinutes() < 10)?"0":"") + this.getMinutes() + ":" + ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
|
al@419
|
692 }
|
al@498
|
693 setInterval(function(){
|
al@545
|
694 document.getElementById('time').textContent = new Date().timeNow();
|
al@499
|
695 //ajax('settings.cgi?do=gethwclock', '1', 'hwclocks');
|
al@498
|
696 }, 1000);
|
al@437
|
697
|
al@498
|
698
|
al@498
|
699 // Run date picker and return value to the 'dateTime' element
|
al@498
|
700 function datePicker() {
|
al@498
|
701 ajax('settings.cgi?do=calendar', '1', 'dateTime');
|
al@498
|
702 }
|
al@498
|
703
|
al@498
|
704 // Actions to do before form submit and submit
|
al@498
|
705 function submitSysTimeForm() {
|
al@498
|
706 sysTimeForm = document.getElementById('sysTimeForm');
|
al@498
|
707
|
al@498
|
708 var dateFull = document.createElement('INPUT');
|
al@498
|
709 dateFull.name = 'dateFull';
|
al@545
|
710 dateFull.value = document.getElementById('dateTime').childNodes[1].textContent;
|
al@498
|
711 dateFull.type = 'hidden';
|
al@498
|
712 sysTimeForm.appendChild(dateFull);
|
al@498
|
713
|
al@498
|
714 var submitDo = document.createElement('INPUT');
|
al@498
|
715 submitDo.name = 'do'; submitDo.value = 'date';
|
al@498
|
716 submitDo.type = 'hidden';
|
al@498
|
717 sysTimeForm.appendChild(submitDo);
|
al@498
|
718
|
al@498
|
719 sysTimeForm.submit();
|
al@498
|
720 }
|
al@419
|
721 </script>
|
al@312
|
722 </section>
|
pankso@110
|
723 EOT
|
al@419
|
724
|
al@419
|
725
|
pankso@110
|
726 #
|
pankso@110
|
727 # Locale settings
|
pankso@110
|
728 #
|
al@419
|
729 cat <<EOT
|
al@312
|
730 <section>
|
al@443
|
731 <header id="locale">$(_ 'System language')</header>
|
al@419
|
732 <div>
|
al@419
|
733 <form>
|
pankso@42
|
734 EOT
|
pankso@42
|
735 # Check if a new locale was requested
|
pankso@42
|
736 if [ -n "$new_locale" ]; then
|
pankso@42
|
737 rm -rf /usr/lib/locale/$new_locale
|
pankso@42
|
738 localedef -i $new_locale -c -f UTF-8 \
|
pankso@42
|
739 /usr/lib/locale/$new_locale
|
pankso@42
|
740 # System configuration
|
pankso@42
|
741 echo "LANG=$new_locale" > /etc/locale.conf
|
pankso@42
|
742 echo "LC_ALL=$new_locale" >> /etc/locale.conf
|
al@443
|
743 msg warn "$(_ \
|
al@443
|
744 'You must logout and login again to your current session to use %s locale.' $new_locale)"
|
pankso@42
|
745 else
|
al@419
|
746 cat <<EOT
|
al@443
|
747 $(_ 'Current system locale:')
|
al@419
|
748 <strong>$(locale | grep LANG | cut -d= -f2)</strong>
|
al@558
|
749 <button name="locale" data-icon="@locale@">$(_ 'Change')</button>
|
al@419
|
750 EOT
|
pankso@42
|
751 fi
|
al@419
|
752 cat <<EOT
|
al@419
|
753 </div>
|
al@419
|
754 </form>
|
al@312
|
755 </section>
|
pankso@110
|
756
|
al@419
|
757
|
al@312
|
758 <section>
|
al@443
|
759 <header id="keymap">$(_ 'Keyboard layout')</header>
|
al@419
|
760 <div>
|
pascal@141
|
761 EOT
|
pascal@141
|
762 # Check if a new keymap was requested
|
pascal@141
|
763 if [ -n "$new_keymap" ]; then
|
pascal@141
|
764 echo "$new_keymap" > /etc/keymap.conf
|
pascal@141
|
765 if [ -x /bin/loadkeys ]; then
|
pascal@141
|
766 loadkeys $new_keymap
|
pascal@141
|
767 else
|
pascal@141
|
768 loadkmap < /usr/share/kmap/$new_keymap.kmap
|
pascal@141
|
769 fi
|
pascal@141
|
770 fi
|
al@419
|
771
|
pascal@142
|
772 keymap=$(cat /etc/keymap.conf)
|
al@443
|
773 _ 'Current console keymap: %s' $keymap
|
pascal@142
|
774 if [ -n "$keymap" ]; then
|
pascal@142
|
775 case "$keymap" in
|
pascal@142
|
776 fr_CH*)
|
pascal@142
|
777 keymap="ch" ;;
|
pascal@142
|
778 ru)
|
al@419
|
779 keymap="us,ru" ;;
|
pascal@142
|
780 slovene)
|
pascal@142
|
781 keymap=si ;;
|
pascal@142
|
782 *)
|
pascal@142
|
783 keymap=${keymap%-lat*}
|
pascal@142
|
784 keymap=${keymap%-abnt2} ;;
|
pascal@142
|
785 esac
|
pascal@142
|
786 keyboard_config=/etc/X11/xorg.conf.d/40-Keyboard.conf
|
al@419
|
787 cat <<EOT
|
al@419
|
788 <form id="settings"></form>
|
al@419
|
789 <form id="index" action="index.cgi"></form>
|
al@419
|
790 <br/>
|
al@443
|
791 $(_ 'Suggested keymap for Xorg:') $keymap
|
al@558
|
792 <button form="settings" name="apply_xorg_kbd" value="$keymap" data-icon="@ok@">$(_ 'Activate')</button>
|
al@558
|
793 <button form="index" name="file" value="$keyboard_config" data-icon="@edit@">$(_ 'Edit')</button>
|
pascal@504
|
794 <input form="index" type="hidden" name="action" value="edit" />
|
al@419
|
795 <br/>
|
pascal@142
|
796 EOT
|
pascal@142
|
797 fi
|
al@419
|
798 cat <<EOT
|
al@419
|
799 <form>
|
al@443
|
800 $(_ 'Available keymaps:')
|
al@419
|
801 <select name="gen_keymap">
|
al@419
|
802 $(list_keymaps)
|
al@419
|
803 </select>
|
al@558
|
804 <button type="submit" data-icon="@ok@">$(_ 'Activate')</button>
|
al@419
|
805 </form>
|
al@419
|
806 </div>
|
al@312
|
807 </section>
|
pascal@141
|
808
|
al@419
|
809
|
al@312
|
810 <section>
|
al@443
|
811 <header>$(_ 'Panel configuration')</header>
|
al@419
|
812 <div>
|
al@419
|
813 <form class="wide">
|
al@443
|
814 <fieldset><legend>$(_ 'Style:')</legend>
|
al@419
|
815 <select name="style">$(list_styles)</select>
|
al@558
|
816 <button data-icon="@ok@">$(_ 'Activate')</button>
|
al@419
|
817 </fieldset>
|
al@419
|
818 </form>
|
al@419
|
819
|
al@443
|
820 <fieldset><legend>$(_ 'Configuration files:')</legend>
|
al@558
|
821 <button form="index" name="file" value="$CONFIG" data-icon="@edit@">$(_ 'Panel')</button>
|
al@558
|
822 <button form="index" name="file" value="$HTTPD_CONF" data-icon="@edit@">$(_ 'Server')</button>
|
al@419
|
823 </fieldset>
|
al@419
|
824
|
al@443
|
825 <p>$(_ 'TazPanel provides a debugging mode and page:')
|
pascal@441
|
826 <a href="index.cgi?debug">debug</a>
|
pankso@110
|
827 </p>
|
al@419
|
828 </div>
|
al@312
|
829 </section>
|
pankso@42
|
830 EOT
|
pankso@110
|
831 ;;
|
pankso@110
|
832 esac
|
pankso@42
|
833
|
pankso@42
|
834 xhtml_footer
|
pankso@42
|
835 exit 0
|