slitaz-tools diff oldstuff/tazctrlbox @ rev 585
Rename stuff to oldstuff and mv subox to it
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Apr 30 01:29:28 2011 +0200 (2011-04-30) |
parents | stuff/tazctrlbox@0a7ab48dfe8c |
children | 83491d0ac7b1 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/oldstuff/tazctrlbox Sat Apr 30 01:29:28 2011 +0200 1.3 @@ -0,0 +1,563 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# SliTaz Control Box is a tool to configure and manage a SliTaz system. 1.7 +# The script uses GTKdialog for the UI interface. Some shell functions 1.8 +# are called by argument. Individual window dialogs are put into 1.9 +# functions. 1.10 +# 1.11 +# (C) GNU gpl v3 - SliTaz GNU/Linux 2010. 1.12 +# Author: Christophe Lincoln <pankso@slitaz.org> 1.13 +# 1.14 +VERSION=1.1 1.15 + 1.16 +# Include gettext helper script. 1.17 +. /usr/bin/gettext.sh 1.18 + 1.19 +# Export package name for gettext. 1.20 +TEXTDOMAIN='tazctrlbox' 1.21 +export TEXTDOMAIN 1.22 + 1.23 +# Get init configuration. 1.24 +. /etc/rcS.conf 1.25 + 1.26 +# Tazctrlbox is only for root. 1.27 +if test $(id -u) != 0 ; then 1.28 + exec subox $0 1.29 + exit 0 1.30 +fi 1.31 + 1.32 +# By default autologin is not configured on an installed system. 1.33 +if ! grep -q 'auto_login' /etc/slim.conf; then 1.34 + echo '# Auto login default user' >> /etc/slim.conf 1.35 + echo 'auto_login no' >> /etc/slim.conf 1.36 +fi 1.37 + 1.38 +# Change Grub menu.lst timeout. 1.39 +sed_grub_timeout() 1.40 +{ 1.41 + CURRENT=`cat /boot/grub/menu.lst | grep ^timeout | cut -d " " -f2` 1.42 + sed -i s/"timeout $CURRENT"/"timeout $GRUB_TIMEOUT"/ /boot/grub/menu.lst 1.43 +} 1.44 + 1.45 +# Change Grub menu.lst timeout. 1.46 +sed_grub_color() 1.47 +{ 1.48 + CURRENT=`cat /boot/grub/menu.lst | grep ^color | cut -d " " -f2-3` 1.49 + sed -i s#"color $CURRENT"#"color $GRUB_COLOR"# /boot/grub/menu.lst 1.50 +} 1.51 + 1.52 +# Set check fs on boot. 1.53 +sed_check_fs() 1.54 +{ 1.55 + sed -i s#"CHECK_FS=\"$CHECK_FS\""#"CHECK_FS=\"$NEW_CHECK_FS\""# \ 1.56 + /etc/rcS.conf 1.57 +} 1.58 + 1.59 +# Set loaded modules on boot. 1.60 +sed_load_modules() 1.61 +{ 1.62 + sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$NEW_MODULES\""/ \ 1.63 + /etc/rcS.conf 1.64 +} 1.65 + 1.66 +# Set daemons to run on boot. 1.67 +sed_run_daemons() 1.68 +{ 1.69 + sed -i s/"RUN_DAEMONS=\"$RUN_DAEMONS\""/"RUN_DAEMONS=\"$NEW_DAEMONS\""/ \ 1.70 + /etc/rcS.conf 1.71 +} 1.72 + 1.73 +# Get user list. 1.74 +get_users() 1.75 +{ 1.76 + for i in `cat /etc/passwd | cut -d ":" -f 1` 1.77 + do 1.78 + if [ -d /home/$i ]; then 1.79 + login=$i 1.80 + uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3` 1.81 + gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4` 1.82 + name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | sed s/,,,//` 1.83 + home=`cat /etc/passwd | grep $i | cut -d ":" -f 6` 1.84 + shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7` 1.85 + echo "system-users | $login | $uid:$gid | $name | $home | $shell" 1.86 + fi 1.87 + done 1.88 +} 1.89 + 1.90 +# Remove a user or change passwd. 1.91 +manage_user() 1.92 +{ 1.93 + export MANAGE_DIALOG=" 1.94 +<window title=\"`gettext "Manage user: "`$USER\" icon-name=\"computer\"> 1.95 + <vbox> 1.96 + <vbox> 1.97 + <text wrap=\"false\" width-chars=\"34\"> 1.98 + <label>\" 1.99 +Login name: $USER 1.100 + \"</label> 1.101 + </text> 1.102 + </vbox> 1.103 + <hbox> 1.104 + <text wrap=\"false\"> 1.105 + <label>\"`gettext "New password:"`\"</label> 1.106 + </text> 1.107 + <entry invisible_char=\"*\" visibility=\"false\" max_length=\"8\"> 1.108 + <variable>PASSWD</variable> 1.109 + </entry> 1.110 + <button> 1.111 + <label>Change</label> 1.112 + <input file icon=\"forward\"></input> 1.113 + <action>echo \"$USER:$PASSWD\" | chpasswd</action> 1.114 + <action type=\"closewindow\">MANAGE_USER</action> 1.115 + </button> 1.116 + </hbox> 1.117 + <hbox> 1.118 + <button> 1.119 + <label>`gettext "Delete user"`</label> 1.120 + <input file icon=\"gtk-delete\"></input> 1.121 + <action>deluser $USER</action> 1.122 + <action type=\"closewindow\">MANAGE_USER</action> 1.123 + </button> 1.124 + <button cancel> 1.125 + <action type=\"closewindow\">MANAGE_USER</action> 1.126 + </button> 1.127 + </hbox> 1.128 + </vbox> 1.129 +</window> 1.130 +" 1.131 + gtkdialog --center --program=MANAGE_DIALOG >/dev/null 1.132 +} 1.133 + 1.134 +# Add a new user. 1.135 +add_user() 1.136 +{ 1.137 + export ADD_USER_DIALOG=' 1.138 +<window title="New user" icon-name="gtk-add"> 1.139 + <vbox> 1.140 + <vbox> 1.141 + <text wrap="false" width-chars="34"> 1.142 + <label>"'`gettext " 1.143 +New account information"`' 1.144 + "</label> 1.145 + </text> 1.146 + </vbox> 1.147 + <hbox> 1.148 + <text wrap="false"> 1.149 + <label>"'`gettext "Login:"`' "</label> 1.150 + </text> 1.151 + <entry> 1.152 + <variable>NEW_USER</variable> 1.153 + </entry> 1.154 + </hbox> 1.155 + <hbox> 1.156 + <text wrap="false"> 1.157 + <label>"'`gettext "Password:"`'"</label> 1.158 + </text> 1.159 + <entry invisible_char="*" visibility="false" max_length="8"> 1.160 + <variable>PASSWD</variable> 1.161 + </entry> 1.162 + </hbox> 1.163 + <hbox> 1.164 + <button ok> 1.165 + <action>adduser -D $NEW_USER</action> 1.166 + <action>echo "$NEW_USER:$PASSWD" | chpasswd</action> 1.167 + <action>addgroup $NEW_USER audio</action> 1.168 + <action>addgroup $NEW_USER cdrom</action> 1.169 + <action>addgroup $NEW_USER floppy</action> 1.170 + <action>addgroup $NEW_USER video</action> 1.171 + <action>rmdir /home/$NEW_USER</action> 1.172 + <action>cp -a /etc/skel /home/$NEW_USER</action> 1.173 + <action>cp /root/.xinitrc /home/$NEW_USER</action> 1.174 + <action>mkdir -p /home/$NEW_USER/.config/slitaz</action> 1.175 + <action>cp -a /etc/slitaz/applications.conf /home/$NEW_USER/.config/slitaz</action> 1.176 + <action>chown -R $NEW_USER:$NEW_USER /home/$NEW_USER</action> 1.177 + <action type="closewindow">MANAGE_USER</action> 1.178 + </button> 1.179 + <button cancel> 1.180 + <action type="closewindow">MANAGE_USER</action> 1.181 + </button> 1.182 + </hbox> 1.183 + </vbox> 1.184 +</window> 1.185 +' 1.186 + gtkdialog --center --program=ADD_USER_DIALOG >/dev/null 1.187 +} 1.188 + 1.189 +# i18n functions. 1.190 +list_locales() 1.191 +{ 1.192 + cd /usr/share/i18n/locales 1.193 + for locale in `ls -1 [a-z][a-z]_[A-Z][A-Z]` 1.194 + do 1.195 + echo "preferences-desktop-locale | $locale | UTF-8" 1.196 + done 1.197 +} 1.198 +gen_utf8_locale() 1.199 +{ 1.200 + rm -rf /usr/lib/locale/$LANGUAGE 1.201 + localedef -i $LANGUAGE -c -f UTF-8 /usr/lib/locale/$LANGUAGE 1.202 + # System configuration 1.203 + echo "LANG=$LANGUAGE" > /etc/locale.conf 1.204 + echo "LC_ALL=$LANGUAGE" >> /etc/locale.conf 1.205 +} 1.206 + 1.207 +# Main dialog with notebook. 1.208 +# 1.209 +export MAIN_DIALOG=' 1.210 +<window title="'`gettext "SliTaz Control Box"`'" icon-name="computer"> 1.211 +<vbox> 1.212 + 1.213 + <hbox> 1.214 + <text use-markup="true"> 1.215 + <label>"'`gettext "<b>SliTaz Control Box</b>"`'"</label> 1.216 + </text> 1.217 + <pixmap> 1.218 + <input file>/usr/share/pixmaps/tazctrlbox.png</input> 1.219 + </pixmap> 1.220 + </hbox> 1.221 + 1.222 + <notebook labels="'`gettext "Boot loader|Initialization|Login manager|Time|Language|Users"`'">' 1.223 + 1.224 +# GRUB. 1.225 +MAIN_DIALOG=${MAIN_DIALOG}" 1.226 + <vbox> 1.227 + <frame `gettext "Grub boot loader"`> 1.228 + <hbox> 1.229 + <text wrap=\"false\"> 1.230 + <label>\"`gettext "Timeout:"`\"</label> 1.231 + </text> 1.232 + <entry> 1.233 + <input>cat /boot/grub/menu.lst | grep ^timeout | cut -d \" \" -f2</input> 1.234 + <variable>GRUB_TIMEOUT</variable> 1.235 + </entry> 1.236 + <button> 1.237 + <label>`gettext "Change"`</label> 1.238 + <input file icon=\"forward\"></input> 1.239 + <action>$0 sed_grub_timeout</action> 1.240 + </button> 1.241 + </hbox> 1.242 + <hbox> 1.243 + <text wrap=\"false\"> 1.244 + <label>\"`gettext "Color:"` \"</label> 1.245 + </text> 1.246 + <entry> 1.247 + <input>cat /boot/grub/menu.lst | grep ^color | cut -d \" \" -f2-3</input> 1.248 + <variable>GRUB_COLOR</variable> 1.249 + </entry> 1.250 + <button> 1.251 + <label>`gettext "Change"`</label> 1.252 + <input file icon=\"forward\"></input> 1.253 + <action>$0 sed_grub_color</action> 1.254 + </button> 1.255 + </hbox> 1.256 + <hbox> 1.257 + <text wrap=\"false\"> 1.258 + <label>\"`gettext "Configuration file:"`\"</label> 1.259 + </text> 1.260 + <button> 1.261 + <label>/boot/grub/menu.lst</label> 1.262 + <input file icon=\"accessories-text-editor\"></input> 1.263 + <action>leafpad /boot/grub/menu.lst</action> 1.264 + <action>refresh:GRUB_COLOR</action> 1.265 + <action>refresh:GRUB_TIMEOUT</action> 1.266 + </button> 1.267 + </hbox> 1.268 + </frame> 1.269 + </vbox>" 1.270 +# Init script. 1.271 +MAIN_DIALOG=${MAIN_DIALOG}" 1.272 + <vbox> 1.273 + <frame `gettext "rcS init scripts"`> 1.274 + <hbox> 1.275 + <text wrap=\"false\"> 1.276 + <label>\"`gettext "Check filesystems:"`\"</label> 1.277 + </text> 1.278 + <entry> 1.279 + <input>echo $CHECK_FS</input> 1.280 + <variable>NEW_CHECK_FS</variable> 1.281 + </entry> 1.282 + <button> 1.283 + <label>Change</label> 1.284 + <input file icon=\"forward\"></input> 1.285 + <action>$0 sed_check_fs</action> 1.286 + </button> 1.287 + </hbox> 1.288 + <hbox> 1.289 + <text wrap=\"false\"> 1.290 + <label>\"`gettext "Load modules:"` \"</label> 1.291 + </text> 1.292 + <entry> 1.293 + <input>echo $LOAD_MODULES</input> 1.294 + <variable>NEW_MODULES</variable> 1.295 + </entry> 1.296 + <button> 1.297 + <label>`gettext "Change"`</label> 1.298 + <input file icon=\"forward\"></input> 1.299 + <action>$0 sed_load_modules</action> 1.300 + </button> 1.301 + </hbox> 1.302 + <hbox> 1.303 + <text wrap=\"false\"> 1.304 + <label>\"`gettext "Run daemons:"` \"</label> 1.305 + </text> 1.306 + <entry> 1.307 + <input>echo $RUN_DAEMONS</input> 1.308 + <variable>NEW_DAEMONS</variable> 1.309 + </entry> 1.310 + <button> 1.311 + <label>`gettext "Change"`</label> 1.312 + <input file icon=\"forward\"></input> 1.313 + <action>$0 sed_run_daemons</action> 1.314 + </button> 1.315 + </hbox> 1.316 + <hbox> 1.317 + <text wrap=\"false\"> 1.318 + <label>\"`gettext "Add local commands:"`\"</label> 1.319 + </text> 1.320 + <button> 1.321 + <label>/etc/init.d/local.sh</label> 1.322 + <input file icon=\"accessories-text-editor\"></input> 1.323 + <action>leafpad /etc/init.d/local.sh</action> 1.324 + </button> 1.325 + </hbox> 1.326 + </frame> 1.327 + </vbox>" 1.328 +# Slim login. 1.329 +MAIN_DIALOG=${MAIN_DIALOG}' 1.330 + <vbox> 1.331 + <frame '`gettext "Slim settings"`'> 1.332 + <hbox> 1.333 + <text wrap="false"> 1.334 + <label>"'`gettext "Sessions:"`' "</label> 1.335 + </text> 1.336 + <entry> 1.337 + <input>cat /etc/slim.conf | grep ^session | sed s/"sessions. *"//</input> 1.338 + <variable>SLIM_SESSIONS</variable> 1.339 + </entry> 1.340 + <button> 1.341 + <label>'`gettext "Change"`'</label> 1.342 + <input file icon="forward"></input> 1.343 + <action>sed -i "s/^sessions.*/sessions $SLIM_SESSIONS/" /etc/slim.conf</action> 1.344 + </button> 1.345 + </hbox> 1.346 + <hbox> 1.347 + <text wrap="false"> 1.348 + <label>"'`gettext "Default user:"`' "</label> 1.349 + </text> 1.350 + <entry> 1.351 + <input>cat /etc/slim.conf | grep ^default_user | sed s/"default_user. *"//</input> 1.352 + <variable>SLIM_DEF_USER</variable> 1.353 + </entry> 1.354 + <button> 1.355 + <label>'`gettext "Change"`'</label> 1.356 + <input file icon="forward"></input> 1.357 + <action>sed -i "s/^default_user.*/default_user $SLIM_DEF_USER/" /etc/slim.conf</action> 1.358 + </button> 1.359 + </hbox> 1.360 + <hbox> 1.361 + <text wrap="false"> 1.362 + <label>"'`gettext "Auto login (yes|no):"`' "</label> 1.363 + </text> 1.364 + <entry max_length="3"> 1.365 + <input>cat /etc/slim.conf | grep ^auto_login | sed s/"auto_login. *"//</input> 1.366 + <variable>SLIM_AUTO_LOGIN</variable> 1.367 + </entry> 1.368 + <button> 1.369 + <label>'`gettext "Change"`'</label> 1.370 + <input file icon="forward"></input> 1.371 + <action>sed -i "s/^auto_login.*/auto_login $SLIM_AUTO_LOGIN/" /etc/slim.conf</action> 1.372 + </button> 1.373 + </hbox> 1.374 + <hbox> 1.375 + <text wrap="false"> 1.376 + <label>"'`gettext "Theme:"`'"</label> 1.377 + </text> 1.378 + <combobox> 1.379 + <variable>NEW_SLIM_THEME</variable>' 1.380 +# List all installed Slim themes. 1.381 +for dir in $(ls /usr/share/slim/themes) 1.382 +do 1.383 + THEME_ITEMS="<item>$dir</item>" 1.384 + MAIN_DIALOG=${MAIN_DIALOG}${THEME_ITEMS} 1.385 +done 1.386 +MAIN_DIALOG=${MAIN_DIALOG}' 1.387 + </combobox> 1.388 + <button> 1.389 + <label>'`gettext "Preview"`'</label> 1.390 + <input file icon="video-display"></input> 1.391 + <action>slim -p /usr/share/slim/themes/$NEW_SLIM_THEME &</action> 1.392 + </button> 1.393 + <button> 1.394 + <label>'`gettext "Change"`'</label> 1.395 + <input file icon="forward"></input> 1.396 + <action>sed -i "s/^current_theme.*/current_theme $NEW_SLIM_THEME/" /etc/slim.conf</action> 1.397 + <action>refresh:SLIM_THEME</action> 1.398 + </button> 1.399 + </hbox> 1.400 + <hbox> 1.401 + <text wrap="false"> 1.402 + <label>"'`gettext "Configuration file:"`'"</label> 1.403 + </text> 1.404 + <button> 1.405 + <label>/etc/slim.conf</label> 1.406 + <input file icon="accessories-text-editor"></input> 1.407 + <action>leafpad /etc/slim.conf</action> 1.408 + <action>refresh:SLIM_SESSIONS</action> 1.409 + <action>refresh:SLIM_DEF_USER</action> 1.410 + </button> 1.411 + </hbox> 1.412 + </frame> 1.413 + </vbox>' 1.414 +# Time settings. 1.415 +MAIN_DIALOG=${MAIN_DIALOG}' 1.416 + <vbox> 1.417 + <frame '`gettext "Date and time"`'> 1.418 + <hbox> 1.419 + <text wrap="false"> 1.420 + <label>"'`gettext "System time:"`' "</label> 1.421 + </text> 1.422 + <entry editable="false"> 1.423 + <input>LC_ALL=C date</input> 1.424 + <variable>DATE</variable> 1.425 + </entry> 1.426 + <button> 1.427 + <label>'`gettext "Sync online"`'</label> 1.428 + <input file icon="reload"></input> 1.429 + <action>rdate -s tick.greyware.com</action> 1.430 + <action>refresh:DATE</action> 1.431 + <action>refresh:HWTIME</action> 1.432 + </button> 1.433 + </hbox> 1.434 + <hbox> 1.435 + <text wrap="false"> 1.436 + <label>"'`gettext "Hardware time:"`'"</label> 1.437 + </text> 1.438 + <entry editable="false"> 1.439 + <input>LC_ALL=C hwclock</input> 1.440 + <variable>HWTIME</variable> 1.441 + </entry> 1.442 + <button> 1.443 + <label>'`gettext "Set from system"`'</label> 1.444 + <input file icon="reload"></input> 1.445 + <action>hwclock -w -u</action> 1.446 + <action>refresh:HWTIME</action> 1.447 + <action>refresh:DATE</action> 1.448 + </button> 1.449 + </hbox> 1.450 + <hbox> 1.451 + <text wrap="true"> 1.452 + <label>"'`gettext "Timezone:"`' "</label> 1.453 + </text> 1.454 + <entry> 1.455 + <input>cat /etc/TZ</input> 1.456 + <variable>NEW_TZ</variable> 1.457 + </entry> 1.458 + <button> 1.459 + <label>'`gettext "Change"`'</label> 1.460 + <input file icon="forward"></input> 1.461 + <action>echo "$NEW_TZ" > /etc/TZ</action> 1.462 + </button> 1.463 + </hbox> 1.464 + </frame> 1.465 + </vbox>' 1.466 +# Language settings. 1.467 +MAIN_DIALOG=${MAIN_DIALOG}" 1.468 + <vbox> 1.469 + <tree> 1.470 + <width>600</width><height>210</height> 1.471 + <variable>LANGUAGE</variable> 1.472 + <label>`gettext "Language|Charmap"`</label> 1.473 + <input icon_column=\"0\">$0 list_locales</input> 1.474 + <action>$0 gen_utf8_locale</action> 1.475 + </tree> 1.476 + <hbox> 1.477 + <text width-chars=\"60\"> 1.478 + <label> 1.479 +\"`gettext "To change the system language you can double-click on the locale name."`\" 1.480 + </label> 1.481 + </text> 1.482 + <button> 1.483 + <label>`gettext "Keymap"`</label> 1.484 + <input file icon=\"input-keyboard\"></input> 1.485 + <action>tazkeymap &</action> 1.486 + </button> 1.487 + </hbox> 1.488 + </vbox>" 1.489 +# Display users list through get_users. 1.490 +MAIN_DIALOG=${MAIN_DIALOG}" 1.491 + <vbox> 1.492 + <tree> 1.493 + <width>600</width><height>210</height> 1.494 + <variable>USER</variable> 1.495 + <label>`gettext "Login|uid:gid|Name|Home|SHell"`</label> 1.496 + <input icon_column=\"0\">$0 get_users</input> 1.497 + <action>$0 manage_user</action> 1.498 + <action>refresh:USER</action> 1.499 + </tree> 1.500 + <hbox> 1.501 + <text width-chars=\"60\"> 1.502 + <label> 1.503 +\"`gettext "To change passwords or delete users you can double-click on the user name."`\" 1.504 + </label> 1.505 + </text> 1.506 + <button> 1.507 + <label>`gettext "Add newuser"`</label> 1.508 + <input file icon=\"gtk-add\"></input> 1.509 + <action>$0 add_user</action> 1.510 + <action>refresh:USER</action> 1.511 + </button> 1.512 + </hbox> 1.513 + </vbox>" 1.514 +export MAIN_DIALOG=${MAIN_DIALOG}' 1.515 + </notebook> 1.516 + 1.517 + <hbox> 1.518 + <button> 1.519 + <label>'`gettext "Network"`'</label> 1.520 + <input file icon="netbox"></input> 1.521 + <action>netbox &</action> 1.522 + </button> 1.523 + <button> 1.524 + <label>'`gettext "Wireless"`'</label> 1.525 + <input file icon="network-wireless"></input> 1.526 + <action>wifibox &</action> 1.527 + </button> 1.528 + <button> 1.529 + <label>'`gettext "Packages"`'</label> 1.530 + <input file icon="tazpkg"></input> 1.531 + <action>tazpkgbox &</action> 1.532 + </button> 1.533 + <button> 1.534 + <label>'`gettext "Hardware"`'</label> 1.535 + <input file icon="computer"></input> 1.536 + <action>tazhw box &</action> 1.537 + </button> 1.538 + <button> 1.539 + <label>'`gettext "Server"`'</label> 1.540 + <input file icon="utilities-system-monitor"></input> 1.541 + <action>serverbox &</action> 1.542 + </button> 1.543 + <button> 1.544 + <label>'`gettext "Storage"`'</label> 1.545 + <input file icon="media-flash"></input> 1.546 + <action>mountbox &</action> 1.547 + </button> 1.548 + <button> 1.549 + <label>'`gettext "Exit"`'</label> 1.550 + <input file icon="exit"></input> 1.551 + <action type="exit">Exit</action> 1.552 + </button> 1.553 + </hbox> 1.554 + 1.555 +</vbox> 1.556 + 1.557 +</window>' 1.558 + 1.559 +# Script can be called with an arg to exec a function. 1.560 +if [ -n "$1" ]; then 1.561 + $1 1.562 +else 1.563 + gtkdialog --center --program=MAIN_DIALOG >/dev/null 1.564 +fi 1.565 + 1.566 +exit 0