slitaz-tools 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 | a4f64dd9b359 |
children | 7f2d66d108cc |
files | tinyutils/slitaz-config tinyutils/tazx |
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
2.1 --- a/tinyutils/tazx Wed Mar 19 19:27:02 2014 +0100 2.2 +++ b/tinyutils/tazx Sun Mar 23 14:52:32 2014 +0100 2.3 @@ -10,18 +10,21 @@ 2.4 # 2.5 2.6 # 20140317: most xsession, xinitrc are obsolete, provided system files 2.7 -# are in /etc/skel and WM config files are no longer copied by tazx 2.8 -# to user home. If some configs are needed by WMs they should be set 2.9 -# by a /usr/bin/wmname-session script. 2.10 +# are in /etc/skel and WM config files should no longer be copied by 2.11 +# tazx to user home. If some configs are needed by WMs they should 2.12 +# be set by a /usr/bin/wmname-session script I guess. - Pankso 2.13 2.14 . /lib/libtaz.sh 2.15 . /etc/slitaz/slitaz.conf 2.16 +. /etc/slitaz/applications.conf 2.17 + 2.18 +installed="$PKGS_DB/installed" 2.19 + 2.20 export TEXTDOMAIN='slitaz-tools' #i18n 2.21 - 2.22 : ${DIALOG=dialog} 2.23 2.24 # Default value. 2.25 -WM=lxde-session 2.26 +WM=${WINDOW_MANAGER} 2.27 2.28 # Default user for config files in Live mode, id is 1000 since it is 2.29 # created by /etc/init.d/bootopts.sh. 2.30 @@ -144,10 +147,9 @@ 2.31 case $value in 2.32 quit) exit 0 ;; 2.33 *) 2.34 - installed=/var/lib/tazpkg/installed/ 2.35 - [ -d "$installed/xorg-server" ] || tazpkg get-install xorg-server 2.36 + [ -d "$installed/xorg-server" ] || tazpkg -gi xorg-server 2.37 [ -d "$installed/xorg-xf86-video-$value" ] || \ 2.38 - tazpkg get-install xorg-xf86-video-$value 2.39 + tazpkg -gi xorg-xf86-video-$value 2.40 xorg_conf_d ;; 2.41 esac 2.42 } 2.43 @@ -158,13 +160,11 @@ 2.44 exec 3>&1 2.45 value=$($DIALOG \ 2.46 --clear --colors \ 2.47 - --title " $(_n 'Configure X') " \ 2.48 - --menu "\ 2.49 -$(_n 'Tazx dialog helps you to configure your Xorg server.')\n\n\ 2.50 -$(_n 'Window Manager:') \Z2$WM\Zn \n\ 2.51 -$(_n 'X server:') \Z2Xorg\Zn" 16 70 3 \ 2.52 - "xorg" "$(_n 'Install or reconfigure Xorg')" \ 2.53 - "quit" "$(_n 'Quit Tazx utility')" \ 2.54 + --title "{ $(_n 'SliTaz Xorg config') }" \ 2.55 + --menu "" 16 72 10 \ 2.56 + "xorg" "$(_n 'Install or reconfigure Xorg')" \ 2.57 + "xorg-light" "$(_n 'Install Xorg server (light version)')" \ 2.58 + "quit" "$(_n 'Quit Tazx utility')" \ 2.59 2>&1 1>&3) 2.60 retval=$? 2.61 exec 3>&- 2.62 @@ -176,141 +176,50 @@ 2.63 esac 2.64 2.65 # Set selected value. 2.66 - case $value in 2.67 - xorg) 2.68 + case "$value" in 2.69 + xorg) 2.70 install_xorg ;; 2.71 - *) exit 0 ;; 2.72 + xorg-light) 2.73 + [ -d "$installed/xorg-server-light" ] || \ 2.74 + tazpkg -gi xorg-server-light 2.75 + [ -d "$installed/xorg-xf86-video-fbdev" ] || \ 2.76 + tazpkg -gi xorg-xf86-video-fbdev 2.77 + xorg_conf_d ;; 2.78 + *) 2.79 + exit 0 ;; 2.80 esac 2.81 } 2.82 2.83 -# Window manager specific configuration. 2.84 -wm_config() { 2.85 - case $WM in 2.86 - ob|openbox) 2.87 - WM=openbox-session 2.88 - # Check if a personal autostart script exists if OB is installed. 2.89 - if [ -d "$INSTALLED/openbox" ]; then 2.90 - if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then 2.91 - mkdir -p $HOME/.config/openbox 2.92 - cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox 2.93 - fi 2.94 - # Script for default user (uid=1000). 2.95 - if [ ! -f "/home/$USER/.config/openbox/autostart.sh" ]; then 2.96 - mkdir -p /home/$USER/.config/openbox 2.97 - cp /etc/xdg/openbox/autostart.sh /home/$USER/.config/openbox 2.98 - fi 2.99 - if [ ! -f "/home/$USER/.config/openbox/menu.xml" ]; then 2.100 - mkdir -p /home/$USER/.config/openbox 2.101 - cp /etc/xdg/openbox/menu.xml /home/$USER/.config/openbox 2.102 - fi 2.103 - chown -R $USER.users /home/$USER/.config 2.104 - fi ;; 2.105 - jwm) 2.106 - WM=jwm 2.107 - JWM_CONFIG=$HOME/.jwmrc 2.108 - if [ -d "$INSTALLED/jwm" ]; then 2.109 - if [ ! -f "$JWM_CONFIG" ]; then 2.110 - cp /etc/jwm/system.jwmrc $JWM_CONFIG 2.111 - fi 2.112 - # In Live mode default user/root JWM config does not exist and 2.113 - # $HOME is not set, this is because tazx is executed by boot 2.114 - # scripts. 2.115 - if [ ! -f "/home/$USER/.jwmrc" ]; then 2.116 - cp /etc/jwm/system.jwmrc /home/$USER/.jwmrc 2.117 - chown $USER.users /home/$USER/.jwmrc 2.118 - fi 2.119 - if [ ! -f "/root/.jwmrc" -a $(id -u) = 0 ]; then 2.120 - cp /etc/jwm/system.jwmrc /root/.jwmrc 2.121 - fi 2.122 - fi ;; 2.123 - pekwm) 2.124 - WM=pekwm 2.125 - if [ -d "$INSTALLED/pekwm" ]; then 2.126 - if [ -d "$HOME/.pekwm" ]; then 2.127 - cp -R /etc/pekwm $HOME/.pekwm 2.128 - fi 2.129 - # In Live mode we want config before starting pekwm the first time. 2.130 - if [ ! -d "/home/$USER/.pekwm" ]; then 2.131 - cp -R /etc/pekwm /home/$USER/.pekwm 2.132 - chown -R $USER.users /home/$USER/.pekwm 2.133 - chmod +x /home/$USER/.pekwm/start 2.134 - fi 2.135 - if [ ! -d "/root/.pekwm" -a `id -u` = 0 ]; then 2.136 - cp -R /etc/pekwm /root/.pekwm 2.137 - chmod +x /root/.pekwm/start 2.138 - fi 2.139 - fi ;; 2.140 - e17|enlightenment) 2.141 - WM=enlightenment_start ;; 2.142 - fluxbox) 2.143 - WM=startfluxbox ;; 2.144 - dwm|karmen) 2.145 - WM=$WM-session ;; 2.146 - awesome) 2.147 - WM=awesome ;; 2.148 - xfce|xfce4) 2.149 - WM=xfce4-session ;; 2.150 - esac 2.151 -} 2.152 - 2.153 -# Sample xinitrc for user (WM can be specified with F1 at slim login). 2.154 -xinitrc_sample() { 2.155 - cat > $1 << "EOF" 2.156 -# ~/.xinitrc: Executed by slim login manager to startx X session. 2.157 -# You can use F1 with Slim to change your window manager or configure 2.158 -# it permanently with your personal applications.conf file. 2.159 -# 2.160 -. $HOME/.config/slitaz/applications.conf 2.161 - 2.162 -case $1 in 2.163 - e17|enlightenment*) exec enlightenment_start ;; 2.164 - openbox|openbox-session|ob) exec openbox-session ;; 2.165 - dwm|dwm-session) exec dwm-session ;; 2.166 - fluxbox|startfluxbox) exec startfluxbox ;; 2.167 - awesome) exec awesome ;; 2.168 - pekwm) exec pekwm ;; 2.169 - karmen|karmen-session) exec karmen-session ;; 2.170 - jwm) lxpanel & exec jwm ;; 2.171 - xfce|xfce4|xfce4-session) xfce4-session ;; 2.172 - *) exec $WINDOW_MANAGER ;; 2.173 -esac 2.174 -EOF 2.175 - # Set default WM in applications.conf user file. Default WM can be 2.176 - # configured graphically with 'desktopbox tazapps' 2.177 - . $CONFIG 2.178 - sed -i 's|WINDOW_MANAGER=.*|WINDOW_MANAGER="'$WM'"|' $CONFIG 2.179 -} 2.180 - 2.181 # ~/.xinitrc for X login from a DM. 2.182 creat_xinitrc() { 2.183 - local APCONF=/etc/slitaz/applications.conf 2.184 - 2.185 - CONFIG=$HOME/.config/slitaz/applications.conf 2.186 - if [ ! -f $CONFIG ]; then 2.187 - mkdir -p $(dirname $CONFIG); cp $APCONF $CONFIG 2.188 + apps_conf=/etc/slitaz/applications.conf 2.189 + user_conf="$HOME/.config/slitaz/applications.conf" 2.190 + xinitrc="$HOME/.xinitrc" 2.191 + if [ ! -f "$user_conf" ]; then 2.192 + mkdir -p $(dirname $user_conf); cp ${apps_conf} ${user_conf} 2.193 fi 2.194 - xinitrc_sample $HOME/.xinitrc 2.195 + if [ ! -f "$xinitrc" ]; then 2.196 + cp /etc/skel/.xinitrc ${xinitrc} 2.197 + fi 2.198 2.199 # Make .xinitrc and config for /etc/skel so new added user will get 2.200 # a working X session. 2.201 if test $(id -u) = 0; then 2.202 - CONFIG=/etc/skel/.config/slitaz/applications.conf 2.203 - mkdir -p $(dirname $CONFIG); cp -f $APCONF $CONFIG 2.204 - xinitrc_sample /etc/skel/.xinitrc 2.205 + user_conf="/etc/skel/.config/slitaz/applications.conf" 2.206 + mkdir -p $(dirname $user_conf); cp -f ${apps_conf} ${user_conf} 2.207 fi 2.208 2.209 - # In Live mode default user needs a xinitrc, since tazx 2.210 - # is executed only by root. 2.211 - CONFIG=/home/$USER/.config/slitaz/applications.conf 2.212 - if [ ! -f $CONFIG ]; then 2.213 - mkdir -p $(dirname $CONFIG); cp $APCONF $CONFIG 2.214 + # In Live mode default user needs a xinitrc, since tazx is executed 2.215 + # only by root. 2.216 + user_conf="/home/$USER/.config/slitaz/applications.conf" 2.217 + xinitrc="/home/$USER/.xinitrc" 2.218 + if [ ! -f "$user_conf" ]; then 2.219 + mkdir -p $(dirname $user_conf); cp ${apps_conf} ${user_conf} 2.220 + chown -R $USER.users $(dirname $user_conf) 2.221 fi 2.222 - chown -R $USER.users /home/$USER/.config/slitaz 2.223 - 2.224 - FILE=/home/$USER/.xinitrc 2.225 - if [ ! -f $FILE ]; then 2.226 - xinitrc_sample $FILE 2.227 - chown $USER.users $FILE 2.228 + if [ ! -f "$xinitrc" ]; then 2.229 + cp -f /etc/skel/.xinitrc ${xinitrc} 2.230 + chown $USER.users ${xinitrc} 2.231 fi 2.232 } 2.233 2.234 @@ -318,60 +227,44 @@ 2.235 # only by startx, Slim login manager uses .xinitrc). 2.236 creat_xsession() { 2.237 local xsession=$HOME/.xsession 2.238 - [ -f $xsession ] && cp -f $xsession $HOME/.previous_xsession 2.239 - cat > $xsession << _EOF_ 2.240 -# ~/.xsession: Start X window session manually on your system (startx). 2.241 + [ -f "$xsession" ] && cp -f ${xsession} ${xsession}.bak 2.242 + cat > ${xsession} << EOT 2.243 +# ~/.xsession: Start X session manually on your system with: startx 2.244 # 2.245 Xorg & 2.246 #xterm & 2.247 -_EOF_ 2.248 - # LXpanel by default with JWM. 2.249 - if [ "$WM" = "jwm" ]; then 2.250 - echo 'lxpanel &' >> $xsession 2.251 - fi 2.252 - echo "exec $WM" >> $xsession 2.253 - chmod 700 $xsession 2.254 +exec $WM 2.255 +EOT 2.256 + chmod 700 ${xsession} 2.257 } 2.258 2.259 - 2.260 -# Commands - WM can be specified on cmdline. 2.261 +# Commands 2.262 2.263 case "$1" in 2.264 install-xorg) 2.265 - check_root $@ 2.266 - if [ -n "$2" ]; then 2.267 - WM=$2 2.268 - fi 2.269 - echo "xorg" > /etc/X11/screen.conf 2.270 + check_root 2.271 install_xorg 2.272 - wm_config 2.273 creat_xinitrc 2.274 creat_xsession ;; 2.275 + 2.276 config-xorg) 2.277 - check_root $@ 2.278 - if [ -n "$2" ]; then 2.279 - WM=$2 2.280 - fi 2.281 - echo "xorg" > /etc/X11/screen.conf 2.282 - wm_config 2.283 + check_root 2.284 creat_xinitrc 2.285 creat_xsession 2.286 - xorg_conf_d 2.287 + xorg_conf_d 2.288 + # Handle live option: screen= 2.289 if grep -qs screen= /proc/cmdline ; then 2.290 MODE="$(sed 's/.*screen=\([0-9]*x[0-9]*\).*/\1/' < /proc/cmdline)" 2.291 sed -i "s/.*EndSubSection.*/\\t\\tModes\\t\"$MODE\"\\n&/" \ 2.292 /etc/X11/xorg.conf.d/70-Screen.conf 2.293 fi ;; 2.294 + 2.295 + *help) 2.296 + echo "Usage: $(basename $0) [install-xorg|config-xorg|]" ;; 2.297 + 2.298 *) 2.299 # User can get a new .xinitrc with tazx from cmdline. 2.300 - if [ -n "$1" ]; then 2.301 - WM=$1 2.302 - fi 2.303 - if test $(id -u) = 0; then 2.304 - echo "xorg" > /etc/X11/screen.conf 2.305 - config_dialog 2.306 - fi 2.307 - wm_config 2.308 + [ $(id -u) == 0 ] && config_dialog 2.309 creat_xinitrc 2.310 creat_xsession ;; 2.311 esac