tazpanel rev 258 1.4.3

installer.cgi: setup file created later, first partitionnot set as default anymore and other bugs fixes
author Dominique Corbex <domcox@slitaz.org>
date Thu Mar 01 21:48:22 2012 +0100 (2012-03-01)
parents 96bca72731bb
children 2091e38d34c4
files installer.cgi
line diff
     1.1 --- a/installer.cgi	Thu Mar 01 18:27:17 2012 +0000
     1.2 +++ b/installer.cgi	Thu Mar 01 21:48:22 2012 +0100
     1.3 @@ -5,10 +5,9 @@
     1.4  # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
     1.5  #
     1.6  # Authors : Dominique Corbex <domcox@slitaz.org>
     1.7 -#           Christophe Lincoln <pankso@slitaz.org>
     1.8  #
     1.9  
    1.10 -VERSION=0.22
    1.11 +VERSION=0.25
    1.12  
    1.13  # Common functions from libtazpanel
    1.14  . lib/libtazpanel
    1.15 @@ -30,10 +29,6 @@
    1.16  # Tazinst setup file
    1.17  INSTFILE=/var/lib/tazinst.conf
    1.18  
    1.19 -read_setup()
    1.20 -{
    1.21 -	[ -e "$INSTFILE" ] && . $INSTFILE  || gettext "Tazinst setup file not found!"
    1.22 -}
    1.23  
    1.24  write_setup()
    1.25  {
    1.26 @@ -55,9 +50,9 @@
    1.27  		TGT_PARTITION=$(echo "$(GET TGT_PARTITION)" | sed 's/\//\\\//'g)
    1.28  		[ -n "$(GET MAIN_FMT)" ] && TGT_FS=$(GET MAIN_FS) || TGT_FS=""
    1.29  		# Home Partition
    1.30 -		if [ -n "$(GET HOME_SPLIT)" ] ; then
    1.31 -			TGT_HOME=$(echo "$(GET HOME_PART)" | sed 's/\//\\\//'g)
    1.32 -			[ -n "$(GET HOME_FMT)" ] && TGT_HOME_FS=$(GET HOME_FS)
    1.33 +		if [ -n "$(GET HOME_SELECT)" ] ; then
    1.34 +			TGT_HOME=$(echo "$(GET TGT_HOME)" | sed 's/\//\\\//'g)
    1.35 +			[ -n "$(GET HOME_FS)" ] && TGT_HOME_FS=$(GET HOME_FS)
    1.36  		else
    1.37  			TGT_HOME=""
    1.38  			TGT_HOME_FS=""
    1.39 @@ -92,21 +87,43 @@
    1.40  	fi
    1.41  }
    1.42  
    1.43 -check_setup()
    1.44 +read_setup()
    1.45  {
    1.46 -	local ret
    1.47 -	IFS=$'\n'
    1.48 -	for line in $(tazinst check $INSTFILE; ret=$?)  
    1.49 -	do
    1.50 -		line=$(echo $line | sed 's/\[1m//g')
    1.51 -		line=$(echo $line | sed 's/\[0m//g')
    1.52 -		line=$(echo $line | sed 's/\s/\&nbsp;/g')
    1.53 -		line=$(echo $line | sed 's/</\&lt;/g')
    1.54 -		line=$(echo $line | sed 's/>/\&gt;/g')
    1.55 -		echo "<font color=\"red\">$line<br /></font>"
    1.56 -	done  
    1.57 -	unset IFS
    1.58 -	return $ret
    1.59 +	# various checks on setup file
    1.60 +	if [ -e "$INSTFILE" ]; then
    1.61 +		# validity check + reformat output
    1.62 +		IFS=$'\n'
    1.63 +		for line in $(tazinst check $INSTFILE)  
    1.64 +		do
    1.65 +			line=$(echo $line | sed 's/\[1m//g')
    1.66 +			line=$(echo $line | sed 's/\[0m//g')
    1.67 +			line=$(echo $line | sed 's/\s/\&nbsp;/g')
    1.68 +			line=$(echo $line | sed 's/</\&lt;/g')
    1.69 +			line=$(echo $line | sed 's/>/\&gt;/g')
    1.70 +			echo "<font color=\"red\">$line<br /></font>"
    1.71 +		done  
    1.72 +		unset IFS
    1.73 +	else
    1.74 +		# no setup file found: creating
    1.75 +		gettext "Creating setup file $INSTFILE."
    1.76 +		tazinst new $INSTFILE
    1.77 +		if [ ! -e "$INSTFILE" ]; then
    1.78 +			cat <<EOT
    1.79 +<font color="red">$(gettext "Setup File Error")<br />
    1.80 +$(gettext "The setup file <strong>$INSTFILE</strong> doesn't exist.")</font><br />
    1.81 +EOT
    1.82 +		else
    1.83 +			if [ ! -r $INSTFILE ]; then
    1.84 +				cat <<EOT
    1.85 +<font color="red">$(gettext "Setup File Error")<br />
    1.86 +$(gettext "The setup file <strong>$INSTFILE</strong> is not readable. 
    1.87 +Check permissions and ownership.")</font><br />
    1.88 +EOT
    1.89 +			fi	
    1.90 +		fi
    1.91 +	fi
    1.92 +	# read setup file
    1.93 +	. $INSTFILE
    1.94  }
    1.95  
    1.96  select_action()
    1.97 @@ -132,7 +149,7 @@
    1.98  	You can graphically manage your partitions with Gparted")
    1.99  </p>
   1.100  </div>
   1.101 -<a class="button" href="$SCRIPT_NAME?page=gparted">Execute Gparted</a>
   1.102 +<a class="button" href="$SCRIPT_NAME?page=gparted">$(gettext "Execute Gparted")</a>
   1.103  EOT
   1.104  }
   1.105  
   1.106 @@ -213,7 +230,7 @@
   1.107  	</tr>
   1.108  	<tr>
   1.109  	<td><input type="radio" name="INST_TYPE" value="usb" $([ "$INST_TYPE" == "usb" ] && echo "checked") id="usb" />
   1.110 -	<label for="usb">$(gettext "LiveUSB"):</label>
   1.111 +	<label for="usb">$(gettext "LiveUSB"):
   1.112  	<select name="SRC_USB">
   1.113  EOT
   1.114  	# List disks if plugged USB device
   1.115 @@ -235,7 +252,7 @@
   1.116  		echo "<option value="">$(gettext "Not found")</option>"
   1.117  	fi
   1.118  	cat << EOT
   1.119 -	</select>
   1.120 +	</select></label>
   1.121  	</td>
   1.122  	</tr>
   1.123  	<tr>
   1.124 @@ -245,20 +262,13 @@
   1.125  	</td>
   1.126  	</tr>
   1.127  	<tr>
   1.128 -	<td><input type="radio" name="INST_TYPE" value="web" $([ "$INST_TYPE" == "web" ] && echo "checked" id="web") />
   1.129 +	<td><input type="radio" name="INST_TYPE" value="web" $([ "$INST_TYPE" == "web" ] && echo "checked") id="web" />
   1.130  	<label for="web">$(gettext "Web"):
   1.131 -	<a class="button" href="$SCRIPT_NAME?page=$(GET page)&SRC_WEB=stable">$(gettext "Stable")</a>
   1.132 -	<a class="button" href="$SCRIPT_NAME?page=$(GET page)&SRC_WEB=cooking">$(gettext "Cooking")</a>
   1.133 -	$(gettext "URL:")</label>
   1.134 -EOT
   1.135 -	case $(GET SRC_WEB) in
   1.136 -		stable|cooking)
   1.137 -			get_SRC_WEB=$(tazinst showurl $(GET SRC_WEB)) ;;
   1.138 -		*)
   1.139 -			[ "$INST_TYPE" == "web" ] && get_SRC_WEB=$SRC_FILE ;;
   1.140 -	esac
   1.141 -cat <<EOT
   1.142 -	<input type="url" size="55" name="SRC_WEB" value="$get_SRC_WEB" placeholder="$(gettext "Full url to an ISO image file")" /></td>
   1.143 +	<a class="button" onclick="document.forms['ConfigForm'].url.value = '$(tazinst showurl stable)'; return true;">$(gettext "Stable")</a>
   1.144 +	<a class="button" onclick="document.forms['ConfigForm'].url.value = '$(tazinst showurl cooking)'; return true;">$(gettext "Cooking")</a>
   1.145 +	$(gettext "URL:")
   1.146 +	<input id="url" type="url" size="55" name="SRC_WEB" value="$get_SRC_WEB" placeholder="$(gettext "Full url to an ISO image file")" /></td>
   1.147 +	</label>
   1.148  	</tr>
   1.149  	</table>
   1.150  EOT
   1.151 @@ -276,6 +286,7 @@
   1.152  EOT
   1.153  	# List partitions
   1.154  	if fdisk -l | grep -q ^/dev/ ; then
   1.155 +		echo "<option value="">$(gettext "None")</option>"
   1.156  		for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
   1.157  			echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo "selected")>$i</option>"
   1.158  		done
   1.159 @@ -313,6 +324,7 @@
   1.160  EOT
   1.161  	# List partitions
   1.162  	if fdisk -l | grep -q ^/dev/ ; then
   1.163 +		echo "<option value="">$(gettext "None")</option>"
   1.164  		for i in `blkid | cut -d ":" -f 1`; do
   1.165  			echo "<option value='$i' $([ "$i" == "$TGT_PARTITION" ] && echo "selected")>$i</option>"
   1.166  		done
   1.167 @@ -331,12 +343,13 @@
   1.168  	cat <<EOT
   1.169  <a name="home"></a>
   1.170  <h4>$(gettext "Home partition")</h4>
   1.171 -<input type="checkbox" name="HOME_SPLIT" value="yes" $([ -n "$TGT_HOME" ] && echo "checked") id="homepart" />
   1.172 +<input type="checkbox" name="HOME_SELECT" value="yes" $([ -n "$TGT_HOME" ] && echo "checked") id="homepart" />
   1.173  	<label for="homepart">$(gettext "Use a separate partition for /home:")</label>
   1.174 -	<select name="HOME_PART">
   1.175 +	<select name="TGT_HOME">
   1.176  EOT
   1.177  	# List disk if plugged USB device
   1.178  	if fdisk -l | grep -q ^/dev/ ; then
   1.179 +		echo "<option value="">$(gettext "None")</option>"
   1.180  		for i in $(fdisk -l | awk '/^\/dev/ {printf "%s " $1}'); do
   1.181  			echo "<option value='$i' $([ "$i" == "$TGT_HOME" ] && echo "selected")>$i</option>"
   1.182  		done
   1.183 @@ -481,27 +494,6 @@
   1.184  EOT
   1.185  			code=1
   1.186  		fi
   1.187 -		# Check setup file
   1.188 -		if [ !  -e "$INSTFILE" ]; then
   1.189 -			gettext "Creating setup file $INSTFILE."
   1.190 -			tazinst new $INSTFILE
   1.191 -		fi
   1.192 -		if [ ! -e "$INSTFILE" ]; then
   1.193 -			cat <<EOT
   1.194 -<h3>$(gettext "Setup File Error")</h3>
   1.195 -<p>$(gettext "The setup file <strong>$INSTFILE</strong> doesn't exist.")</p>
   1.196 -EOT
   1.197 -			code=1
   1.198 -		else
   1.199 -			if [ ! -r $INSTFILE ]; then
   1.200 -				cat <<EOT
   1.201 -<h3>$(gettext "Setup File Error")</h3>
   1.202 -<p>$(gettext "The setup file <strong>$INSTFILE</strong> is not readable. 
   1.203 -Check permissions and ownership.")</p>
   1.204 -EOT
   1.205 -				code=1
   1.206 -			fi
   1.207 -		fi
   1.208  	fi
   1.209  	return $code
   1.210  }
   1.211 @@ -563,13 +555,10 @@
   1.212  		page_redirection home
   1.213  		;;
   1.214  	install)
   1.215 -		read_setup
   1.216  		xhtml_header
   1.217  		form_start
   1.218  		display_action install
   1.219 -		# The config file is generic and will be created now.
   1.220 -		# Should be done after: moveto_page home write ?
   1.221 -		#check_setup
   1.222 +		read_setup
   1.223  		select_source
   1.224  		select_partition
   1.225  		select_home
   1.226 @@ -581,11 +570,10 @@
   1.227  		form_end
   1.228  		;;
   1.229  	upgrade)
   1.230 -		read_setup
   1.231  		xhtml_header
   1.232  		form_start
   1.233  		display_action upgrade
   1.234 -		check_setup
   1.235 +		read_setup
   1.236  		select_source
   1.237  		select_old_slitaz
   1.238  		select_grub
   1.239 @@ -625,16 +613,13 @@
   1.240  	menu_install)
   1.241  		xhtml_header
   1.242  		if check_ressources; then
   1.243 -			select_action
   1.244 -			select_gparted
   1.245 -			select_install
   1.246 +			page_redirection install
   1.247  		fi
   1.248  		;;
   1.249  	menu_upgrade)
   1.250  		xhtml_header
   1.251  		if check_ressources; then
   1.252 -			select_action
   1.253 -			select_upgrade
   1.254 +			page_redirection upgrade
   1.255  		fi
   1.256  		;;
   1.257  	*)