# HG changeset patch # User Pascal Bellard # Date 1314963984 -7200 # Node ID 07084286f28cef07eb5bdd33e3b2662fab2ebdcd # Parent 7e3623f26c5ea9c888b14d33cc63378064ac6bdf Add Install tab (thanks Dominique) diff -r 7e3623f26c5e -r 07084286f28c installer.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/installer.cgi Fri Sep 02 13:46:24 2011 +0200 @@ -0,0 +1,639 @@ +#!/bin/sh +# +# Main CGI interface for Tazinst, the SliTaz installer. +# +# Copyright (C) 2011 SliTaz GNU/Linux - BSD License +# +# Authors : Dominique Corbex +# + +VERSION=0.21 + +# Common functions from libtazpanel +. lib/libtazpanel +header +get_config + +# Include gettext helper script. +. /usr/bin/gettext.sh + +# Export package name for gettext. +TEXTDOMAIN='installer' +export TEXTDOMAIN + +TITLE="- Installer" + +# Tazinst required version +TAZINST_REQUIRED_VERSION="3.3" + +# Tazinst setup file +INSTFILE=/var/lib/tazinst.conf + +read_setup() +{ + [ -e "$INSTFILE" ] && . $INSTFILE || gettext "Tazinst setup file not found!" +} + +write_setup() +{ + if [ -e "$INSTFILE" ]; then + # Install type + INST_TYPE=$(GET INST_TYPE) + # Source File + case "$INST_TYPE" in + usb) + SRC_FILE=$(GET SRC_USB) ;; + iso) + SRC_FILE=$(GET SRC_ISO) ;; + web) + SRC_FILE=$(GET SRC_WEB) ;; + esac + SRC_FILE=$(echo "$SRC_FILE" | sed 's/\//\\\//'g) + [ -n $(GET URL) ] && SRC_WEB=$(GET URL) + # Main Partition + TGT_PARTITION=$(echo "$(GET TGT_PARTITION)" | sed 's/\//\\\//'g) + [ -n "$(GET MAIN_FMT)" ] && TGT_FS=$(GET MAIN_FS) || TGT_FS="" + # Home Partition + if [ -n "$(GET HOME_SPLIT)" ] ; then + TGT_HOME=$(echo "$(GET HOME_PART)" | sed 's/\//\\\//'g) + [ -n "$(GET HOME_FMT)" ] && TGT_HOME_FS=$(GET HOME_FS) + else + TGT_HOME="" + TGT_HOME_FS="" + fi + # Hostname + TGT_HOSTNAME=$(GET TGT_HOSTNAME) + # Root pwd + TGT_ROOT_PWD=$(GET TGT_ROOT_PWD) + # User Login + TGT_USER=$(GET TGT_USER) + # User Pwd + TGT_USER_PWD=$(GET TGT_USER_PWD) + # Grub + TGT_GRUB=$(GET TGT_GRUB) + [ "$TGT_GRUB" == "yes" ] || TGT_GRUB=no + # Win Dual-Boot + TGT_WINBOOT=$(GET TGT_WINBOOT) + + # Save changes to INSTFILE + sed -i s/"^INST_TYPE=.*"/"INST_TYPE=\"$INST_TYPE\"/" $INSTFILE + sed -i s/"^SRC_FILE=.*"/"SRC_FILE=\"$SRC_FILE\"/" $INSTFILE + sed -i s/"^TGT_PARTITION=.*"/"TGT_PARTITION=\"$TGT_PARTITION\"/" $INSTFILE + sed -i s/"^TGT_FS=.*"/"TGT_FS=\"$TGT_FS\"/" $INSTFILE + sed -i s/"^TGT_HOME=.*"/"TGT_HOME=\"$TGT_HOME\"/" $INSTFILE + sed -i s/"^TGT_HOME_FS=.*"/"TGT_HOME_FS=\"$TGT_HOME_FS\"/" $INSTFILE + sed -i s/"^TGT_HOSTNAME=.*"/"TGT_HOSTNAME=\"$TGT_HOSTNAME\"/" $INSTFILE + sed -i s/"^TGT_ROOT_PWD=.*"/"TGT_ROOT_PWD=\"$TGT_ROOT_PWD\"/" $INSTFILE + sed -i s/"^TGT_USER=.*"/"TGT_USER=\"$TGT_USER\"/" $INSTFILE + sed -i s/"^TGT_USER_PWD=.*"/"TGT_USER_PWD=\"$TGT_USER_PWD\"/" $INSTFILE + sed -i s/"^TGT_GRUB=.*"/"TGT_GRUB=\"$TGT_GRUB\"/" $INSTFILE + sed -i s/"^TGT_WINBOOT=.*"/"TGT_WINBOOT=\"$TGT_WINBOOT\"/" $INSTFILE + fi +} + +check_setup() +{ + local ret + IFS=$'\n' + for line in $(tazinst check $INSTFILE; ret=$?) + do + line=$(echo $line | sed 's/\[1m//g') + line=$(echo $line | sed 's/\[0m//g') + line=$(echo $line | sed 's/\s/\ /g') + line=$(echo $line | sed 's//\>/g') + echo "$line
" + done + unset IFS + return $ret +} + +select_action() +{ + cat < +

