slitaz-arm view rootfs/usr/bin/slitaz-config @ rev 61

Add slitaz-config (will go in slitaz-tools but needed to rel an RPi distro)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Mar 15 17:25:47 2014 +0100 (2014-03-15)
parents
children dd6fa65acfc2
line source
1 #!/bin/sh
2 #
3 # SliTaz Config - A tool with all SliTaz Ncurses config in one place for
4 # text mode system (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 # Main Dialog menu
36 main_box() {
37 dialog \
38 --clear \
39 --title "$title" \
40 --ok-label "Exec" \
41 --cancel-label "Quit" \
42 --menu "" ${height} ${width} 14 \
43 "keyboard" "$(gettext 'System keyboard setting')" \
44 "locale" "$(gettext 'System language setting')" \
45 "root-passwd" "$(gettext 'Change root password')" \
46 "quit" "$(gettext 'Exit from TazBerry tool')" 2>${tmp}
48 # Handle options
49 opt=${?}
50 case "$opt" in
51 1|255) rm -rf ${tmpdir} && exit 0 ;;
52 esac
54 # Handle actions
55 action=$(cat $tmp)
56 case "$action" in
57 keyboard)
58 tazkeymap ;;
59 locale)
60 tazlocale ;;
61 root-passwd)
62 root_passwd ;;
63 quit)
64 rm -rf ${tmpdir} && exit 0 ;;
65 esac
66 }
68 #
69 # Handle commands
70 #
72 case "$1" in
73 *_*)
74 # Execute functions
75 $@ ;;
76 *)
77 while true; do
78 main_box
79 done ;;
80 esac
82 # Clean exit
83 rm -rf ${tmpdir}
84 exit 0