slitaz-tools annotate tinyutils/tazctrlbox @ rev 365

sshbox: typo
author Paul Issott <paul@slitaz.org>
date Sun Jun 28 18:02:32 2009 +0000 (2009-06-28)
parents d69f74e9a92b
children 753d6fb3c4a5
rev   line source
pankso@275 1 #!/bin/sh
pankso@275 2 #
pankso@275 3 # SliTaz Control Box is a tool to configure and manage a SliTaz system.
pankso@275 4 # The script use GTKdialog for the UI interface, some shell functions
pankso@275 5 # are called by argument. Individual window dialog are put into
pankso@275 6 # functions.
pankso@275 7 #
pankso@275 8 # (C) GNU gpl v3 - SliTaz GNU/Linux 2008.
pankso@275 9 # Author: Christophe Lincoln <pankso@slitaz.org>
pankso@275 10 #
pankso@275 11 VERSION=1.0
pankso@275 12
pankso@275 13 # Get init configuration.
pankso@275 14 . /etc/rcS.conf
pankso@275 15
pankso@275 16 # Tazctrlbox is only for root.
pankso@275 17 if test $(id -u) != 0 ; then
pankso@275 18 exec subox $0
pankso@275 19 exit 0
pankso@275 20 fi
pankso@275 21
pankso@313 22 # By default autologin is not configured on installed system
pankso@313 23 if ! grep -q 'auto_login' /etc/slim.conf; then
pankso@313 24 echo '# Auto login default user' >> /etc/slim.conf
pankso@313 25 echo 'auto_login no' >> /etc/slim.conf
pankso@313 26 fi
pankso@313 27
pankso@275 28 # Change Grub menu.lst timeout.
pankso@275 29 sed_grub_timeout()
pankso@275 30 {
pankso@275 31 CURRENT=`cat /boot/grub/menu.lst | grep ^timeout | cut -d " " -f2`
pankso@275 32 sed -i s/"timeout $CURRENT"/"timeout $GRUB_TIMEOUT"/ /boot/grub/menu.lst
pankso@275 33 }
pankso@275 34
pankso@275 35 # Change Grub menu.lst timeout.
pankso@275 36 sed_grub_color()
pankso@275 37 {
pankso@275 38 CURRENT=`cat /boot/grub/menu.lst | grep ^color | cut -d " " -f2-3`
pankso@275 39 sed -i s#"color $CURRENT"#"color $GRUB_COLOR"# /boot/grub/menu.lst
pankso@275 40 }
pankso@275 41
pankso@275 42 # Set checked fs on boot.
pankso@275 43 sed_check_fs()
pankso@275 44 {
pankso@275 45 sed -i s#"CHECK_FS=\"$CHECK_FS\""#"CHECK_FS=\"$NEW_CHECK_FS\""# \
pankso@275 46 /etc/rcS.conf
pankso@275 47 }
pankso@275 48
pankso@275 49 # Set loaded modules on boot.
pankso@275 50 sed_load_modules()
pankso@275 51 {
pankso@275 52 sed -i s/"LOAD_MODULES=\"$LOAD_MODULES\""/"LOAD_MODULES=\"$NEW_MODULES\""/ \
pankso@275 53 /etc/rcS.conf
pankso@275 54 }
pankso@275 55
pankso@275 56 # Set daemons to run on boot.
pankso@275 57 sed_run_daemons()
pankso@275 58 {
pankso@275 59 sed -i s/"RUN_DAEMONS=\"$RUN_DAEMONS\""/"RUN_DAEMONS=\"$NEW_DAEMONS\""/ \
pankso@275 60 /etc/rcS.conf
pankso@275 61 }
pankso@275 62
pankso@275 63 # Get user list
pankso@275 64 get_users()
pankso@275 65 {
pankso@275 66 for i in `cat /etc/passwd | cut -d ":" -f 1`
pankso@275 67 do
pankso@275 68 if [ -d /home/$i ]; then
pankso@275 69 login=$i
pankso@275 70 uid=`cat /etc/passwd | grep $i | cut -d ":" -f 3`
pankso@275 71 gid=`cat /etc/passwd | grep $i | cut -d ":" -f 4`
pankso@275 72 name=`cat /etc/passwd | grep $i | cut -d ":" -f 5 | sed s/,,,//`
pankso@275 73 home=`cat /etc/passwd | grep $i | cut -d ":" -f 6`
pankso@275 74 shell=`cat /etc/passwd | grep $i | cut -d ":" -f 7`
pankso@312 75 echo "system-users | $login | $uid:$gid | $name | $home | $shell"
pankso@275 76 fi
pankso@275 77 done
pankso@275 78 }
pankso@275 79
pankso@275 80 # Remove a user or change passwd.
pankso@275 81 manage_user()
pankso@275 82 {
pankso@275 83 export MANAGE_DIALOG="
pankso@275 84 <window title=\"Manage user: $USER\" icon-name=\"computer\">
pankso@275 85 <vbox>
pankso@313 86 <vbox>
pankso@275 87 <text wrap=\"false\" width-chars=\"34\">
pankso@275 88 <label>\"
pankso@275 89 Login name: $USER
pankso@275 90 \"</label>
pankso@275 91 </text>
pankso@313 92 </vbox>
pankso@275 93 <hbox>
pankso@275 94 <text wrap=\"false\">
pankso@275 95 <label>\"New password:\"</label>
pankso@275 96 </text>
pankso@313 97 <entry invisible_char=\"*\" visibility=\"false\" max_length=\"8\">
pankso@275 98 <variable>PASSWD</variable>
pankso@275 99 </entry>
pankso@275 100 <button>
pankso@275 101 <label>Change</label>
pankso@275 102 <input file icon=\"forward\"></input>
pankso@275 103 <action>echo \"$USER:$PASSWD\" | chpasswd</action>
pankso@275 104 <action type=\"closewindow\">MANAGE_USER</action>
pankso@275 105 </button>
pankso@275 106 </hbox>
pankso@275 107 <hbox>
pankso@275 108 <button>
pankso@275 109 <label>Delete user</label>
pankso@275 110 <input file icon=\"gtk-delete\"></input>
pankso@275 111 <action>deluser $USER</action>
pankso@275 112 <action type=\"closewindow\">MANAGE_USER</action>
pankso@275 113 </button>
pankso@275 114 <button cancel>
pankso@275 115 <action type=\"closewindow\">MANAGE_USER</action>
pankso@275 116 </button>
pankso@275 117 </hbox>
pankso@275 118 </vbox>
pankso@275 119 </window>
pankso@275 120 "
pankso@275 121 gtkdialog --center --program=MANAGE_DIALOG >/dev/null
pankso@275 122 }
pankso@275 123
pankso@275 124 # Add a new user.
pankso@275 125 add_user()
pankso@275 126 {
pankso@275 127 export ADD_USER_DIALOG='
pankso@275 128 <window title="New user" icon-name="gtk-add">
pankso@275 129 <vbox>
pankso@313 130 <vbox>
pankso@275 131 <text wrap="false" width-chars="34">
pankso@275 132 <label>"
pankso@275 133 New account information
pankso@275 134 "</label>
pankso@275 135 </text>
pankso@313 136 </vbox>
pankso@275 137 <hbox>
pankso@275 138 <text wrap="false">
pankso@275 139 <label>"Login: "</label>
pankso@275 140 </text>
pankso@275 141 <entry>
pankso@275 142 <variable>NEW_USER</variable>
pankso@275 143 </entry>
pankso@275 144 </hbox>
pankso@275 145 <hbox>
pankso@275 146 <text wrap="false">
pankso@275 147 <label>"Password:"</label>
pankso@275 148 </text>
pankso@313 149 <entry invisible_char="*" visibility="false" max_length="8">
pankso@275 150 <variable>PASSWD</variable>
pankso@275 151 </entry>
pankso@275 152 </hbox>
pankso@275 153 <hbox>
pankso@275 154 <button ok>
pankso@275 155 <action>adduser -D $NEW_USER</action>
pankso@275 156 <action>echo "$NEW_USER:$PASSWD" | chpasswd</action>
pankso@275 157 <action>adduser -G audio $NEW_USER</action>
pankso@320 158 <action>rmdir /home/$NEW_USER</action>
pankso@275 159 <action>cp -a /etc/skel /home/$NEW_USER</action>
pankso@275 160 <action>cp /root/.xinitrc /home/$NEW_USER</action>
pankso@275 161 <action>chown -R $NEW_USER:$NEW_USER /home/$NEW_USER</action>
pankso@275 162 <action type="closewindow">MANAGE_USER</action>
pankso@275 163 </button>
pankso@275 164 <button cancel>
pankso@275 165 <action type="closewindow">MANAGE_USER</action>
pankso@275 166 </button>
pankso@275 167 </hbox>
pankso@275 168 </vbox>
pankso@275 169 </window>
pankso@275 170 '
pankso@275 171 gtkdialog --center --program=ADD_USER_DIALOG >/dev/null
pankso@275 172 }
pankso@275 173
pankso@275 174 # Main dialog with notebook.
pankso@275 175 #
pankso@275 176 export MAIN_DIALOG='
pankso@275 177 <window title="SliTaz Control Box" icon-name="computer">
pankso@275 178 <vbox>
pankso@275 179
pankso@275 180 <hbox>
pankso@275 181 <text use-markup="true">
pankso@275 182 <label>"<b>SliTaz Control Box</b>"</label>
pankso@275 183 </text>
pankso@275 184 <pixmap>
pankso@275 185 <input file>/usr/share/pixmaps/tazctrlbox.png</input>
pankso@275 186 </pixmap>
pankso@275 187 </hbox>
pankso@275 188
paul@317 189 <notebook labels="Time|Boot loader|Initialization|Login manager|Users">
pankso@275 190
pankso@275 191 <vbox>
pankso@275 192 <frame Date and time>
pankso@275 193 <hbox>
pankso@275 194 <text wrap="false">
pankso@312 195 <label>"System time: "</label>
pankso@275 196 </text>
pankso@312 197 <entry editable="false">
pankso@312 198 <input>LC_ALL=C date</input>
pankso@275 199 <variable>DATE</variable>
pankso@275 200 </entry>
pankso@275 201 <button>
pankso@275 202 <label>Sync online</label>
pankso@275 203 <input file icon="reload"></input>
pankso@275 204 <action>rdate -s tick.greyware.com</action>
pankso@275 205 <action>refresh:DATE</action>
pankso@313 206 <action>refresh:HWTIME</action>
pankso@275 207 </button>
pankso@275 208 </hbox>
pankso@275 209 <hbox>
pankso@312 210 <text wrap="false">
pankso@312 211 <label>"Hardware time:"</label>
pankso@312 212 </text>
pankso@312 213 <entry editable="false">
pankso@312 214 <input>LC_ALL=C hwclock</input>
pankso@312 215 <variable>HWTIME</variable>
pankso@312 216 </entry>
pankso@312 217 <button>
pankso@313 218 <label>Set from system</label>
pankso@312 219 <input file icon="reload"></input>
pankso@316 220 <action>hwclock -w -u</action>
pankso@312 221 <action>refresh:HWTIME</action>
pankso@313 222 <action>refresh:DATE</action>
pankso@312 223 </button>
pankso@312 224 </hbox>
pankso@312 225 <hbox>
pankso@275 226 <text wrap="true">
pankso@312 227 <label>"Timezone: "</label>
pankso@275 228 </text>
pankso@275 229 <entry>
pankso@275 230 <input>cat /etc/TZ</input>
pankso@275 231 <variable>NEW_TZ</variable>
pankso@275 232 </entry>
pankso@275 233 <button>
pankso@275 234 <label>Change</label>
pankso@275 235 <input file icon="forward"></input>
pankso@275 236 <action>echo "$NEW_TZ" > /etc/TZ</action>
pankso@275 237 </button>
pankso@275 238 </hbox>
pankso@275 239 </frame>
pankso@275 240 </vbox>'
pankso@313 241 # GRUB
pankso@275 242 MAIN_DIALOG=${MAIN_DIALOG}"
pankso@275 243 <vbox>
pankso@275 244 <frame Grub boot loader>
pankso@275 245 <hbox>
pankso@275 246 <text wrap=\"false\">
pankso@275 247 <label>\"Timeout:\"</label>
pankso@275 248 </text>
pankso@275 249 <entry>
pankso@275 250 <input>cat /boot/grub/menu.lst | grep ^timeout | cut -d \" \" -f2</input>
pankso@275 251 <variable>GRUB_TIMEOUT</variable>
pankso@275 252 </entry>
pankso@275 253 <button>
pankso@275 254 <label>Change</label>
pankso@275 255 <input file icon=\"forward\"></input>
pankso@275 256 <action>$0 sed_grub_timeout</action>
pankso@275 257 </button>
pankso@275 258 </hbox>
pankso@275 259 <hbox>
pankso@275 260 <text wrap=\"false\">
pankso@275 261 <label>\"Color: \"</label>
pankso@275 262 </text>
pankso@275 263 <entry>
pankso@275 264 <input>cat /boot/grub/menu.lst | grep ^color | cut -d \" \" -f2-3</input>
pankso@275 265 <variable>GRUB_COLOR</variable>
pankso@275 266 </entry>
pankso@275 267 <button>
pankso@275 268 <label>Change</label>
pankso@275 269 <input file icon=\"forward\"></input>
pankso@275 270 <action>$0 sed_grub_color</action>
pankso@275 271 </button>
pankso@275 272 </hbox>
pankso@275 273 <hbox>
pankso@275 274 <text wrap=\"false\">
pankso@275 275 <label>\"Configuration file:\"</label>
pankso@275 276 </text>
pankso@275 277 <button>
pankso@275 278 <label>/boot/grub/menu.lst</label>
pankso@275 279 <input file icon=\"accessories-text-editor\"></input>
pankso@275 280 <action>leafpad /boot/grub/menu.lst</action>
pankso@275 281 <action>refresh:GRUB_COLOR</action>
pankso@275 282 <action>refresh:GRUB_TIMEOUT</action>
pankso@275 283 </button>
pankso@275 284 </hbox>
pankso@275 285 </frame>
pankso@313 286 </vbox>"
pankso@313 287 # Init script
pankso@313 288 MAIN_DIALOG=${MAIN_DIALOG}"
pankso@313 289 <vbox>
pankso@275 290 <frame rcS init scripts>
pankso@275 291 <hbox>
pankso@275 292 <text wrap=\"false\">
pankso@275 293 <label>\"Check filesystems:\"</label>
pankso@275 294 </text>
pankso@275 295 <entry>
pankso@275 296 <input>echo $CHECK_FS</input>
pankso@275 297 <variable>NEW_CHECK_FS</variable>
pankso@275 298 </entry>
pankso@275 299 <button>
pankso@275 300 <label>Change</label>
pankso@275 301 <input file icon=\"forward\"></input>
pankso@275 302 <action>$0 sed_check_fs</action>
pankso@275 303 </button>
pankso@275 304 </hbox>
pankso@275 305 <hbox>
pankso@275 306 <text wrap=\"false\">
pankso@275 307 <label>\"Load modules: \"</label>
pankso@275 308 </text>
pankso@275 309 <entry>
pankso@275 310 <input>echo $LOAD_MODULES</input>
pankso@275 311 <variable>NEW_MODULES</variable>
pankso@275 312 </entry>
pankso@275 313 <button>
pankso@275 314 <label>Change</label>
pankso@275 315 <input file icon=\"forward\"></input>
pankso@275 316 <action>$0 sed_load_modules</action>
pankso@275 317 </button>
pankso@275 318 </hbox>
pankso@275 319 <hbox>
pankso@275 320 <text wrap=\"false\">
pankso@275 321 <label>\"Run daemons: \"</label>
pankso@275 322 </text>
pankso@275 323 <entry>
pankso@275 324 <input>echo $RUN_DAEMONS</input>
pankso@275 325 <variable>NEW_DAEMONS</variable>
pankso@275 326 </entry>
pankso@275 327 <button>
pankso@275 328 <label>Change</label>
pankso@275 329 <input file icon=\"forward\"></input>
pankso@275 330 <action>$0 sed_run_daemons</action>
pankso@275 331 </button>
pankso@275 332 </hbox>
pankso@275 333 <hbox>
pankso@275 334 <text wrap=\"false\">
pankso@313 335 <label>\"Add local commands:\"</label>
pankso@275 336 </text>
pankso@275 337 <button>
pankso@275 338 <label>/etc/init.d/local.sh</label>
pankso@275 339 <input file icon=\"accessories-text-editor\"></input>
pankso@275 340 <action>leafpad /etc/init.d/local.sh</action>
pankso@275 341 </button>
pankso@275 342 </hbox>
pankso@275 343 </frame>
pankso@275 344 </vbox>"
pankso@313 345 # Slim login
pankso@275 346 MAIN_DIALOG=${MAIN_DIALOG}'
pankso@275 347 <vbox>
pankso@275 348 <frame Slim settings>
pankso@275 349 <hbox>
pankso@275 350 <text wrap="false">
pankso@313 351 <label>"Sessions: "</label>
pankso@275 352 </text>
pankso@275 353 <entry>
pankso@313 354 <input>cat /etc/slim.conf | grep ^session | sed s/"sessions. *"//</input>
pankso@275 355 <variable>SLIM_SESSIONS</variable>
pankso@275 356 </entry>
pankso@275 357 <button>
pankso@275 358 <label>Change</label>
pankso@275 359 <input file icon="forward"></input>
pankso@275 360 <action>sed -i "s/^sessions.*/sessions $SLIM_SESSIONS/" /etc/slim.conf</action>
pankso@275 361 </button>
pankso@275 362 </hbox>
pankso@275 363 <hbox>
pankso@275 364 <text wrap="false">
pankso@313 365 <label>"Default user: "</label>
pankso@275 366 </text>
pankso@275 367 <entry>
pankso@313 368 <input>cat /etc/slim.conf | grep ^default_user | sed s/"default_user. *"//</input>
pankso@275 369 <variable>SLIM_DEF_USER</variable>
pankso@275 370 </entry>
pankso@275 371 <button>
pankso@275 372 <label>Change</label>
pankso@275 373 <input file icon="forward"></input>
pankso@275 374 <action>sed -i "s/^default_user.*/default_user $SLIM_DEF_USER/" /etc/slim.conf</action>
pankso@275 375 </button>
pankso@275 376 </hbox>
pankso@275 377 <hbox>
pankso@275 378 <text wrap="false">
pankso@313 379 <label>"Auto login (yes|no): "</label>
pankso@313 380 </text>
pankso@313 381 <entry max_length="3">
pankso@313 382 <input>cat /etc/slim.conf | grep ^auto_login | sed s/"auto_login. *"//</input>
pankso@313 383 <variable>SLIM_AUTO_LOGIN</variable>
pankso@313 384 </entry>
pankso@313 385 <button>
pankso@313 386 <label>Change</label>
pankso@313 387 <input file icon="forward"></input>
pankso@313 388 <action>sed -i "s/^auto_login.*/auto_login $SLIM_AUTO_LOGIN/" /etc/slim.conf</action>
pankso@313 389 </button>
pankso@313 390 </hbox>
pankso@313 391 <hbox>
pascal@324 392 <button>
pascal@324 393 <label>Resize screen</label>
pascal@324 394 <input file icon="view-fullscreen"></input>
pascal@324 395 <action>tazx</action>
pascal@324 396 </button>
pankso@313 397 <text wrap="false">
pankso@275 398 <label>"Theme:"</label>
pankso@275 399 </text>
pankso@275 400 <combobox>
pankso@275 401 <variable>NEW_SLIM_THEME</variable>'
pankso@275 402 # List all installed Slim themes.
pankso@275 403 for dir in $(ls /usr/share/slim/themes)
pankso@275 404 do
pankso@275 405 THEME_ITEMS="<item>$dir</item>"
pankso@275 406 MAIN_DIALOG=${MAIN_DIALOG}${THEME_ITEMS}
pankso@275 407 done
pankso@275 408 MAIN_DIALOG=${MAIN_DIALOG}'
pankso@275 409 </combobox>
pankso@275 410 <button>
pankso@275 411 <label>Preview</label>
pankso@275 412 <input file icon="video-display"></input>
pankso@275 413 <action>slim -p /usr/share/slim/themes/$NEW_SLIM_THEME &</action>
pankso@275 414 </button>
pankso@275 415 <button>
pankso@275 416 <label>Change</label>
pankso@275 417 <input file icon="forward"></input>
pankso@275 418 <action>sed -i "s/^current_theme.*/current_theme $NEW_SLIM_THEME/" /etc/slim.conf</action>
pankso@275 419 <action>refresh:SLIM_THEME</action>
pankso@275 420 </button>
pankso@275 421 </hbox>
pankso@275 422 <hbox>
pankso@275 423 <text wrap="false">
pankso@275 424 <label>"Configuration file:"</label>
pankso@275 425 </text>
pankso@275 426 <button>
pankso@275 427 <label>/etc/slim.conf</label>
pankso@275 428 <input file icon="accessories-text-editor"></input>
pankso@275 429 <action>leafpad /etc/slim.conf</action>
pankso@275 430 <action>refresh:SLIM_SESSIONS</action>
pankso@275 431 <action>refresh:SLIM_DEF_USER</action>
pankso@275 432 </button>
pankso@275 433 </hbox>
pankso@275 434 </frame>
pankso@275 435 </vbox>'
pankso@275 436 # Display users list throught get_users.
pankso@275 437 MAIN_DIALOG=${MAIN_DIALOG}"
pankso@275 438 <vbox>
pankso@275 439 <tree>
pankso@313 440 <width>600</width><height>210</height>
pankso@275 441 <variable>USER</variable>
pankso@275 442 <label>Login|uid:gid|Name|Home|SHell</label>
pankso@312 443 <input icon_column=\"0\">$0 get_users</input>
pankso@275 444 <action>$0 manage_user</action>
pankso@275 445 <action>refresh:USER</action>
pankso@275 446 </tree>
pankso@275 447 <hbox>
pankso@313 448 <text width-chars=\"60\">
paul@278 449 <label>
pankso@313 450 \"To change passwords or delete users you can double-click on the user name.\"
paul@278 451 </label>
paul@278 452 </text>
pankso@275 453 <button>
pankso@275 454 <label>Add newuser</label>
pankso@275 455 <input file icon=\"gtk-add\"></input>
pankso@275 456 <action>$0 add_user</action>
pankso@275 457 <action>refresh:USER</action>
pankso@275 458 </button>
pankso@275 459 </hbox>
pankso@275 460 </vbox>"
pankso@275 461 export MAIN_DIALOG=${MAIN_DIALOG}'
pankso@275 462 </notebook>
pankso@275 463
pankso@275 464 <hbox>
pankso@313 465
pankso@313 466 <button>
pankso@313 467 <label>Network</label>
pankso@313 468 <input file icon="netbox"></input>
pankso@313 469 <action>netbox &</action>
pankso@313 470 </button>
pankso@313 471 <button>
pankso@313 472 <label>Wireless</label>
pankso@313 473 <input file icon="network-wireless"></input>
pankso@313 474 <action>wifibox &</action>
pankso@313 475 </button>
pankso@313 476 <button>
pankso@313 477 <label>Packages</label>
pankso@313 478 <input file icon="tazpkg"></input>
pankso@313 479 <action>tazpkgbox &</action>
pankso@313 480 </button>
pankso@313 481 <button>
pankso@313 482 <label>Hardware</label>
pankso@313 483 <input file icon="computer"></input>
pankso@313 484 <action>tazhw box &</action>
pankso@313 485 </button>
pankso@313 486 <button>
pankso@313 487 <label>Storage</label>
pankso@313 488 <input file icon="media-flash"></input>
pankso@313 489 <action>mountbox &</action>
pankso@313 490 </button>
pankso@275 491 <button>
pankso@275 492 <label>Exit</label>
pankso@275 493 <input file icon="exit"></input>
pankso@275 494 <action type="exit">Exit</action>
pankso@275 495 </button>
pankso@275 496 </hbox>
pankso@275 497
pankso@275 498 </vbox>
pankso@275 499
pankso@275 500 </window>
pankso@275 501 '
pankso@275 502
pankso@275 503 # Script can be called with an arg to exec a function.
pankso@275 504 if [ -n "$1" ]; then
pankso@275 505 $1
pankso@275 506 else
pankso@275 507 gtkdialog --center --program=MAIN_DIALOG >/dev/null
pankso@275 508 fi
pankso@275 509
pankso@275 510 exit 0