slitaz-tools view tinyutils/slitaz-config @ rev 840

Add slitaz-config and clean tazx
author Christophe Lincoln <pankso@slitaz.org>
date Sun Mar 23 14:52:32 2014 +0100 (2014-03-23)
parents
children 4bdf432f7525
line source
1 #!/bin/sh
2 #
3 # SliTaz Config - A tool with all SliTaz Ncurses configs in one place for
4 # text mode systems (server, ARM devices)
5 #
6 # Copyright (C) 2014 SliTaz ARM - BSD License
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
9 . /lib/libtaz.sh
10 check_root
12 title="{ SliTaz Config }"
13 tmpdir="/tmp/$(basename $0)"
14 tmp="$tmpdir/$$"
15 height="20"
16 width="72"
18 # Use a tmp directory
19 mkdir -p ${tmpdir}
21 #
22 # GUI Functions
23 #
25 # Set root passwd
26 root_passwd() {
27 dialog \
28 --inputbox "Enter new root password:" \
29 10 ${width} 2>${tmp}
30 passwd=$(cat $tmp)
31 [ "$passwd" == "" ] && return 0
32 echo "root:$passwd" | chpasswd --md5
33 }
35 set_date() {
36 clear && newline
37 echo -n "Old date:"; date
38 rdate -s 203.129.68.14 2>/dev/null
39 echo -n "New date:"; date
40 sleep 4
41 }
43 # Main Dialog menu
44 main_box() {
45 dialog \
46 --clear --title "$title" \
47 --ok-label "Exec" --cancel-label "Quit" \
48 --menu "" ${height} ${width} 14 \
49 "keyboard" "$(gettext 'System keyboard setting')" \
50 "locale" "$(gettext 'System language setting')" \
51 "root-passwd" "$(gettext 'Change root password')" \
52 "set-date" "$(gettext 'Set system date from the web')" \
53 "quit" "$(gettext 'Exit from SliTaz Config')" 2>${tmp}
55 # Handle options
56 opt=${?}
57 case "$opt" in
58 1|255) rm -rf ${tmpdir} && exit 0 ;;
59 esac
61 # Handle actions
62 action=$(cat $tmp)
63 case "$action" in
64 keyboard) tazkeymap ;;
65 locale) tazlocale ;;
66 root-passwd) root_passwd ;;
67 set-date) set_date ;;
68 quit) rm -rf ${tmpdir} && exit 0 ;;
69 esac
70 }
72 #
73 # Handle commands
74 #
76 case "$1" in
77 *_*)
78 # Execute functions
79 $@ ;;
80 *)
81 while true; do
82 main_box
83 done ;;
84 esac
86 # Clean exit
87 rm -rf ${tmpdir}
88 exit 0