$(gettext "SliTaz Installer")

+

$(gettext "The SliTaz Installer installs or upgrade SliTaz to a hard disk + drive from a device like a Live-CD or LiveUSB key, from a SliTaz ISO file, or + from the web by downloading an ISO file.")

+ +EOT +} + +select_gparted() +{ + cat < + + $(gettext "Before installation, you'll may need to resize partitions +on your hard disk drive in order to make space for SlItaz GNU/Linux.") + + +EOT +} + +select_install() +{ + cat < +

+ + + + + + + + + + +

$(gettext "Install")

$(gettext "Install SliTaz on a partition of your hard disk drive. If + you decide to format your HDD, all data will be lost. If you do not + format, all data except for any existing /home directory will be removed, + the home directory will be kept as is.")
$(gettext "Install SliTaz")
+EOT +} + +select_upgrade() +{ + cat < + +

$(gettext "Upgrade")

+ + + $(gettext "Upgrade an already installed SliTaz system on your hard disk + drive. Your /home /etc /var/www directories will be kept, all other directories + will be removed. Any additional package added to your old Slitaz system + will be updated as long you have an active internet connection.") + + + $(gettext "Upgrade SliTaz") + + + +EOT +} + +display_action() +{ + case $1 in + install) + cat << EOT +
+

$(gettext "Install SliTaz")

+

$(gettext "You're going to install SliTaz on a partition of your hard disk drive. If + you decide to format your HDD, all data will be lost. If you do not + format, all data except for any existing /home directory will be removed, + the home directory will be kept as is.")

+

+ +EOT + ;; + upgrade) + cat << EOT +
+

$(gettext "Upgrade SliTaz")

+

$(gettext "You're going to upgrade an already installed SliTaz system on your hard disk + drive. Your /home /etc /var/www directories will be kept, all other directories + will be removed. Any additional package added to your old Slitaz system + will be updated as long you have an active internet connection.")

+

