slitaz-tools diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tinyutils/slitaz-config Sun Mar 23 14:52:32 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# SliTaz Config - A tool with all SliTaz Ncurses configs in one place for 1.7 +# text mode systems (server, ARM devices) 1.8 +# 1.9 +# Copyright (C) 2014 SliTaz ARM - BSD License 1.10 +# Author: Christophe Lincoln <pankso@slitaz.org> 1.11 +# 1.12 +. /lib/libtaz.sh 1.13 +check_root 1.14 + 1.15 +title="{ SliTaz Config }" 1.16 +tmpdir="/tmp/$(basename $0)" 1.17 +tmp="$tmpdir/$$" 1.18 +height="20" 1.19 +width="72" 1.20 + 1.21 +# Use a tmp directory 1.22 +mkdir -p ${tmpdir} 1.23 + 1.24 +# 1.25 +# GUI Functions 1.26 +# 1.27 + 1.28 +# Set root passwd 1.29 +root_passwd() { 1.30 + dialog \ 1.31 + --inputbox "Enter new root password:" \ 1.32 + 10 ${width} 2>${tmp} 1.33 + passwd=$(cat $tmp) 1.34 + [ "$passwd" == "" ] && return 0 1.35 + echo "root:$passwd" | chpasswd --md5 1.36 +} 1.37 + 1.38 +set_date() { 1.39 + clear && newline 1.40 + echo -n "Old date:"; date 1.41 + rdate -s 203.129.68.14 2>/dev/null 1.42 + echo -n "New date:"; date 1.43 + sleep 4 1.44 +} 1.45 + 1.46 +# Main Dialog menu 1.47 +main_box() { 1.48 + dialog \ 1.49 + --clear --title "$title" \ 1.50 + --ok-label "Exec" --cancel-label "Quit" \ 1.51 + --menu "" ${height} ${width} 14 \ 1.52 +"keyboard" "$(gettext 'System keyboard setting')" \ 1.53 +"locale" "$(gettext 'System language setting')" \ 1.54 +"root-passwd" "$(gettext 'Change root password')" \ 1.55 +"set-date" "$(gettext 'Set system date from the web')" \ 1.56 +"quit" "$(gettext 'Exit from SliTaz Config')" 2>${tmp} 1.57 + 1.58 + # Handle options 1.59 + opt=${?} 1.60 + case "$opt" in 1.61 + 1|255) rm -rf ${tmpdir} && exit 0 ;; 1.62 + esac 1.63 + 1.64 + # Handle actions 1.65 + action=$(cat $tmp) 1.66 + case "$action" in 1.67 + keyboard) tazkeymap ;; 1.68 + locale) tazlocale ;; 1.69 + root-passwd) root_passwd ;; 1.70 + set-date) set_date ;; 1.71 + quit) rm -rf ${tmpdir} && exit 0 ;; 1.72 + esac 1.73 +} 1.74 + 1.75 +# 1.76 +# Handle commands 1.77 +# 1.78 + 1.79 +case "$1" in 1.80 + *_*) 1.81 + # Execute functions 1.82 + $@ ;; 1.83 + *) 1.84 + while true; do 1.85 + main_box 1.86 + done ;; 1.87 +esac 1.88 + 1.89 +# Clean exit 1.90 +rm -rf ${tmpdir} 1.91 +exit 0