flavors rev 19

core: rm all tools (again)
author Christophe Lincoln <pankso@slitaz.org>
date Thu Feb 11 14:41:24 2010 +0100 (2010-02-11)
parents 4951c830c8ea
children 1082b7a00eed
files core/rootfs/sbin/tazlocale core/rootfs/usr/bin/slitaz-installer core/rootfs/usr/bin/wifibox
line diff
     1.1 --- a/core/rootfs/sbin/tazlocale	Thu Feb 11 14:40:09 2010 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,137 +0,0 @@
     1.4 -#!/bin/sh
     1.5 -#
     1.6 -# Tazlocale: SliTaz GNU/Linux locale setting using dialog boxes.
     1.7 -# Configuration file is : /etc/locale.conf
     1.8 -#
     1.9 -# 20100201 <pankso@slitaz.org> - GNU gpl.
    1.10 -#
    1.11 -
    1.12 -# Check if user is root.
    1.13 -if test $(id -u) != 0; then
    1.14 -	echo -e "\nYou must be root to run `basename $0`!"
    1.15 -	echo -e "Type su and root password to become super-user.\n"
    1.16 -	exit 1
    1.17 -fi
    1.18 -
    1.19 -get_messages()
    1.20 -{
    1.21 -	[ -f "/etc/locale.conf" ] && . /etc/locale.conf
    1.22 -	LANGUAGE=${LANG%_*}
    1.23 -	[ "$LANG" = "C" ] && LANGUAGE="en_US"
    1.24 -	case $LANGUAGE in
    1.25 -		fr*)
    1.26 -			RECONFIG_MSG="
    1.27 -Veuilliez fermer votre session et vous reloguer pour utiliser SliTaz \
    1.28 -avec la locale : $LANG" ;;
    1.29 -		*)
    1.30 -			RECONFIG_MSG="
    1.31 -Please logout of your current session and login again to use SliTaz \
    1.32 -with $LANG locale." ;;
    1.33 -	esac
    1.34 -}
    1.35 -
    1.36 -# Create symlink to translated files provide by SliTaz language pack,
    1.37 -# doc and config files.
    1.38 -link_language_files()
    1.39 -{
    1.40 -	. /etc/locale.conf
    1.41 -	LANGUAGE=${LANG%_*}
    1.42 -	[ "$LANG" = "C" ] && LANGUAGE="en"
    1.43 -	# Openbox menu in /usr/share/doc/slitaz
    1.44 -	if [ -f /etc/xdg/openbox/menu.$LANGUAGE.xml ]; then
    1.45 -		cd /etc/xdg/openbox && rm -f menu.xml
    1.46 -		ln -s menu.$LANGUAGE.xml menu.xml
    1.47 -	fi
    1.48 -	# Documentation in /usr/share/doc/slitaz
    1.49 -	if [ -f /usr/share/doc/slitaz/index.$LANGUAGE.html ]; then
    1.50 -		cd /usr/share/doc/slitaz && rm -f index.html
    1.51 -		ln -s index.$LANGUAGE.html index.html
    1.52 -	fi
    1.53 -	# SliTaz Software Manuals
    1.54 -	for soft in tazpkg tazlito tazusb tazwok
    1.55 -	do
    1.56 -		if [ -f /usr/share/doc/$soft/$soft.$LANGUAGE.html ]; then
    1.57 -			cd /usr/share/doc/$soft && rm -f $soft.html
    1.58 -			ln -s $soft.$LANGUAGE.html $soft.html
    1.59 -		fi
    1.60 -	done
    1.61 -}
    1.62 -
    1.63 -# Locale name displayed.
    1.64 -get_locale_name()
    1.65 -{
    1.66 -	for i in `ls -1 /usr/share/i18n/locales/ | grep ^[a-z][a-z]_[A-Z][A-Z]`
    1.67 -	do
    1.68 -		#name=`locale -a -v | grep -A 2 "locale: $i" | grep "title" | \
    1.69 -		#	cut -d " " -f 7`
    1.70 -		echo "$i Locale"
    1.71 -	done
    1.72 -}
    1.73 -
    1.74 -# We have no locale files in /usr/lib/locale by default. Run localedef in
    1.75 -# background to have a faster boot.
    1.76 -gen_utf8_locale()
    1.77 -{
    1.78 -	localedef -i $locale -c -f UTF-8 /usr/lib/locale/$locale &
    1.79 -}
    1.80 -
    1.81 -# Dialog menu.
    1.82 -dialog_menu()
    1.83 -{
    1.84 -	exec 3>&1
    1.85 -	locale=`$DIALOG  --clear \
    1.86 -	--title " SliTaz language configuration " \
    1.87 -	--menu "" 15 70 5 \
    1.88 -"en" "English" \
    1.89 -$(get_locale_name) \
    1.90 -2>&1 1>&3`
    1.91 -	retval=$?
    1.92 -	exec 3>&-
    1.93 -	case $retval in
    1.94 -		0)
    1.95 -			continue ;;
    1.96 -		1)
    1.97 -			echo "Cancel pressed."
    1.98 -			exit 0 ;;
    1.99 -		255)
   1.100 -			if test -n "$locale"; then
   1.101 -				echo "$locale"
   1.102 -			else
   1.103 -				echo "ESC pressed."
   1.104 -				exit 0
   1.105 -			fi ;;
   1.106 -	esac
   1.107 -	# Default: C = English
   1.108 -	[ "$locale" = "en" ] && locale="en_US"
   1.109 -	[ -s /etc/locale.conf ] && RECONFIG="yes"
   1.110 -	# System configuration
   1.111 -	echo "LANG=$locale" > /etc/locale.conf
   1.112 -	echo "LC_ALL=$locale" >> /etc/locale.conf
   1.113 -	export LANG=$locale LC_ALL=$locale
   1.114 -	gen_utf8_locale
   1.115 -	get_messages
   1.116 -	# If it's a reconfiguration give an info message.
   1.117 -	if [ -n "$RECONFIG" ]; then
   1.118 -		$DIALOG --clear \
   1.119 -			--title " Information " \
   1.120 -			--msgbox "$RECONFIG_MSG" 16 70
   1.121 -	fi
   1.122 -}
   1.123 -
   1.124 -case "$1" in
   1.125 -	*_*)
   1.126 -		# Execute functions (can be called from an other apps).
   1.127 -		$1 ;;
   1.128 -	link-files)
   1.129 -		link_language_files ;;
   1.130 -	list)
   1.131 -		echo ""
   1.132 -		locale -a
   1.133 -		echo "" ;;
   1.134 -	*)
   1.135 -		: ${DIALOG=dialog}
   1.136 -		dialog_menu
   1.137 -		link_language_files ;;
   1.138 -esac
   1.139 -
   1.140 -exit 0
     2.1 --- a/core/rootfs/usr/bin/slitaz-installer	Thu Feb 11 14:40:09 2010 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,1051 +0,0 @@
     2.4 -#!/bin/sh
     2.5 -# slitaz-installer - SliTaz GNU/Linux installer.
     2.6 -#
     2.7 -# So this is SliTaz installer using dialog boxes. All the comments are in
     2.8 -# English but displayed messages are in French. The script starts with a
     2.9 -# few main variables, then all the functions and then a sequence of functions.
    2.10 -#
    2.11 -# (C) 2007-2009 SliTaz - GNU General Public License v3.
    2.12 -#
    2.13 -# Author : Christophe Lincoln <pankso@slitaz.org>
    2.14 -#
    2.15 -VERSION=2.0
    2.16 -
    2.17 -: ${DIALOG=dialog}
    2.18 -
    2.19 -# We need to know cdrom device and kernel version string to copy files.
    2.20 -DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
    2.21 -CDROM=/dev/$DRIVE_NAME
    2.22 -KERNEL=vmlinuz-`uname -r`
    2.23 -TARGET_ROOT=/mnt/target
    2.24 -LOG=/var/log/slitaz-installer.log
    2.25 -BACKLIST="SliTaz GNU/Linux installer"
    2.26 -ACTION=$1
    2.27 -
    2.28 -#######################
    2.29 -# Installer functions #
    2.30 -#######################
    2.31 -
    2.32 -# Messages language setting.
    2.33 -set_messages()
    2.34 -{
    2.35 -	case $LANG in
    2.36 -		de*)
    2.37 -			. /usr/share/slitaz/messages/de/installer.msg ;;
    2.38 -		fr*)
    2.39 -			. /usr/share/slitaz/messages/fr/installer.msg ;;
    2.40 -		hu*)
    2.41 -			. /usr/share/slitaz/messages/hu/installer.msg ;;
    2.42 -		pt*)
    2.43 -			. /usr/share/slitaz/messages/pt/installer.msg ;;
    2.44 -		*)
    2.45 -			. /usr/share/slitaz/messages/en/installer.msg ;;
    2.46 -	esac
    2.47 -}
    2.48 -
    2.49 -# Display error message.
    2.50 -error_message()
    2.51 -{
    2.52 -	$DIALOG --title " Error " \
    2.53 -		--colors --backtitle "$BACKLIST" \
    2.54 -		--clear --msgbox "\n$ERROR_MSG" 18 70
    2.55 -}
    2.56 -
    2.57 -# Exit install if user is not root.
    2.58 -check_root()
    2.59 -{
    2.60 -	if test $(id -u) != 0 ; then
    2.61 -	ERROR_MSG="\
    2.62 -[\Z6en\Zn] You must be root administrator to start SliTaz installer, please \
    2.63 -use 'su' to get a root SHell and restart installation.\n\n
    2.64 -[\Z6fr\Zn] Vous devez être root pour installer SLiTaz GNU/Linux. Vous pouvez \
    2.65 -utiliser 'su' suivi du mot de passe administrateur pour devenir root \
    2.66 -et relancer l'installation."
    2.67 -		error_message
    2.68 -		exit 0
    2.69 -	fi
    2.70 -}
    2.71 -
    2.72 -# This function is used after each screen to contine or abort install.
    2.73 -check_retval()
    2.74 -{
    2.75 -	case $retval in
    2.76 -		0)
    2.77 -			continue ;;
    2.78 -		1)
    2.79 -			echo -e "\nVoluntary exit.\n" && exit 0 ;;
    2.80 -		3)
    2.81 -			continue ;;
    2.82 -		255)
    2.83 -			echo -e "ESC pressed.\n" && exit 0 ;;
    2.84 -	esac
    2.85 -}
    2.86 -
    2.87 -# Start install with basic information.
    2.88 -start_installer()
    2.89 -{
    2.90 -	$DIALOG --title " Install or Upgrade " \
    2.91 -		--backtitle "$BACKLIST" \
    2.92 -		--extra-button --extra-label "Upgrade" \
    2.93 -		--ok-label "Install" \
    2.94 -		--clear --colors --yesno "$START_INSTALL_MSG" 18 70
    2.95 -	retval=$?
    2.96 -		case $retval in
    2.97 -		0)
    2.98 -			ACTION=install ;;
    2.99 -		1)
   2.100 -			echo -e "\nVoluntary exit.\n" && exit 0 ;;
   2.101 -		3)
   2.102 -			ACTION=upgrade ;;
   2.103 -		255)
   2.104 -			echo -e "ESC pressed.\n" && exit 0 ;;
   2.105 -	esac
   2.106 -	echo "start_installer: `date`" > $LOG
   2.107 -}
   2.108 -
   2.109 -# Mount cdrom and verify if it's really SliTaz CD.
   2.110 -mount_cdrom()
   2.111 -{
   2.112 -	ERROR_MSG=""
   2.113 -	(
   2.114 -	echo "XXX" && echo 30
   2.115 -	echo -e "\nCreating mount point (/media/cdrom)..."
   2.116 -	echo "XXX"
   2.117 -	mkdir -p /media/cdrom
   2.118 -	sleep 1
   2.119 -	# First try to mount a cdrom
   2.120 -	if mount -t iso9660 $CDROM /media/cdrom 2>>$LOG; then
   2.121 -		echo "XXX" && echo 60
   2.122 -		echo -e "\nUsing file from cdrom ($CDROM)..."
   2.123 -		echo "XXX"
   2.124 -		sleep 2
   2.125 -	else
   2.126 -		# We may be in LiveUSB mode
   2.127 -		if [ -d /home/boot ]; then
   2.128 -			echo "XXX" && echo 60
   2.129 -			echo -e "\nUsing file from USB device..."
   2.130 -			echo "XXX"
   2.131 -			rm /media/cdrom/boot 2>/dev/null
   2.132 -			ln -s /home/boot /media/cdrom/boot
   2.133 -			sleep 2
   2.134 -		fi
   2.135 -	fi
   2.136 -
   2.137 -	echo "XXX" && echo 90
   2.138 -	echo -e "\nChecking installation media..."
   2.139 -	echo "XXX"
   2.140 -	sleep 2
   2.141 -	) |
   2.142 -	$DIALOG --title " Mounting cdrom " \
   2.143 -		--backtitle "$BACKLIST" \
   2.144 -		--gauge "Preparing the installation media..." 18 70 0
   2.145 -	# Exit with error msg if no rootfs.gz found.
   2.146 -	if [ ! -f /media/cdrom/boot/rootfs.gz ]; then
   2.147 -		ERROR_MSG="$MOUNT_CDROM_ERROR_MSG"
   2.148 -		error_message
   2.149 -		echo "missing: /media/cdrom/boot/rootfs.gz" >>$LOG
   2.150 -		exit 1
   2.151 -	fi
   2.152 -}
   2.153 -
   2.154 -# Display a list of available partitions.
   2.155 -fdisk_list()
   2.156 -{
   2.157 -	LIST_PARTITIONS=`fdisk -l | grep ^/dev | sed s/'e Win95'/'e'/g`
   2.158 -	$DIALOG --title " Partition tables " \
   2.159 -		--backtitle "$BACKLIST" \
   2.160 -		--clear --msgbox "\n
   2.161 -Available partitions :\n\n
   2.162 -$LIST_PARTITIONS" 18 70
   2.163 -}
   2.164 -
   2.165 -# We need a partition to install to (inputbox).
   2.166 -ask_for_target_dev()
   2.167 -{
   2.168 -	exec 3>&1
   2.169 -	TARGET_DEV=`$DIALOG --title " Root Partition " \
   2.170 -		--backtitle "$BACKLIST" --clear \
   2.171 -		--extra-label "List" --extra-button \
   2.172 -		--colors --inputbox "$ASK_FOR_TARGET_DEV_MSG" 18 70 2>&1 1>&3`
   2.173 -	retval=$?
   2.174 -	exec 3>&-
   2.175 -	check_retval
   2.176 -	# Display list and come back.
   2.177 -	if [ "$retval" = "3" ]; then
   2.178 -		fdisk_list
   2.179 -		ask_for_target_dev
   2.180 -	fi
   2.181 -	# Empty value.
   2.182 -	if [ -z $TARGET_DEV ]; then
   2.183 -		ask_for_target_dev
   2.184 -	fi
   2.185 -	set_messages
   2.186 -	# Check if specified device exists in /proc/partitions.
   2.187 -	DEV_NAME=${TARGET_DEV#/dev/}
   2.188 -	if cat /proc/partitions | grep -q $DEV_NAME; then
   2.189 -		if [ "$DEV_NAME" = "$TARGET_DEV" ]; then
   2.190 -			TARGET_DEV="/dev/$DEV_NAME"
   2.191 -		fi
   2.192 -		echo "ask_for_target_dev: $TARGET_DEV" >>$LOG
   2.193 -	else
   2.194 -		ERROR_MSG="Partition \Z2$TARGET_DEV\Zn doesn't exist."
   2.195 -		error_message
   2.196 -		ask_for_target_dev
   2.197 -	fi
   2.198 -}
   2.199 -
   2.200 -# Mkfs if needed/wanted on /.
   2.201 -ask_for_mkfs_target_dev()
   2.202 -{
   2.203 -	$DIALOG --title " Format " \
   2.204 -		--backtitle "$BACKLIST" \
   2.205 -		--clear --colors --yesno "$ASK_FOR_MKFS_TARGET_DEV_MSG" 18 70
   2.206 -	retval=$?
   2.207 -	case $retval in
   2.208 -		0)
   2.209 -			MKFS_TARGET_DEV="ext3"
   2.210 -			echo "mkfs_target_dev: ext3" >>$LOG ;;
   2.211 -		1)
   2.212 -			CLEAN="clean"
   2.213 -			echo "mkfs_target_dev: clean" >>$LOG ;;
   2.214 -		255)
   2.215 -			echo -e "ESC pressed.\n" && exit 0 ;;
   2.216 -	esac
   2.217 -
   2.218 -}
   2.219 -
   2.220 -# We can have a separate partition for /home.
   2.221 -ask_for_home()
   2.222 -{
   2.223 -	exec 3>&1
   2.224 -	HOME_DEV=`$DIALOG --title " Home Partition " \
   2.225 -		--backtitle "$BACKLIST" --clear \
   2.226 -		--extra-label "List" --extra-button \
   2.227 -		--colors --inputbox "
   2.228 -On most GNU/Linux systems users personal files are stored in the directory \
   2.229 -/home. Home can be on a separate partition or another hard disk.
   2.230 -
   2.231 -\Z2Home partition to use (Optional):\Zn" 18 70 2>&1 1>&3`
   2.232 -	retval=$?
   2.233 -	exec 3>&-
   2.234 -	check_retval
   2.235 -	# Display list and come back.
   2.236 -	if [ "$retval" = "3" ]; then
   2.237 -		fdisk_list
   2.238 -		ask_for_home
   2.239 -	fi
   2.240 -	if [ -n "$HOME_DEV" ]; then
   2.241 -		# Check if specified device exists in /proc/partitions.
   2.242 -		DEV_NAME=${HOME_DEV#/dev/}
   2.243 -		if cat /proc/partitions | grep -q $DEV_NAME; then
   2.244 -			if [ "$DEV_NAME" = "$HOME_DEV" ]; then
   2.245 -				HOME_DEV="/dev/$DEV_NAME"
   2.246 -			fi
   2.247 -			echo "ask_for_home: $HOME_DEV" >>$LOG
   2.248 -		else
   2.249 -			ERROR_MSG="Partition \Z2$HOME_DEV\Zn doesn't exist."
   2.250 -			error_message
   2.251 -			ask_for_home
   2.252 -		fi
   2.253 -	fi
   2.254 -}
   2.255 -
   2.256 -# Mkfs if needed/wanted on /.
   2.257 -ask_for_mkfs_home()
   2.258 -{
   2.259 -	$DIALOG --title " Format " \
   2.260 -		--backtitle "$BACKLIST" \
   2.261 -		--clear --colors --yesno "
   2.262 -Here you can format the /home partition: $HOME_DEV
   2.263 -
   2.264 -SliTaz uses ext3 by default but another filesystem can be used if wanted, \
   2.265 -for this please adjust /etc/fstab after installation.
   2.266 -
   2.267 -\Z2Do you want to format (Option): $HOME_DEV\Zn" 18 70
   2.268 -	retval=$?
   2.269 -	case $retval in
   2.270 -		0)
   2.271 -			MKFS_HOME="ext3"
   2.272 -			echo "mkfs_home: ext3" >>$LOG ;;
   2.273 -		1)
   2.274 -			MKFS_HOME=""
   2.275 -			echo "mkfs_home: no" >>$LOG ;;
   2.276 -		255)
   2.277 -			echo -e "ESC pressed.\n" && exit 0 ;;
   2.278 -	esac
   2.279 -
   2.280 -}
   2.281 -
   2.282 -# Ask for hostname before installing files.
   2.283 -ask_for_hostname()
   2.284 -{
   2.285 -	exec 3>&1
   2.286 -	HOSTNAME=`$DIALOG --title " Hostname " \
   2.287 -		--backtitle "$BACKLIST" --clear \
   2.288 -		--colors --inputbox "$ASK_FOR_HOSTNAME_MSG" 18 70 "slitaz" 2>&1 1>&3`
   2.289 -	retval=$?
   2.290 -	exec 3>&-
   2.291 -	check_retval
   2.292 -	# Empty value.
   2.293 -	if [ -z $HOSTNAME ]; then
   2.294 -		HOSTNAME="slitaz"
   2.295 -	fi
   2.296 -}
   2.297 -
   2.298 -# Ask for root password and default user settings.
   2.299 -ask_for_users_settings()
   2.300 -{
   2.301 -	# Root passwd
   2.302 -	exec 3>&1
   2.303 -	ROOT_PASSWD=`$DIALOG --title " Root password " \
   2.304 -		--backtitle "$BACKLIST" --clear \
   2.305 -		--colors --nocancel --inputbox "
   2.306 -The root administrator privilege lets you manage and configure the full \
   2.307 -system. A root user can damage your system so you should always setup a \
   2.308 -strong password with special characters and/or numbers.
   2.309 -
   2.310 -\Z2Please specify the Root password for your new system:\Zn" 18 70 "root" 2>&1 1>&3`
   2.311 -	retval=$?
   2.312 -	exec 3>&-
   2.313 -	check_retval
   2.314 -	# Prevent empty value.
   2.315 -	if [ -z $ROOT_PASSWD ]; then
   2.316 -		ROOT_PASSWD="root"
   2.317 -	fi
   2.318 -	# Default user
   2.319 -	exec 3>&1
   2.320 -	USER=`$DIALOG --title " User name " \
   2.321 -		--backtitle "$BACKLIST" --clear \
   2.322 -		--colors --nocancel --inputbox "
   2.323 -The default user for the system will have their personal files stored \
   2.324 -in /home/*user* (and will be automatically added to the audio group).
   2.325 -
   2.326 -\Z2Default user name login:\Zn" 18 70 "tux" 2>&1 1>&3`
   2.327 -	retval=$?
   2.328 -	exec 3>&-
   2.329 -	check_retval
   2.330 -	# Prevent empty value.
   2.331 -	if [ -z $USER ]; then
   2.332 -		USER="tux"
   2.333 -	fi
   2.334 -	# User passwd
   2.335 -	exec 3>&1
   2.336 -	USER_PASSWD=`$DIALOG --title " User password " \
   2.337 -		--backtitle "$BACKLIST" --clear \
   2.338 -		--colors --nocancel --inputbox "
   2.339 -The password for default user $USER. It may be a security risk if too \
   2.340 -weak and should always be strong if you use a SSH connection through the web.
   2.341 -
   2.342 -\Z2Please specify $USER password:\Zn" 18 70 "tux" 2>&1 1>&3`
   2.343 -	retval=$?
   2.344 -	exec 3>&-
   2.345 -	check_retval
   2.346 -	# Prevent empty value.
   2.347 -	if [ -z $USER_PASSWD ]; then
   2.348 -		USER_PASSWD="tux"
   2.349 -	fi
   2.350 -}
   2.351 -
   2.352 -# Tiny summary and last chance to cancel or restart for user.
   2.353 -summary()
   2.354 -{
   2.355 -	$DIALOG --title " Summary " \
   2.356 -		--backtitle "$BACKLIST" \
   2.357 -		--clear --colors --yesno "
   2.358 -Installation settings summary and last chance to cancel or restart all \
   2.359 -installation steps.
   2.360 -
   2.361 -Root partition: $TARGET_DEV
   2.362 -Home partition: $HOME_DEV
   2.363 -Hostname: $HOSTNAME
   2.364 -Default user: $USER
   2.365 -
   2.366 -\Z2Go and install SliTaz or cancel?\Zn" 18 70
   2.367 -	retval=$?
   2.368 -	check_retval
   2.369 -}
   2.370 -
   2.371 -# Mount and mkfs with progress.
   2.372 -prepare_partitions()
   2.373 -{
   2.374 -	(
   2.375 -	echo "XXX" && echo 30
   2.376 -	echo -e "\nPreparing target partition..."
   2.377 -	echo "XXX"
   2.378 -	# Mount point can be already used.
   2.379 -	if mount | grep -q $TARGET_ROOT; then
   2.380 -		umount $TARGET_ROOT 2>$LOG
   2.381 -	fi
   2.382 -	sleep 2
   2.383 -
   2.384 -	if [ "$MKFS_TARGET_DEV" == "ext3" ]; then
   2.385 -		echo "XXX" && echo 50
   2.386 -		echo -e "\nExecuting mkfs.ext3 on $TARGET_DEV"
   2.387 -		echo "XXX"
   2.388 -		mkfs.ext3 $TARGET_DEV >>$LOG 2>>$LOG
   2.389 -	else
   2.390 -		echo "XXX" && echo 50
   2.391 -		echo -e "\nThe partition ($TARGET_DEV) will be cleaned..."
   2.392 -		echo "XXX"
   2.393 -		sleep 2
   2.394 -	fi
   2.395 -
   2.396 -	if [ "$MKFS_HOME" == "ext3" ]; then
   2.397 -		echo "XXX" && echo 70
   2.398 -		echo -e "\nExecuting mkfs.ext3 on $HOME_DEV"
   2.399 -		echo "XXX"
   2.400 -		mkfs.ext3 -L "Home" $HOME_DEV >>$LOG 2>>$LOG
   2.401 -	else
   2.402 -		echo "XXX" && echo 70
   2.403 -		echo -e "\nThe partition ($HOME_DEV) will be kept..."
   2.404 -		echo "XXX"
   2.405 -		sleep 2
   2.406 -	fi
   2.407 -
   2.408 -	echo "XXX" && echo 90
   2.409 -	echo -e "\nCreating mount point: $TARGET_ROOT"
   2.410 -	echo "XXX"
   2.411 -	mkdir -p $TARGET_ROOT
   2.412 -	sleep 2
   2.413 -
   2.414 -	) |
   2.415 -	$DIALOG --title " Prepare the target " \
   2.416 -		--backtitle "$BACKLIST" \
   2.417 -		--gauge "Target in preparation..." 18 70 0
   2.418 -	# Mount target.
   2.419 -	mount $TARGET_DEV $TARGET_ROOT >>$LOG 2>>$LOG
   2.420 -}
   2.421 -
   2.422 -# Get a clean target device (15%).
   2.423 -clean_target()
   2.424 -{
   2.425 -	if [ "$CLEAN" == "clean" ]; then
   2.426 -		echo "XXX" && echo 15
   2.427 -		echo -e "\nCleaning the root partition ($TARGET_DEV)"
   2.428 -		echo "XXX"
   2.429 -		# Keep /home in case of reinstall.
   2.430 -		cd $TARGET_ROOT
   2.431 -		for dir in *
   2.432 -		do
   2.433 -			case "$dir" in
   2.434 -				home)
   2.435 -					mv $TARGET_ROOT/home $TARGET_ROOT/home.bak
   2.436 -					echo "keeping /home found on: $TARGET_DEV" >>$LOG ;;
   2.437 -				lost+found)
   2.438 -					continue ;;
   2.439 -				*)
   2.440 -					echo "removing target: $dir" >>$LOG
   2.441 -					rm -rf $dir 2>>$LOG ;;
   2.442 -			esac
   2.443 -		done
   2.444 -		if [ -d $TARGET_ROOT/mklost+found ]; then
   2.445 -			mklost+found 2>>$LOG
   2.446 -		fi
   2.447 -	fi
   2.448 -	sleep 2
   2.449 -}
   2.450 -
   2.451 -# Kernel is renamed to standard vmlinuz-$VERSION.
   2.452 -install_kernel()
   2.453 -{
   2.454 -	mkdir -p $TARGET_ROOT/boot
   2.455 -	cp /media/cdrom/boot/bzImage $TARGET_ROOT/boot/$KERNEL
   2.456 -	echo "install_kernel: $KERNEL" >> $LOG
   2.457 -	sleep 2
   2.458 -}
   2.459 -
   2.460 -# Copy isolinux r/w files (not syslinux, some files are read only).
   2.461 -copy_bootloaders()
   2.462 -{
   2.463 -	if [ -d "/media/cdrom/boot/isolinux" ]; then
   2.464 -		mkdir -p $TARGET_ROOT/boot/isolinux
   2.465 -		cp -a /media/cdrom/boot/isolinux/*.cfg $TARGET_ROOT/boot/isolinux
   2.466 -		cp -a /media/cdrom/boot/isolinux/*.kbd $TARGET_ROOT/boot/isolinux
   2.467 -		cp -a /media/cdrom/boot/isolinux/*.txt $TARGET_ROOT/boot/isolinux
   2.468 -		cp -a /media/cdrom/boot/isolinux/*.bin $TARGET_ROOT/boot/isolinux
   2.469 -		cp -a /media/cdrom/boot/isolinux/*.msg $TARGET_ROOT/boot/isolinux
   2.470 -		cp -a /media/cdrom/boot/isolinux/*.lss $TARGET_ROOT/boot/isolinux
   2.471 -		cp -a /media/cdrom/boot/isolinux/*.c32 $TARGET_ROOT/boot/isolinux
   2.472 -	fi
   2.473 -}
   2.474 -
   2.475 -# Extract lzma'ed or gziped rootfs.
   2.476 -extract_rootfs()
   2.477 -{
   2.478 -	cd $TARGET_ROOT
   2.479 -	(zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so || \
   2.480 -	 cat rootfs.gz) 2>>$LOG | cpio -id 2>>$LOG > /dev/null
   2.481 -	rm -f rootfs.gz
   2.482 -	# unpack /usr (double check...)
   2.483 -	if ls etc/tazlito | grep -q ".extract"; then
   2.484 -		for i in etc/tazlito/*.extract; do
   2.485 -			[ -f "$i" ] && . $i /media/cdrom
   2.486 -		done
   2.487 -	fi
   2.488 -}
   2.489 -
   2.490 -# Pre configure freshly installed system (60 - 80%).
   2.491 -pre_config_system()
   2.492 -{
   2.493 -	cd $TARGET_ROOT
   2.494 -	# Restore backup of existing /home if exists.
   2.495 -	# (created by prepare_target_dev)
   2.496 -	if [ -d home.bak ]; then
   2.497 -		echo "XXX" && echo 65
   2.498 -		echo -e "\nRestoring directory: /home..."
   2.499 -		echo "XXX"
   2.500 -		rm -rf home
   2.501 -		mv home.bak home
   2.502 -		sleep 1
   2.503 -	fi
   2.504 -	# Add root device to CHECK_FS in rcS.conf to check filesystem
   2.505 -	# on each boot.
   2.506 -	echo "XXX" && echo 70
   2.507 -	echo -e "\nAdding $TARGET_DEV and CHECK_FS to file /etc/rcS.conf..."
   2.508 -	echo "XXX"
   2.509 -	sed -i s#'CHECK_FS=\"\"'#"CHECK_FS=\"$TARGET_DEV\""# etc/rcS.conf
   2.510 -	sleep 2
   2.511 -	# Set hostname.
   2.512 -	echo "XXX" && echo 80
   2.513 -	echo -e "\nConfiguring host name: $HOSTNAME"
   2.514 -	echo "XXX"
   2.515 -	echo $HOSTNAME > etc/hostname
   2.516 -}
   2.517 -
   2.518 -# Set root passwd and create user after rootfs extraction.
   2.519 -users_settings()
   2.520 -{
   2.521 -	cat > $TARGET_ROOT/users.sh << _EOF_
   2.522 -#!/bin/sh
   2.523 -echo "root:$ROOT_PASSWD" | chpasswd
   2.524 -adduser -D -H $USER
   2.525 -addgroup $USER audio
   2.526 -echo "$USER:$USER_PASSWD" | chpasswd
   2.527 -if [ ! -d /home/$USER ]; then
   2.528 -	cp -a /etc/skel /home/$USER
   2.529 -	chown -R $USER.$USER /home/$USER
   2.530 -	# Path for user desktop files.
   2.531 -	for i in /home/$USER/.local/share/applications/*.desktop
   2.532 -	do
   2.533 -		sed -i s/"user_name"/"$USER"/g \$i
   2.534 -	done
   2.535 -fi
   2.536 -# Slim default user.
   2.537 -if [ -f /etc/slim.conf ]; then
   2.538 -	sed -i s/"default_user .*"/"default_user        $USER"/ \
   2.539 -		/etc/slim.conf
   2.540 -fi
   2.541 -_EOF_
   2.542 -	chmod +x $TARGET_ROOT/users.sh
   2.543 -	chroot $TARGET_ROOT ./users.sh
   2.544 -	rm $TARGET_ROOT/users.sh
   2.545 -}
   2.546 -
   2.547 -# /home can be on a separate partition. If default user exist in /home
   2.548 -# we remove default file crated by users_settings().
   2.549 -home_config()
   2.550 -{
   2.551 -	echo "home_config: $HOME_DEV" >> $LOG
   2.552 -	cd $TARGET_ROOT
   2.553 -	mv home/$USER tmp
   2.554 -	mount $HOME_DEV home
   2.555 -	if [ -d $TARGET_ROOT/home/$USER ]; then
   2.556 -		rm -rf tmp/$USER
   2.557 -	else
   2.558 -		mv tmp/$USER home
   2.559 -	fi
   2.560 -	echo "$HOME_DEV       /home        ext3    defaults          0       2" \
   2.561 -		>> etc/fstab
   2.562 -	umount home
   2.563 -}
   2.564 -
   2.565 -# Determine GRUB partition number and GRUB disk number.
   2.566 -grub_config()
   2.567 -{
   2.568 -	DISK_LETTER=${TARGET_DEV#/dev/[h-s]d}
   2.569 -	DISK_LETTER=${DISK_LETTER%[0-9]}
   2.570 -	GRUB_PARTITION=$((${TARGET_DEV#/dev/[h-s]d[a-z]}-1))
   2.571 -	for disk in a b c d e f g h
   2.572 -	do
   2.573 -		nb=$(($nb+1))
   2.574 -		if [ "$disk" = "$DISK_LETTER" ]; then
   2.575 -			GRUB_DISK=$(($nb-1))
   2.576 -			break
   2.577 -		fi
   2.578 -	done
   2.579 -	GRUB_ROOT="(hd${GRUB_DISK},${GRUB_PARTITION})"
   2.580 -	# Create the target GRUB configuration.
   2.581 -	mkdir -p $TARGET_ROOT/boot/grub
   2.582 -	cat > $TARGET_ROOT/boot/grub/menu.lst << _EOF_
   2.583 -# /boot/grub/menu.lst: GRUB boot loader configuration.
   2.584 -#
   2.585 -
   2.586 -# By default, boot the first entry.
   2.587 -default 0
   2.588 -
   2.589 -# Boot automatically after 8 secs.
   2.590 -timeout 8
   2.591 -
   2.592 -# Change the colors.
   2.593 -color yellow/brown light-green/black
   2.594 -
   2.595 -# For booting SliTaz from : $TARGET_DEV
   2.596 -#
   2.597 -title SliTaz GNU/Linux (cooking) (Kernel $KERNEL)
   2.598 -root $GRUB_ROOT
   2.599 -kernel /boot/$KERNEL root=$TARGET_DEV
   2.600 -
   2.601 -_EOF_
   2.602 -	# log
   2.603 -	echo "grub_config: $TARGET_ROOT/boot/grub/menu.lst" >>$LOG
   2.604 -	sleep 2
   2.605 -}
   2.606 -
   2.607 -# Files install with gauge, calling for functions or with cmds.
   2.608 -install_files()
   2.609 -{
   2.610 -	(
   2.611 -
   2.612 -	echo "XXX" && echo 10
   2.613 -	echo -e "\nCleaning the root partition if necessary..."
   2.614 -	echo "XXX"
   2.615 -	clean_target
   2.616 -
   2.617 -	echo "XXX" && echo 20
   2.618 -	echo -e "\nInstalling the kernel ($KERNEL)"
   2.619 -	echo "XXX"
   2.620 -	install_kernel
   2.621 -
   2.622 -	echo "XXX" && echo 30
   2.623 -	echo -e "\nCopying the bootloader syslinux/isolinux..."
   2.624 -	echo "XXX"
   2.625 -	copy_bootloaders
   2.626 -
   2.627 -	echo "XXX" && echo 40
   2.628 -	echo -e "\nCopying the compressed system (rootfs.gz)..."
   2.629 -	echo "XXX"
   2.630 -	cp /media/cdrom/boot/rootfs.gz $TARGET_ROOT
   2.631 -	sleep 2
   2.632 -
   2.633 -	echo "XXX" && echo 50
   2.634 -	echo -e "\nExtracting the root system..."
   2.635 -	echo "XXX"
   2.636 -	extract_rootfs
   2.637 -
   2.638 -	echo "XXX" && echo 60
   2.639 -	echo -e "\nPreconfiguring the system..."
   2.640 -	echo "XXX"
   2.641 -	pre_config_system
   2.642 -
   2.643 -	echo "XXX" && echo 70
   2.644 -	echo -e "\nConfiguring root and default $USER account..."
   2.645 -	echo "XXX"
   2.646 -	users_settings
   2.647 -	sleep 2
   2.648 -
   2.649 -	if [ "$HOME_DEV" != "" ]; then
   2.650 -		echo "XXX" && echo 80
   2.651 -		echo -e "\nConfiguring $HOME_DEV to be used as /home..."
   2.652 -		echo "XXX"
   2.653 -		home_config
   2.654 -		sleep 2
   2.655 -	fi
   2.656 -
   2.657 -	echo "XXX" && echo 90
   2.658 -	echo -e "\nCreating the configuration file for GRUB (menu.lst)..."
   2.659 -	echo "XXX"
   2.660 -	grub_config
   2.661 -
   2.662 -	echo "XXX" && echo 100
   2.663 -	echo -e "\nFinishing the files installation..."
   2.664 -	echo "XXX"
   2.665 -	echo "install_files: OK" >>$LOG
   2.666 -	sleep 2
   2.667 -
   2.668 -	) |
   2.669 -	$DIALOG --title " Install files " \
   2.670 -		--backtitle "$BACKLIST" \
   2.671 -		--gauge "Starting to install files..." 18 70 0
   2.672 -}
   2.673 -
   2.674 -# GRUB info with disk name used for grub-install.
   2.675 -grub_install()
   2.676 -{
   2.677 -	TARGET_DISK=`echo $TARGET_DEV | sed s/"[0-9]"/''/`
   2.678 -	set_messages
   2.679 -	$DIALOG --title " GRUB install " \
   2.680 -		--backtitle "$BACKLIST" \
   2.681 -		--clear --colors --yesno "$GRUB_INSTALL_MSG" 18 70
   2.682 -	retval=$?
   2.683 -	case $retval in
   2.684 -		0)
   2.685 -			(
   2.686 -			echo "XXX" && echo 50
   2.687 -			echo -e "\nRunning grub-install on : $TARGET_DISK"
   2.688 -			echo "XXX"
   2.689 -			grub-install --no-floppy \
   2.690 -				--root-directory=$TARGET_ROOT $TARGET_DISK 2>>$LOG
   2.691 -			echo "XXX" && echo 100
   2.692 -			echo -e "\nFinished installation..."
   2.693 -			echo "XXX"
   2.694 -			sleep 2
   2.695 -			) |
   2.696 -			$DIALOG --title " GRUB install " \
   2.697 -				--backtitle "$BACKLIST" \
   2.698 -				--gauge "Installing GRUB..." 18 70 0 ;;
   2.699 -		1)
   2.700 -			echo "grub_install: NO" >>$LOG ;;
   2.701 -		255)
   2.702 -			echo -e "ESC pressed.\n" && exit 0 ;;
   2.703 -	esac
   2.704 -}
   2.705 -
   2.706 -# Copy log file, umount target and eject cdrom.
   2.707 -umount_devices()
   2.708 -{
   2.709 -	(
   2.710 -	echo "XXX" && echo 25
   2.711 -	echo -e "\nCopying the log files ($LOG)"
   2.712 -	echo "XXX"
   2.713 -	cp -a $LOG $TARGET_ROOT/var/log
   2.714 -	sleep 2
   2.715 -	echo "XXX" && echo 50
   2.716 -	echo -e "\nUnmounting the target ($TARGET_DEV)"
   2.717 -	echo "XXX"
   2.718 -	if mount | grep -q $TARGET_ROOT; then
   2.719 -		umount $TARGET_ROOT 2>/dev/null
   2.720 -	fi
   2.721 -	echo "XXX" && echo 75
   2.722 -	echo -e "\nUnmounting and ejecting the cdrom..."
   2.723 -	echo "XXX"
   2.724 -	if mount | grep -q /media/cdrom; then
   2.725 -		umount /media/cdrom
   2.726 -		grep -q slitaz-loram-cdrom /etc/init.d/rcS || eject
   2.727 -	fi
   2.728 -	sleep 2
   2.729 -	echo "XXX" && echo 100
   2.730 -	echo -e "\n$TITLE..."
   2.731 -	echo "XXX"
   2.732 -	sleep 2
   2.733 -	) |
   2.734 -	$DIALOG --title " $TITLE " \
   2.735 -		--backtitle "$BACKLIST" \
   2.736 -		--gauge "$TITLE starting..." 18 70 0
   2.737 -}
   2.738 -
   2.739 -# End of installation.
   2.740 -end_of_install()
   2.741 -{
   2.742 -	echo "end_of_install: `date`" >>$LOG
   2.743 -	$DIALOG --title " Installation complete " \
   2.744 -		--backtitle "$BACKLIST" \
   2.745 -		--yes-label "Exit" \
   2.746 -		--no-label "Reboot" \
   2.747 -		--clear --colors --yesno "$END_OF_INSTALL_MSG" 18 70
   2.748 -	retval=$?
   2.749 -	case $retval in
   2.750 -	0)
   2.751 -		TITLE="Exiting"
   2.752 -		umount_devices ;;
   2.753 -	1)
   2.754 -		TITLE="Rebooting"
   2.755 -		umount_devices
   2.756 -		reboot || reboot -f ;;
   2.757 -	255)
   2.758 -		echo -e "ESC pressed.\n" && exit 0 ;;
   2.759 -esac
   2.760 -}
   2.761 -
   2.762 -#####################
   2.763 -# Upgrade functions #
   2.764 -#####################
   2.765 -
   2.766 -# We need a partition to upgrade SliTaz.
   2.767 -ask_for_upgrade_dev()
   2.768 -{
   2.769 -	exec 3>&1
   2.770 -	UPGRADE_DEV=`$DIALOG --title " Target to upgrade " \
   2.771 -		--backtitle "$BACKLIST" --clear \
   2.772 -		--extra-label "List" --extra-button \
   2.773 -		--colors --inputbox "\n
   2.774 -The installer will upgrade the target by saving all configuration files and \
   2.775 -the list of installed packages. Then, it will clean the partition and install the \
   2.776 -version of SliTaz contained on the cdrom, restore the configuration files and \
   2.777 -reinstall any packages which are not present on the cdrom. You will need an active \
   2.778 -internet connection before upgrading.\n\n
   2.779 -\Z2Partition containing the system upgrade:\Zn" 18 70 2>&1 1>&3`
   2.780 -	retval=$?
   2.781 -	exec 3>&-
   2.782 -	check_retval
   2.783 -	# Display list and come back.
   2.784 -	if [ "$retval" = "3" ]; then
   2.785 -		fdisk_list
   2.786 -		ask_for_upgrade_dev
   2.787 -	fi
   2.788 -	# Empty value.
   2.789 -	if [ -z $UPGRADE_DEV ]; then
   2.790 -		ask_for_upgrade_dev
   2.791 -	fi
   2.792 -	# Check if specified device exists in /proc/partitions.
   2.793 -	DEV_NAME=${UPGRADE_DEV#/dev/}
   2.794 -	if cat /proc/partitions | grep -q $DEV_NAME; then
   2.795 -		echo "ask_for_target_dev: $TARGET_DEV" >>$LOG
   2.796 -	else
   2.797 -		ERROR_MSG="The partition \Z2$UPGRADE_DEV\Zn doesn't seem to exist."
   2.798 -		error_message
   2.799 -		ask_for_upgrade_dev
   2.800 -	fi
   2.801 -	echo "partition to upgrade: $UPGRADE_DEV" >>$LOG
   2.802 -}
   2.803 -
   2.804 -# Prepare the partition to upgrade, backup, install, restore configs
   2.805 -# and reinstall pkgs.
   2.806 -upgrade_process()
   2.807 -{
   2.808 -	(
   2.809 -	echo "XXX" && echo 5
   2.810 -	echo -e "\nPreparing the target partition..."
   2.811 -	echo "XXX"
   2.812 -	# Mount point can be already used.
   2.813 -	if mount | grep -q $TARGET_ROOT; then
   2.814 -		umount $TARGET_ROOT 2>$LOG
   2.815 -	fi
   2.816 -	mkdir -p $TARGET_ROOT && sleep 2
   2.817 -	# Mount target.
   2.818 -	mount $UPGRADE_DEV $TARGET_ROOT >>$LOG 2>>$LOG
   2.819 -	cd $TARGET_ROOT
   2.820 -	TARGET_DEV=$UPGRADE_DEV
   2.821 -	set_messages
   2.822 -
   2.823 -	echo "XXX" && echo 10
   2.824 -	echo -e "\nSearch for /etc/slitaz-release"
   2.825 -	echo "XXX"
   2.826 -	if [ -f etc/slitaz-release ]; then
   2.827 -		release=`cat etc/slitaz-release`
   2.828 -		echo "XXX" && echo 15
   2.829 -		echo -e "\nSliTaz release: $release"
   2.830 -		echo "XXX"
   2.831 -	else
   2.832 -		ERROR_MSG="The partition \Z2$UPGRADE_DEV\Zn doesn't appear to contain \
   2.833 -a SliTaz system, the file: /etc/slitaz-release doesn't exist."
   2.834 -		error_message
   2.835 -		exit 0
   2.836 -	fi && sleep 2
   2.837 -
   2.838 -	echo "XXX" && echo 20
   2.839 -	echo -e "\nBackup /etc, /home and the packages list..."
   2.840 -	echo "XXX"
   2.841 -	# Backup target packages list.
   2.842 -	ls -1 var/lib/tazpkg/installed > home/packages-selection.list
   2.843 -	for dir in *
   2.844 -	do
   2.845 -		case "$dir" in
   2.846 -			boot)
   2.847 -				# Upgrade doesn't prompt for grub install, so backup and
   2.848 -				# create a new grub menu.lst.
   2.849 -				rm -rf $TARGET_ROOT/boot/vmlinuz-*
   2.850 -				mv $TARGET_ROOT/boot/grub/menu.lst \
   2.851 -					$TARGET_ROOT/boot/grub/menu.lst.bak 2>/dev/null
   2.852 -				grub_config ;;
   2.853 -			home)
   2.854 -				mv $TARGET_ROOT/home $TARGET_ROOT/home.bak
   2.855 -				echo "keeping /home found on: $UPGRADE_DEV" >>$LOG ;;
   2.856 -			etc)
   2.857 -				tar czf $TARGET_ROOT/etc.tar.gz etc
   2.858 -				mv $TARGET_ROOT/etc $TARGET_ROOT/etc.bak
   2.859 -				echo "keeping /etc found on: $UPGRADE_DEV" >>$LOG ;;
   2.860 -			var)
   2.861 -				if [ -d $TARGET_ROOT/var/www ]; then
   2.862 -					mv $TARGET_ROOT/var/www $TARGET_ROOT/www.bak
   2.863 -				fi
   2.864 -				rm -rf $TARGET_ROOT/var ;;
   2.865 -			lost+found)
   2.866 -				continue ;;
   2.867 -			*)
   2.868 -				echo "removing target: $dir" >>$LOG
   2.869 -				rm -rf $TARGET_ROOT/$dir 2>>$LOG ;;
   2.870 -		esac
   2.871 -	done
   2.872 -	if [ -d $TARGET_ROOT/mklost+found ]; then
   2.873 -		mklost+found 2>>$LOG
   2.874 -	fi
   2.875 -	sleep 2
   2.876 -
   2.877 -	echo "XXX" && echo 25
   2.878 -	echo -e "\nInstalling the kernel ($KERNEL)"
   2.879 -	echo "XXX"
   2.880 -	install_kernel
   2.881 -
   2.882 -	echo "XXX" && echo 30
   2.883 -	echo -e "\nCopying the bootloader syslinux/isolinux..."
   2.884 -	echo "XXX"
   2.885 -	copy_bootloaders
   2.886 -
   2.887 -	echo "XXX" && echo 35
   2.888 -	echo -e "\nCopying the compressed system (rootfs.gz)..."
   2.889 -	echo "XXX"
   2.890 -	cp /media/cdrom/boot/rootfs.gz $TARGET_ROOT
   2.891 -	sleep 2
   2.892 -
   2.893 -	echo "XXX" && echo 40
   2.894 -	echo -e "\nExtracting the root system..."
   2.895 -	echo "XXX"
   2.896 -	extract_rootfs
   2.897 -
   2.898 -	# Restore backups.
   2.899 -	echo "XXX" && echo 42
   2.900 -	echo -e "\nRestoring configuration files..."
   2.901 -	echo "XXX"
   2.902 -	rm -rf $TARGET_ROOT/home
   2.903 -	mv $TARGET_ROOT/home.bak $TARGET_ROOT/home
   2.904 -	rm -rf $TARGET_ROOT/etc
   2.905 -	mv $TARGET_ROOT/etc.bak $TARGET_ROOT/etc
   2.906 -	if [ -d $TARGET_ROOT/www.bak ]; then
   2.907 -		rm -rf $TARGET_ROOT/var/www
   2.908 -		mv $TARGET_ROOT/www.bak $TARGET_ROOT/var/www
   2.909 -	fi
   2.910 -	echo "backups restored: `date`" >> $LOG
   2.911 -
   2.912 -	# /var/lib/slitaz-installer
   2.913 -	mkdir $TARGET_ROOT/var/lib/slitaz-installer
   2.914 -	mv $TARGET_ROOT/etc.tar.gz $TARGET_ROOT/var/lib/slitaz-installer
   2.915 -	mv $TARGET_ROOT/home/packages-selection.list $TARGET_ROOT/var/lib/slitaz-installer
   2.916 -	cd $TARGET_ROOT/var/lib/slitaz-installer
   2.917 -
   2.918 -	# LiveCD packages list.
   2.919 -	echo "XXX" && echo 46
   2.920 -	echo -e "\nCreating package lists..."
   2.921 -	echo "XXX"
   2.922 -	ls -1 $TARGET_ROOT/var/lib/tazpkg/installed > packages-cdrom.list || exit 1
   2.923 -	echo "packages-cdrom.list: done" >> $LOG
   2.924 -	# Diff
   2.925 -	diff packages-cdrom.list packages-selection.list | \
   2.926 -		grep ^+[a-z] | sed s/^+// > packages-selection.diff
   2.927 -	echo "packages-selection.diff: done" >> $LOG
   2.928 -	# Get mirror list.
   2.929 -	tazpkg recharge >>$LOG 2>>$LOG
   2.930 -	if [ ! -f /var/lib/tazpkg/packages.list ]; then
   2.931 -		ERROR_MSG="The list of available packages on the mirror could not be \
   2.932 -downloaded. No missing packages will be reinstalled now, but \
   2.933 -you can do so later by looking at the following list: \n\n
   2.934 -
   2.935 -/var/lib/slitaz-installer/packages-selection.diff"
   2.936 -		error_message
   2.937 -	fi
   2.938 -	sleep 2
   2.939 -
   2.940 -	# Check if the pkg is on the mirror.
   2.941 -	echo "XXX" && echo 48
   2.942 -	echo -e "\nChecking the availability of packages..."
   2.943 -	echo "XXX"
   2.944 -	touch packages-to-install.list
   2.945 -	packages=0
   2.946 -	diff=`cat packages-selection.diff | sort`
   2.947 -	for pkg in $diff
   2.948 -	do
   2.949 -		if grep -q ^$pkg-[0-9] /var/lib/tazpkg/packages.list; then
   2.950 -			packages=$(($packages+1))
   2.951 -			echo "$pkg" >> packages-to-install.list
   2.952 -		fi
   2.953 -	done
   2.954 -
   2.955 -	# Calculate the percent for one package and install.
   2.956 -	echo "XXX" && echo 50
   2.957 -	echo -e "\nInstalling any packages..."
   2.958 -	echo "XXX"
   2.959 -	sleep 2
   2.960 -	if [ "$packages" == "0" ]; then
   2.961 -		echo "packages to install: 0" >> $LOG
   2.962 -	else
   2.963 -		onepkg=$((48/$packages))
   2.964 -		pct=50
   2.965 -		# Get-install all missing pkgs.
   2.966 -		for pkg in `cat packages-to-install.list`
   2.967 -		do
   2.968 -			pct=$(($pct+$onepkg))
   2.969 -			echo "XXX" && echo $pct
   2.970 -			echo -e "\nInstallation of: $pkg..."
   2.971 -			echo "XXX"
   2.972 -			# Log please.
   2.973 -			echo "get-install: $pkg" >>$LOG
   2.974 -			# Get install package and answer yes in case of dependencies.
   2.975 -			pkgname=`grep ^$pkg /var/lib/tazpkg/packages.list`
   2.976 -			tazpkg get $pkg >/dev/null 2>/dev/null
   2.977 -			yes "" | tazpkg install $pkgname.tazpkg --root=$TARGET_ROOT >/dev/null 2>/dev/null
   2.978 -			rm -f $pkgname.tazpkg
   2.979 -		done
   2.980 -	fi
   2.981 -	echo "XXX" && echo 100
   2.982 -	echo -e "\nInstallation of packages complete..."
   2.983 -	echo "XXX"
   2.984 -	sleep 2
   2.985 -	) |
   2.986 -	$DIALOG --title " Processing system upgrade " \
   2.987 -		--backtitle "$BACKLIST" \
   2.988 -		--gauge "Target in preparation..." 18 70 0
   2.989 -}
   2.990 -
   2.991 -# End of system upgrade.
   2.992 -end_of_upgrade()
   2.993 -{
   2.994 -	TARGET_DEV=$UPGRADE_DEV
   2.995 -	set_messages
   2.996 -	pkgscd=`cat $TARGET_ROOT/var/lib/slitaz-installer/packages-cdrom.list | wc -l`
   2.997 -	pkginst=`cat $TARGET_ROOT/var/lib/slitaz-installer/packages-to-install.list | wc -l`
   2.998 -	echo "end_of_upgrade: `date`" >>$LOG
   2.999 -	$DIALOG --title " Upgrade completed " \
  2.1000 -		--backtitle "$BACKLIST" \
  2.1001 -		--yes-label "Exit" \
  2.1002 -		--no-label "Reboot" \
  2.1003 -		--clear --colors --yesno "\n
  2.1004 -Upgrade finished. You can now restart (reboot) \
  2.1005 -from your SliTaz GNU/Linux system.\n\n
  2.1006 -Packages on the cdrom      : $pkgscd\n
  2.1007 -Packages installed from the mirror : $pkginst\n" 18 70
  2.1008 -	retval=$?
  2.1009 -	case $retval in
  2.1010 -	0)
  2.1011 -		TITLE="Exiting"
  2.1012 -		umount_devices ;;
  2.1013 -	1)
  2.1014 -		TITLE="Rebooting"
  2.1015 -		umount_devices
  2.1016 -		reboot || reboot -f ;;
  2.1017 -	255)
  2.1018 -		echo -e "ESC pressed.\n" && exit 0 ;;
  2.1019 -esac
  2.1020 -}
  2.1021 -
  2.1022 -######################
  2.1023 -# Installer sequence #
  2.1024 -######################
  2.1025 -
  2.1026 -set_messages
  2.1027 -check_root
  2.1028 -start_installer
  2.1029 -
  2.1030 -case $ACTION in
  2.1031 -	upgrade)
  2.1032 -		BACKLIST="$BACKLIST (Upgrade)"
  2.1033 -		mount_cdrom
  2.1034 -		ask_for_upgrade_dev
  2.1035 -		upgrade_process
  2.1036 -		end_of_upgrade ;;
  2.1037 -	install|*)
  2.1038 -		mount_cdrom
  2.1039 -		ask_for_target_dev
  2.1040 -		ask_for_mkfs_target_dev
  2.1041 -		ask_for_home
  2.1042 -		if [ -n "$HOME_DEV" ]; then
  2.1043 -			ask_for_mkfs_home
  2.1044 -		fi
  2.1045 -		ask_for_hostname
  2.1046 -		ask_for_users_settings
  2.1047 -		summary
  2.1048 -		prepare_partitions
  2.1049 -		install_files
  2.1050 -		grub_install
  2.1051 -		end_of_install ;;
  2.1052 -esac
  2.1053 -
  2.1054 -exit 0
     3.1 --- a/core/rootfs/usr/bin/wifibox	Thu Feb 11 14:40:09 2010 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,634 +0,0 @@
     3.4 -#!/bin/sh
     3.5 -#
     3.6 -# GTKdialog interface to manage wireless connections in a simple way.
     3.7 -# Use tabs to indent, split commands from the GUI and use functions.
     3.8 -# Favorite networks are also supported
     3.9 -#
    3.10 -# (c) 2010 SliTaz GNU/Linux - GNU gpl v3
    3.11 -#
    3.12 -VERSION=20100118
    3.13 -
    3.14 -# Export script path and others if needed so we can use them in 'quote'.
    3.15 -export BIN=$0
    3.16 -export FAVORITES_WIFI=/etc/wireless
    3.17 -. /etc/network.conf
    3.18 -
    3.19 -# Wifibox is only for root.
    3.20 -if test $(id -u) != 0 ; then
    3.21 -	exec subox wifibox
    3.22 -	exit 0
    3.23 -fi
    3.24 -
    3.25 -# Sanity check
    3.26 -[ -x /usr/sbin/iwconfig ] || tazpkg get-install wireless_tools
    3.27 -[ -d $FAVORITES_WIFI ] || mkdir -p $FAVORITES_WIFI
    3.28 -rm -f $FAVORITES_WIFI/any.conf
    3.29 -
    3.30 -# Catch ESSIDs and format output for GTK tree. We get the list of
    3.31 -# networks by Cell and without spaces.
    3.32 -detect_wifi_networks()
    3.33 -{
    3.34 -	desktopbox notify "Scanning Wireless interface: $WIFI_INTERFACE" &
    3.35 -	if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
    3.36 -		ifconfig $WIFI_INTERFACE up
    3.37 -		for i in `iwlist $WIFI_INTERFACE scan | sed s/"Cell "/Cell-/ | grep "Cell-" | awk '{print $1}'`
    3.38 -		do
    3.39 -			SCAN=`iwlist $WIFI_INTERFACE scan last | \
    3.40 -				awk '/(Cell|ESS|Qual|Encry|IE: WPA)/ {print}' | \
    3.41 -				sed s/"Cell "/Cell-/ | grep -A 5 "$i"`
    3.42 -			ESSID=`echo $SCAN | cut -d '"' -f 2`
    3.43 -			if echo "$SCAN" | grep -q Quality; then
    3.44 -				QUALITY=`echo $SCAN | sed 's/.*Quality=\([^ ]*\).*/\1/' | sed 's/.*Quality:\([^ ]*\).*/\1/'`
    3.45 -			else
    3.46 -				QUALITY="-"
    3.47 -			fi
    3.48 -			ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
    3.49 -			# Check encryption type
    3.50 -			if echo "$SCAN" | grep -q WPA; then
    3.51 -				ENCRYPTION="${ENCRYPTION} (WPA)"
    3.52 -			fi
    3.53 -			# Connected or not connected...
    3.54 -			if ifconfig | grep -A 1 $WIFI_INTERFACE | \
    3.55 -				grep -q inet && iwconfig $WIFI_INTERFACE | \
    3.56 -				grep ESSID | grep -q -w "$ESSID"; then
    3.57 -				STATUS=connected
    3.58 -			else
    3.59 -				STATUS="-"
    3.60 -			fi
    3.61 -			echo -n ""
    3.62 -			echo "$ESSID | $QUALITY | $ENCRYPTION | $STATUS"
    3.63 -		done
    3.64 -	fi
    3.65 -}
    3.66 -
    3.67 -# cmdline functions
    3.68 -
    3.69 -# Toggle Software RF Switch on some laptops
    3.70 -set_rfswitch()
    3.71 -{
    3.72 -	for i in /proc/driver/acerhk/wirelessled /proc/acpi/asus/wled ; do
    3.73 -		[ -e $i ] && echo $1 > $i
    3.74 -	done
    3.75 -}
    3.76 -
    3.77 -# Configure /etc/network.conf and restart connection with init script.
    3.78 -start_wifi_connection()
    3.79 -{
    3.80 -	# Get tmp config created by connect_to_essid() if exists and set 
    3.81 -	# empty value to clean config file.
    3.82 -	if [ -f /tmp/wifi.conf ]; then
    3.83 -		. /tmp/wifi.conf
    3.84 -		WIFI_MODE=""
    3.85 -		WIFI_IWCONFIG_ARGS=""
    3.86 -		WIFI_CHANNEL=""
    3.87 -	fi
    3.88 -	sed -i "s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/" \
    3.89 -		/etc/network.conf
    3.90 -	sed -i "s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" \
    3.91 -		/etc/network.conf
    3.92 -	sed -i "s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/" \
    3.93 -		/etc/network.conf
    3.94 -	sed -i "s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/" \
    3.95 -		/etc/network.conf
    3.96 -	sed -i "s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/" \
    3.97 -		/etc/network.conf
    3.98 -	sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" \
    3.99 -		/etc/network.conf
   3.100 -	sed -i "s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/" \
   3.101 -		/etc/network.conf
   3.102 -	sed -i "s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/" \
   3.103 -		/etc/network.conf	
   3.104 -	[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
   3.105 -	ifconfig $WIFI_INTERFACE down
   3.106 -	set_rfswitch 1 
   3.107 -	iwconfig $WIFI_INTERFACE txpower auto
   3.108 -	/etc/init.d/network.sh restart
   3.109 -	# Remove tmp file (could be used to have wireless profiles)
   3.110 -	rm -f /tmp/wifi.conf
   3.111 -	sleep 2
   3.112 -}
   3.113 -
   3.114 -# We must sleep 4 sec to refresh networks list.
   3.115 -stop_wifi_connexion()
   3.116 -{
   3.117 -	sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"no\"/ \
   3.118 -		/etc/network.conf
   3.119 -	[ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop
   3.120 -	ifconfig $WIFI_INTERFACE down
   3.121 -	iwconfig $WIFI_INTERFACE txpower off
   3.122 -	set_rfswitch 0 
   3.123 -	[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`
   3.124 -	sleep 2
   3.125 -}
   3.126 -
   3.127 -# Favorite wireless networks use only 3 values: essid. key and type of
   3.128 -# key
   3.129 -favorites_wifi_list()
   3.130 -{
   3.131 -	for i in $FAVORITES_WIFI/*.conf
   3.132 -	do
   3.133 -		WIFI_ESSID=""
   3.134 -		WIFI_KEY=""
   3.135 -		WIFI_KEY_TYPE=""
   3.136 -		. "$i"
   3.137 -		[ -z "$WIFI_ESSID" ] && WIFI_ESSID="Bad config file: $i"
   3.138 -		[ -z "$WIFI_KEY_TYPE" ] && WIFI_KEY_TYPE="-"
   3.139 -		if [ -n "$WIFI_KEY" ]; then
   3.140 -			WIFI_KEY="********"
   3.141 -		else
   3.142 -			WIFI_KEY="-"
   3.143 -		fi
   3.144 -		echo "$WIFI_ESSID | $WIFI_KEY_TYPE | $WIFI_KEY"
   3.145 -	done
   3.146 -}
   3.147 -
   3.148 -favorite_wifi_actions()
   3.149 -{
   3.150 -	cp -a $FAVORITES_WIFI/"$FAVORITE".conf /tmp/wifi.conf
   3.151 -	. /tmp/wifi.conf
   3.152 -	export CONNECT_FAVORITE="
   3.153 -<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
   3.154 -<vbox>
   3.155 -	
   3.156 -	<text width-chars=\"54\">
   3.157 -		<label>
   3.158 -\"
   3.159 -ESSID name: $WIFI_ESSID
   3.160 -\"
   3.161 -		</label>
   3.162 -	</text>
   3.163 -	
   3.164 -	<hbox>
   3.165 -		<button>
   3.166 -			<label>Connect</label>
   3.167 -			<input file icon=\"forward\"></input>	
   3.168 -			<action>$0 start_wifi_connection</action>
   3.169 -			<action type=\"exit\">exit</action>
   3.170 -		</button>
   3.171 -		<button>
   3.172 -			<label>Edit settings</label>
   3.173 -			<input file icon=\"accessories-text-editor\"></input>	
   3.174 -			<action>leafpad $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
   3.175 -			<action>rm -f /tmp/wifi.conf</action>
   3.176 -			<action type=\"exit\">exit</action>
   3.177 -		</button>
   3.178 -		<button>
   3.179 -			<label>Delete</label>
   3.180 -			<input file icon=\"gtk-delete\"></input>	
   3.181 -			<action>rm -f $FAVORITES_WIFI/\"$FAVORITE\".conf</action>
   3.182 -			<action type=\"exit\">exit</action>
   3.183 -		</button>
   3.184 -		<button cancel></button>
   3.185 -	</hbox>
   3.186 -	
   3.187 -</vbox>
   3.188 -</window>"
   3.189 -	gtkdialog --center --program=CONNECT_FAVORITE >/dev/null
   3.190 -}
   3.191 -
   3.192 -add_favorite_network_box()
   3.193 -{
   3.194 -	ADD_FAVORITE='
   3.195 -<window title="Add new favorite Wireless" icon-name="network-wireless">
   3.196 -<vbox>
   3.197 -	<text width-chars="54">
   3.198 -		<label>
   3.199 -"
   3.200 -Please configure your new favorite Wireless network
   3.201 -"
   3.202 -		</label>
   3.203 -	</text>
   3.204 -	<hbox>
   3.205 -		<text use-markup="true">
   3.206 -			<label>"<b>ESSID:</b>"</label>
   3.207 -		</text>
   3.208 -		<entry>
   3.209 -			<variable>WIFI_ESSID</variable>
   3.210 -		</entry>
   3.211 -	</hbox>
   3.212 -	<hbox>
   3.213 -		<text use-markup="true">
   3.214 -			<label>"<b>Key:   </b>"</label>
   3.215 -		</text>
   3.216 -		<entry>
   3.217 -			<variable>WIFI_KEY</variable>
   3.218 -		</entry>
   3.219 -	</hbox>
   3.220 -	<hbox>
   3.221 -		<text use-markup="true">
   3.222 -			<label>"<b>Key type:</b>"</label>
   3.223 -		</text>
   3.224 -		<combobox>'
   3.225 -	tmp="${ADD_FAVORITE}<item>$WIFI_KEY_TYPE</item>"
   3.226 -	for i in none WEP WPA any; do
   3.227 -		tmp=${tmp}"<item>$i</item>"
   3.228 -	done
   3.229 -	export ADD_FAVORITE=${tmp}'
   3.230 -			<variable>WIFI_KEY_TYPE</variable>
   3.231 -		</combobox>
   3.232 -	</hbox>
   3.233 -	<hbox>
   3.234 -		<button>
   3.235 -			<label>Add to list</label>
   3.236 -			<input file icon="forward"></input>
   3.237 -			<action>echo "# Wireless connection configuration." > $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.238 -			<action>echo "#" >> /etc/wireless/"$WIFI_ESSID".conf</action>
   3.239 -			<action>echo "WIFI_ESSID=\"$WIFI_ESSID\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.240 -			<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.241 -			<action>echo "WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"" >> $FAVORITES_WIFI/"$WIFI_ESSID".conf</action>
   3.242 -			<action type="exit">exit</action>
   3.243 -		</button>
   3.244 -		<button cancel></button>
   3.245 -	</hbox>
   3.246 -</vbox>
   3.247 -</window>'
   3.248 -	gtkdialog --center --program=ADD_FAVORITE #>/dev/null
   3.249 -}
   3.250 -
   3.251 -# GUI functions
   3.252 -
   3.253 -helpbutton()
   3.254 -{
   3.255 -	local label;
   3.256 -        label="<label>$3</label>"
   3.257 -	[ -n "$3" ] || label=""
   3.258 -	cat << EOT
   3.259 -<button>
   3.260 -	<input file icon="help"></input>$label
   3.261 -	<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry $2 -title "$1 help" -e "$(which $1) --help ; echo -e \\"----\\nENTER to continue...\\" && read close"</action>
   3.262 -</button>
   3.263 -EOT
   3.264 -}
   3.265 -
   3.266 -manbutton()
   3.267 -{
   3.268 -	cat << EOT
   3.269 -<button>
   3.270 -	<input file icon="browser"></input>
   3.271 -	<label>man</label>
   3.272 -	<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x24 -title "$2 man (q to quit)" -e ". /etc/profile; man $1 $2"</action>
   3.273 -</button>
   3.274 -EOT
   3.275 -}
   3.276 -
   3.277 -# Independant dialog to connect on a wireless network. If encryption
   3.278 -# is on we ask for the security key.
   3.279 -connect_to_essid()
   3.280 -{
   3.281 -	SCAN=`iwlist $WIFI_INTERFACE scan | \
   3.282 -		awk '/(Cell|ESS|Qual|Encry|IE: WPA)/ {print}' | \
   3.283 -		grep -B 1 -A 1 "$ESSID_LIST"`
   3.284 -	WIFI_ESSID="$ESSID_LIST"
   3.285 -	ENCRYPTION=`echo $SCAN | sed 's/.*key:\([^ ]*\).*/\1/'`
   3.286 -	# Create tmp file used by active_wifi_connexion()
   3.287 -	cat > /tmp/wifi.conf << _EOF_
   3.288 -# Wireless connexion configuration file.
   3.289 -WIFI_ESSID="$ESSID_LIST"
   3.290 -_EOF_
   3.291 -	CONNECT_ESSID="
   3.292 -<window title=\"Connect to: $WIFI_ESSID\" icon-name=\"network-wireless\">
   3.293 -<vbox>
   3.294 -	<text width-chars=\"54\">
   3.295 -		<label>
   3.296 -\"
   3.297 -Connect $WIFI_INTERFACE to: $WIFI_ESSID
   3.298 -\"
   3.299 -		</label>
   3.300 -	</text>"
   3.301 -	# We maybe need a key to connect
   3.302 -	if [ "$ENCRYPTION" = "on" ] && [ "$ESSID_LIST" != "any" ]; then
   3.303 -		# WPA
   3.304 -		if echo "$SCAN" | grep -q WPA; then
   3.305 -			echo 'WIFI_KEY_TYPE="WPA"' >> /tmp/wifi.conf
   3.306 -			CONNECT_ESSID=${CONNECT_ESSID}'
   3.307 -			<hbox>
   3.308 -				<text use-markup="true">
   3.309 -					<label>"<b>WPA Key:</b>"</label>
   3.310 -				</text>
   3.311 -				<entry>
   3.312 -					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   3.313 -					<variable>WIFI_KEY</variable>
   3.314 -				</entry>
   3.315 -			</hbox>'
   3.316 -		else
   3.317 -			# WEP
   3.318 -			echo 'WIFI_KEY_TYPE="WEP"' >> /tmp/wifi.conf
   3.319 -			CONNECT_ESSID=${CONNECT_ESSID}'
   3.320 -			<hbox>
   3.321 -				<text use-markup="true">
   3.322 -					<label>"<b>WEP Key:</b>"</label>
   3.323 -				</text>
   3.324 -				<entry>
   3.325 -					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   3.326 -					<variable>WIFI_KEY</variable>
   3.327 -				</entry>
   3.328 -			</hbox>'
   3.329 -		fi
   3.330 -	else
   3.331 -		# No encryption
   3.332 -		echo 'WIFI_KEY=""' >> /tmp/wifi.conf
   3.333 -		echo 'WIFI_KEY_TYPE=""' >> /tmp/wifi.conf
   3.334 -		start_wifi_connection
   3.335 -		exit 0
   3.336 -	fi
   3.337 -	# Add key to config file so active_wifi_connexion() can use it.
   3.338 -	# WIFI_KEY is not exported if we quote with --> "
   3.339 -	export CONNECT_ESSID=${CONNECT_ESSID}'
   3.340 -	<hbox>
   3.341 -		<button>
   3.342 -			<label>Connect</label>
   3.343 -			<input file icon="forward"></input>	
   3.344 -			<action>echo "WIFI_KEY=\"$WIFI_KEY\"" >> /tmp/wifi.conf</action>
   3.345 -			<action>$BIN start_wifi_connection</action>
   3.346 -			<action type="exit">exit</action>
   3.347 -		</button>
   3.348 -		<button cancel></button>
   3.349 -	</hbox>
   3.350 -</vbox>
   3.351 -</window>'
   3.352 -	gtkdialog --center --program=CONNECT_ESSID #>/dev/null
   3.353 -}
   3.354 -
   3.355 -# Wifibox start with Networks tab.
   3.356 -box()
   3.357 -{
   3.358 -	WIFI_DIALOG="
   3.359 -<window title=\"Wireless manager\" icon-name=\"network-wireless\">
   3.360 -<vbox>
   3.361 -	
   3.362 -	<notebook labels=\"Networks|Favorites|Configuration|Drivers\">
   3.363 -	
   3.364 -	<vbox>
   3.365 -		<tree icon=\"network-wireless\">
   3.366 -			<width>520</width><height>160</height>
   3.367 -			<variable>ESSID_LIST</variable>
   3.368 -			<label>ESSID|Quality|Encryption|Status</label>
   3.369 -			<input>$0 detect_wifi_networks</input>
   3.370 -			<item icon=\"network-wireless\">any | * | off | (auto-connect)</item>
   3.371 -			<action>$0 connect_to_essid</action>
   3.372 -			<action>refresh:ESSID_LIST</action>
   3.373 -			<action>refresh:WIFI_ESSID</action>
   3.374 -			<action>refresh:WIFI_KEY</action>
   3.375 -			<action>refresh:WIFI_KEY_TYPE</action>
   3.376 -		</tree>
   3.377 -		<hbox>
   3.378 -			<text width-chars=\"54\">
   3.379 -				<label>
   3.380 -\"Please double click on a network to connect or enter security key\"
   3.381 -				</label>
   3.382 -			</text>
   3.383 -			<button>
   3.384 -				<label>Refresh list</label>
   3.385 -				<input file icon=\"reload\"></input>
   3.386 -				<action>refresh:ESSID_LIST</action>
   3.387 -			</button>
   3.388 -		</hbox>
   3.389 -	</vbox>"
   3.390 -	
   3.391 -	# Favorite networks
   3.392 -	WIFI_DIALOG=${WIFI_DIALOG}"	
   3.393 -	<vbox>
   3.394 -		<tree icon=\"network-wireless\">
   3.395 -			<width>500</width><height>160</height>
   3.396 -			<variable>FAVORITE</variable>
   3.397 -			<label>ESSID|Key Type|Key status</label>
   3.398 -			<input>$0 favorites_wifi_list</input>
   3.399 -			<item icon=\"network-wireless\">any | - | -</item>
   3.400 -			<action>$0 favorite_wifi_actions</action>
   3.401 -			<action>refresh:FAVORITE</action>
   3.402 -			<action>refresh:ESSID_LIST</action>
   3.403 -			<action>refresh:WIFI_ESSID</action>
   3.404 -			<action>refresh:WIFI_KEY</action>
   3.405 -			<action>refresh:WIFI_KEY_TYPE</action>
   3.406 -		</tree>
   3.407 -		<hbox>
   3.408 -			<text width-chars=\"50\">
   3.409 -				<label>
   3.410 -\"Please double click on a network to modify or remove it\"
   3.411 -				</label>
   3.412 -			</text>
   3.413 -			<button>
   3.414 -				<label>Add Network</label>
   3.415 -				<input file icon=\"gtk-add\"></input>
   3.416 -				<action>$0 add_favorite_network_box</action>
   3.417 -				<action>refresh:FAVORITE</action>
   3.418 -			</button>
   3.419 -		</hbox>
   3.420 -	</vbox>"
   3.421 -
   3.422 -	# Configuration tab
   3.423 -	WIFI_DIALOG=${WIFI_DIALOG}'
   3.424 -	<vbox>
   3.425 -		<frame Basic>
   3.426 -			<hbox>
   3.427 -				<text use-markup="true">
   3.428 -					<label>"<b>Interface:</b>"</label>
   3.429 -				</text>
   3.430 -				<entry>
   3.431 -					<input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input>
   3.432 -					<variable>WIFI_INTERFACE</variable>
   3.433 -				</entry>
   3.434 -			</hbox>
   3.435 -			<hbox>
   3.436 -				<text use-markup="true">
   3.437 -					<label>"<b>ESSID:        </b>"</label>
   3.438 -				</text>
   3.439 -				<entry>
   3.440 -					<input>. /etc/network.conf; echo "$WIFI_ESSID"</input>
   3.441 -					<variable>WIFI_ESSID</variable>
   3.442 -				</entry>
   3.443 -			</hbox>
   3.444 -			<hbox>
   3.445 -				<text use-markup="true">
   3.446 -					<label>"<b>Key:           </b>"</label>
   3.447 -				</text>
   3.448 -				<entry>
   3.449 -					<input>. /etc/network.conf; echo "$WIFI_KEY"</input>
   3.450 -					<variable>WIFI_KEY</variable>
   3.451 -				</entry>
   3.452 -				<combobox>'
   3.453 -	tmp2="${WIFI_DIALOG}<item>$WIFI_KEY_TYPE</item>"
   3.454 -	for i in none WEP WPA any; do
   3.455 -		[ "$i" = "$WIFI_KEY_TYPE" ] || tmp2="$tmp2<item>$i</item>"
   3.456 -	done
   3.457 -	tmp3='		<variable>WIFI_KEY_TYPE</variable>
   3.458 -				</combobox>
   3.459 -			</hbox>
   3.460 -		</frame>
   3.461 -		<frame Advanced>
   3.462 -			<hbox>
   3.463 -				<text use-markup="true">
   3.464 -					<label>"<b>Channel/Mode:</b>"</label>
   3.465 -				</text>
   3.466 -				<entry>
   3.467 -					<input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input>
   3.468 -					<variable>WIFI_CHANNEL</variable>
   3.469 -				</entry>
   3.470 -				
   3.471 -				<combobox>
   3.472 -					<variable>WIFI_MODE</variable>'
   3.473 -	tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>"
   3.474 -	for i in managed ad-hoc master repeater secondary monitor; do
   3.475 -		[ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>"
   3.476 -	done
   3.477 -	tmp3='		</combobox>
   3.478 -			</hbox>
   3.479 -			<hbox>
   3.480 -				<text use-markup="true">
   3.481 -					<label>"<b>Iwconfig args:</b> "</label>
   3.482 -				</text>
   3.483 -				<entry>
   3.484 -					<input>. /etc/network.conf; echo "$WIFI_IWCONFIG_ARGS"</input>
   3.485 -					<variable>WIFI_IWCONFIG_ARGS</variable>
   3.486 -				</entry>'
   3.487 -	WIFI_DIALOG="$tmp$tmp2$tmp3
   3.488 -	$(helpbutton iwconfig 80x24)
   3.489 -	$(manbutton 8 iwconfig)
   3.490 -			</hbox>
   3.491 -		</frame>"
   3.492 -		
   3.493 -	# Start Button for manual configuration.
   3.494 -	WIFI_DIALOG=${WIFI_DIALOG}'
   3.495 -		<hbox>
   3.496 -			<button>
   3.497 -				<label>Start connection</label>
   3.498 -				<input file icon="forward"></input>
   3.499 -				<action>[ "$WIFI_KEY_TYPE" = "WPA" -a ! -x /usr/bin/wpa_supplicant ] && xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "wpa_supplicant install" -e "tazpkg get-install wpa_supplicant ; echo -e \"----\n\nENTER to continue...\" && read close"</action>
   3.500 -				<action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/ /etc/network.conf</action>
   3.501 -				<action>sed -i s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
   3.502 -				<action>sed -i s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
   3.503 -				<action>sed -i s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
   3.504 -				<action>sed -i s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
   3.505 -				<action>sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" /etc/network.conf</action>
   3.506 -				<action>sed -i s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
   3.507 -				<action>sed -i s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
   3.508 -				<action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
   3.509 -				<action>ifconfig $WIFI_INTERFACE down</action>
   3.510 -				<action>iwconfig $WIFI_INTERFACE txpower auto</action>
   3.511 -				<action>/etc/init.d/network.sh restart</action>
   3.512 -				<action>refresh:ESSID_LIST</action>
   3.513 -				<action>refresh:WIFI_ESSID</action>
   3.514 -				<action>refresh:WIFI_KEY</action>
   3.515 -				<action>refresh:WIFI_KEY_TYPE</action>
   3.516 -			</button>
   3.517 -		</hbox>
   3.518 -	</vbox>'
   3.519 -
   3.520 -	# Kernel Modules, firmware and tazndisbox note + button.
   3.521 -	WIFI_DIALOG=${WIFI_DIALOG}"
   3.522 -	<vbox>
   3.523 -		<hbox>
   3.524 -			<text width-chars=\"64\">
   3.525 -				<label>
   3.526 -\"
   3.527 -Some Wireless Adapters need non-free firmware. Please install the
   3.528 -firmware before loading the corresponding module. Note: you can use 
   3.529 -Tazhw to automatically detect your PCI, PCMCIA or USB Wireless adapter.
   3.530 -\"
   3.531 -				</label>
   3.532 -			</text>
   3.533 -		</hbox>
   3.534 -		<hbox>
   3.535 -			<text use-markup=\"true\">
   3.536 -				<label>\"<b>Tools:</b>\"</label>
   3.537 -			</text>
   3.538 -			<button>
   3.539 -				<input file icon=\"computer\"></input>
   3.540 -				<label>Auto detect devices</label>
   3.541 -				<action>tazhw box</action>
   3.542 -				<action>refresh:ESSID_LIST</action>
   3.543 -			</button>"
   3.544 -			# Display firmware stuff, tazndisbox button if installed and close 
   3.545 -			# tab + notebook
   3.546 -			if [ -x /usr/bin/tazndisbox ]; then
   3.547 -				WIFI_DIALOG=${WIFI_DIALOG}"
   3.548 -			<button>
   3.549 -				<input file icon=\"system-installer\"></input>
   3.550 -				<label>Install Windows driver</label>
   3.551 -				<action>tazndisbox</action>
   3.552 -				<action>refresh:ESSID_LIST</action>
   3.553 -			</button>"
   3.554 -			fi
   3.555 -		WIFI_DIALOG=${WIFI_DIALOG}"
   3.556 -		</hbox>
   3.557 -		<hbox>
   3.558 -			<text use-markup=\"true\">
   3.559 -				<label>\"<b>Module:</b>\"</label>
   3.560 -			</text>
   3.561 -			<combobox>
   3.562 -				<variable>MODULE</variable>"
   3.563 -	WIFI_DIALOG="${WIFI_DIALOG}$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f 2> /dev/null |  sed 's,/.*/\(.*\).ko.*,<item>\1</item>,')"
   3.564 -	WIFI_DIALOG=${WIFI_DIALOG}'
   3.565 -			</combobox>
   3.566 -			<button>
   3.567 -				<label>Load</label>
   3.568 -				<input file icon="forward"></input>
   3.569 -				<action>modprobe $MODULE</action>
   3.570 -			</button>
   3.571 -			<button>
   3.572 -				<label>Unload</label>
   3.573 -				<input file icon="undo"></input>
   3.574 -				<action>modprobe -r $MODULE</action>
   3.575 -			</button>
   3.576 -			<button>
   3.577 -				<label>Lsmod</label>
   3.578 -				<input file icon="computer"></input>
   3.579 -				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
   3.580 -			</button>
   3.581 -		</hbox>'
   3.582 -	# Firmware stuff.
   3.583 -	tmp=$(for i in /usr/bin/get*firmware; do
   3.584 -		[ -x $i ] || continue
   3.585 -		[ "$i" = "/usr/bin/get-wifi-firmware" ] && continue
   3.586 -		[ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue
   3.587 -		echo "<item>${i#/usr/bin/get-}</item>"; done)
   3.588 -		[ -n "$tmp" ] && tmp="
   3.589 -		<hbox>
   3.590 -			<text use-markup=\"true\">
   3.591 -				<label>\"<b>Firmware:</b>\"</label>
   3.592 -			</text>
   3.593 -			<combobox><variable>FIRMWARE</variable>$tmp</combobox>
   3.594 -			<button>
   3.595 -				<label>Install</label>
   3.596 -				<input file icon=\"go-jump\"></input>
   3.597 -				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
   3.598 -				<action>refresh:ESSID_LIST</action>
   3.599 -			</button>
   3.600 -			<button>
   3.601 -				<input file icon=\"system-file-manager\"></input>
   3.602 -				<label>List files</label>
   3.603 -				<action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 100x25 -title \"Firmware files (q to quit)\" -e \"find /lib/firmware -exec ls -ld {} \; | less\"</action>
   3.604 -				<action>refresh:ESSID_LIST</action>
   3.605 -			</button>
   3.606 -		</hbox>"
   3.607 -
   3.608 -# Bottom buttons
   3.609 -export WIFI_DIALOG=${WIFI_DIALOG}${tmp}"
   3.610 -		</vbox>
   3.611 -	</notebook>
   3.612 -	<hbox>
   3.613 -		<button>
   3.614 -			<label>Stop connection</label>
   3.615 -			<input file icon=\"stop\"></input>
   3.616 -			<action>$0 stop_wifi_connexion</action>
   3.617 -			<action>refresh:ESSID_LIST</action>
   3.618 -		</button>
   3.619 -		<button>
   3.620 -			<label>Exit</label>
   3.621 -			<input file icon=\"exit\"></input>
   3.622 -			<action type=\"exit\">Exit</action>
   3.623 -		</button>
   3.624 -	</hbox>
   3.625 -	
   3.626 -</vbox>
   3.627 -</window>"
   3.628 -	gtkdialog --center --program=WIFI_DIALOG #>/dev/null 2>&1
   3.629 -}
   3.630 -
   3.631 -if [ -n "$1" ]; then
   3.632 -	$1
   3.633 -else
   3.634 -	box
   3.635 -fi
   3.636 -
   3.637 -exit 0