+ +EOT + ;; + esac +} + +select_source() +{ + cat < +

$(gettext "Source")

+ + + + + + + + + + + + + +
+
+ + +
+ + +
+ +EOT + case $(GET SRC_WEB) in + stable|cooking) + get_SRC_WEB=$(tazinst showurl $(GET SRC_WEB)) ;; + *) + [ "$INST_TYPE" == "web" ] && get_SRC_WEB=$SRC_FILE ;; + esac +cat <
+EOT +} + +select_partition() +{ +cat < +

$(gettext "Main Partition")

+ + +
+ $(gettext "Partition to use:") + +
+ + +
+EOT +} + +select_old_slitaz() +{ +cat < +

$(gettext "Existing SliTaz Partition")

+ + +
+ $(gettext "Partition in use:") +
+EOT +} + +select_home() +{ + cat < +

$(gettext "Home partition")

+ + + + + " +} + +select_hostname() +{ +cat << EOT + +

$(gettext "Host")

+$(gettext "Hostname:") + +EOT +} + +select_root() +{ +cat << EOT + +

$(gettext "Root")

+$(gettext "Root passwd:") + +EOT +} + +select_user() +{ +cat << EOT + +

$(gettext "User")

+$(gettext "User login:") + +$(gettext "User passwd:") + +EOT +} + +select_grub() +{ +cat << EOT + +

$(gettext "Grub")

+ + + + +EOT +} + +moveto_page() +{ + case $1 in + *) + page=home + title1=$(gettext "Back to Installer Start Page") ;; + esac + case $2 in + write|run) + title2=$(gettext "Proceed to SliTaz installation") ;; + reboot) + title2=$(gettext "Installation complete. You can now restart (reboot)") ;; + failed) + title2=$(gettext "Installation failed. See log") ;; + *) + page=home + title2=$(gettext "Back to Installer Start Page") ;; + esac + cat < + function SubmitForm() { + var r=confirm("$(gettext "Do you really want to continue?")"); + if (r==true) + { + document.ConfigForm.submit(); + } + } + +
+ +$title1 +$title2 +EOT +} + +page_redirection() +{ + cat < + +$(gettext "A web page that points a browser to a different page after 2 seconds") + + + + +$(gettext "If your browser doesn't automatically go there within a few seconds, +you may want to go manually to ") +$1 + + +EOT +} + +check_ressources() +{ + local code + code=0 + # Check tazinst + if ! tazinst usage | grep -q Usage: ; then + cat <$(gettext "Tazinst Error") +

tazinst, $(gettext "the lightweight SliTaz HDD installer +is missing. Any installation can't be done without tazinst.")

+

$(gettext "Check tazinst' permissions, or reinstall the slitaz-tools package:")

+# tazpkg get-install slitaz-tools --forced +EOT + code=1 + else + # Check tazinst required version + v=$(tazinst version | tr -d '[:alpha:]') + r=$TAZINST_REQUIRED_VERSION + if ! (echo "$v" | awk -v r=$r '{v=$v+0}{ if (v < r) exit 1}') ; then + cat <$(gettext "Tazinst Error") +

tazinst ($v) $(gettext "is not at the required version ($r), +use tazinst in a xterm or reinstall the slitaz-tools package:")

+# tazpkg get-install slitaz-tools --forced +EOT + code=1 + fi + # Check setup file + if [ ! -e "$INSTFILE" ]; then + gettext "Creating setup file $INSTFILE." + tazinst new $INSTFILE + fi + if [ ! -e "$INSTFILE" ]; then + cat <$(gettext "Setup File Error") +

$(gettext "The setup file $INSTFILE doesn't exists.")

+EOT + code=1 + else + if [ ! -r $INSTFILE ]; then + cat <$(gettext "Setup File Error") +

$(gettext "The setup file $INSTFILE is not readable. +Check permissions and ownership.")

+EOT + code=1 + fi + fi + fi + return $code +} + +run_tazinst() +{ + echo "

$(gettext "Proceeding: ()")

" + gettext "Please wait until processing is complete" + table_start + tazinst $(GET INST_ACTION) $INSTFILE | \ + awk '{print "" $0 ""}' + table_end + return $(grep -c "cancelled on error" $INSTFILE) +} + +tazinst_log() +{ + echo "
"
+	tazinst log
+	echo "
" +} + +scan_mkfs() +{ + for path in /bin /sbin /usr/bin /usr/sbin + do + [ -e $path/mkfs.btrfs ] && FS=btrfs + [ -e $path/mkfs.cramfs ] && FS="$FS cramfs" + [ -e $path/mkfs.ext2 ] && FS="$FS ext2" + [ -e $path/mkfs.ext3 ] && FS="$FS ext3" + [ -e $path/mkfs.ext4 ] && FS="$FS ext4" + [ -e $path/mkfs.vfat ] && FS="$FS fat32" + [ -e $path/mkfs.jfs ] && FS="$FS jfs" + [ -e $path/mkfs.minix ] && FS="$FS minix" + [ -e $path/mkfs.ntfs ] && FS="$FS ntfs" + [ -e $path/mkfs.reiserfs ] && FS="$FS reiserfs" + [ -e $path/mkfs.xfs ] && FS="$FS xfs" + done +} + +form_start() +{ + cat < +EOT +} + +form_end() +{ + echo "" +} + +# +# Main +# + +case "$(GET page)" in + gparted) + /usr/sbin/gparted + xhtml_header + page_redirection home + ;; + install) + read_setup + xhtml_header + form_start + display_action install + check_setup + select_source + select_partition + select_home + select_hostname + select_root + select_user + select_grub + moveto_page home write + form_end + ;; + upgrade) + read_setup + xhtml_header + form_start + display_action upgrade + check_setup + select_source + select_old_slitaz + select_grub + moveto_page home write + form_end + ;; + write) + write_setup + xhtml_header + if ! (tazinst check $INSTFILE); then + page_redirection $(GET INST_ACTION) + else + read_setup + form_start + display_action $(GET INST_ACTION) + if run_tazinst; then + moveto_page home reboot + else + moveto_page home failed + fi + form_end + fi + ;; + reboot) + reboot ;; + home) + xhtml_header + select_action + select_gparted + select_install + select_upgrade + ;; + failed) + xhtml_header + display_log + ;; + *) + xhtml_header + if check_ressources; then + page_redirection home + fi + ;; +esac + +xhtml_footer + +exit 0 diff -r 7e3623f26c5e -r 07084286f28c styles/default/header.html --- a/styles/default/header.html Tue Aug 30 17:15:31 2011 +0200 +++ b/styles/default/header.html Fri Sep 02 13:46:24 2011 +0200 @@ -27,6 +27,7 @@ Live Boot Hardware + Install