slitaz-tools diff installer/tazinst @ rev 656

tazinst: showurl+check commands added
author Dominique Corbex <domcox@slitaz.org>
date Mon Jul 25 12:03:18 2011 +0200 (2011-07-25)
parents b28d4a6bf467
children 9ec8aeb6a41f
line diff
     1.1 --- a/installer/tazinst	Wed Jul 20 15:29:22 2011 +0200
     1.2 +++ b/installer/tazinst	Mon Jul 25 12:03:18 2011 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  #!/bin/sh
     1.5 -# slitaz-installer - SliTaz GNU/Linux installer.
     1.6 +# tazinst - SliTaz GNU/Linux installer.
     1.7  #
     1.8  # So this is the SliTaz installer. The script starts with a
     1.9  # few main variables, then all the functions and then the 
    1.10 @@ -10,16 +10,16 @@
    1.11  # Authors : Christophe Lincoln <pankso@slitaz.org>
    1.12  #           Dominique Corbex <domcox@slitaz.org>
    1.13  #
    1.14 -# Exit codes
    1.15 +# Exit codes:
    1.16  # 1: Parameters error 
    1.17  # 2: Configuration file error
    1.18  # 3: Source error
    1.19  # 4: Cancelled by user
    1.20  # 5: Target partition error
    1.21 -# 6: No SliTaz system to upgrade found
    1.22 +# 6: SliTaz system to upgrade not found
    1.23  # 8: Internal error
    1.24  
    1.25 -VERSION=3.01
    1.26 +VERSION=3.10
    1.27  
    1.28  # Internationalization
    1.29  . /usr/bin/gettext.sh
    1.30 @@ -39,17 +39,22 @@
    1.31  URL_COOKING="http://mirror.slitaz.org/iso/cooking/slitaz-cooking.iso"
    1.32  URL_ROLLING="http://mirror.slitaz.org/iso/rolling/slitaz-core.iso"
    1.33  
    1.34 +# Config
    1.35 +[ -r /etc/slitaz/tazinst.conf ] && . /etc/slitaz/tazinst.conf
    1.36 +
    1.37  # Print a short help
    1.38  usage()
    1.39  {
    1.40  	echo -e "\n`gettext \"Tazinst - SliTaz installer - Version\"`: $VERSION\n"
    1.41  	echo -e "\033[1m`gettext \"Usage\"`:"
    1.42 -	echo -e "\033[0m `gettext \"tazinst [command] [config-file]\"`\n"
    1.43 +	echo -e "\033[0m `gettext \"tazinst [command] [config-file|url|options]\"`\n"
    1.44  	echo -e "\033[1m`gettext \"Commands\"`: \033[0m"
    1.45  	echo -e "usage         `gettext \"Print this short usage.\"`"
    1.46  	echo -e "install       `gettext \"Install SliTaz on HDD using a configuration file.\"`"
    1.47  	echo -e "upgrade       `gettext \"Upgrade SliTaz on HDD using a configuration file.\"`"
    1.48  	echo -e "config        `gettext \"Generate a configuration file.\"`"
    1.49 +	echo -e "check         `gettext \"Check configuration file validity.\"`"
    1.50 +	echo -e "showurl       `gettext \"Show the full URL of a predefined URL (stable|cooking|rolling).\"`"
    1.51  	echo -e "cli           `gettext \"Install or upgrade using command line options:\"`"
    1.52  	echo -e "  -i             `gettext \"Full Install (not upgrading, all present data will be lost).\"`"
    1.53  	echo -e "  -u             `gettext \"Upgrade (Needs an active internet connection).\"`"
    1.54 @@ -76,7 +81,7 @@
    1.55  		umount $TARGET_ROOT 2>>$LOG
    1.56  	fi
    1.57  	echo -e "`gettext \"Error\"` $@"
    1.58 -	echo -e "`gettext \"Installation cancelled\"`"
    1.59 +#	echo -e "`gettext \"Installation cancelled\"`"
    1.60  	test $(id -u) = 0 && echo "Installation cancelled on error $@" >> $LOG
    1.61  	exit $1
    1.62  }
    1.63 @@ -270,7 +275,7 @@
    1.64  
    1.65  	# Check Action
    1.66  	case $INST_ACTION in
    1.67 -		install|upgrade) ;;
    1.68 +		install|upgrade|check) ;;
    1.69  		*) msg `gettext "INST_ACTION=$INST_ACTION: Invalid setting"`; error=yes ;;
    1.70  	esac
    1.71  
    1.72 @@ -299,7 +304,7 @@
    1.73  				msg `gettext "SRC_FILE=$SRC_FILE: file not found"`; error=yes
    1.74  			fi ;;
    1.75  		web)
    1.76 -			if [ $(wget -sq "$SRC_FILE") ]; then
    1.77 +			if ! wget -sq "$SRC_FILE" 2> /dev/null ; then
    1.78  				msg `gettext "SRC_FILE=$SRC_FILE: file not found on the web"`; error=yes
    1.79  			fi ;;
    1.80  	esac
    1.81 @@ -766,7 +771,7 @@
    1.82  	[ -e /root/.xinitrc ] && cp /root/.xinitrc /home/$TGT_USER
    1.83  	mkdir -p /home/$TGT_USER/.config/slitaz
    1.84  	cp -a /etc/slitaz/applications.conf /home/$TGT_USER/.config/slitaz
    1.85 -	# chmod $TGT_USER:user doesn't work with most ISO
    1.86 +	# Set ownership
    1.87  	if grep -q ^users: /etc/group; then
    1.88  		chown -R $TGT_USER:users /home/$TGT_USER
    1.89  	else
    1.90 @@ -1262,6 +1267,22 @@
    1.91  				grub_install
    1.92  				end_of_install ;;
    1.93  		esac ;;
    1.94 +	showurl)
    1.95 +		case $2 in
    1.96 +			stable)
    1.97 +				echo $URL_STABLE ;;
    1.98 +			cooking)
    1.99 +				echo $URL_COOKING ;;
   1.100 +			rolling)
   1.101 +				echo $URL_ROLLING ;;
   1.102 +		esac ;;
   1.103 +	check)
   1.104 +		LOG="/dev/null"
   1.105 +		INST_ACTION=check
   1.106 +		check_root
   1.107 +		init $@
   1.108 +		read_configuration_file $2
   1.109 +		check_vars ;;
   1.110  	usage|*)
   1.111  		usage ;;
   1.112  esac