summaryrefslogtreecommitdiffstats
path: root/setup2hd.tpl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsetup2hd.tpl302
1 files changed, 83 insertions, 219 deletions
diff --git a/setup2hd.tpl b/setup2hd.tpl
index 4bc48bb..f87a697 100755
--- a/setup2hd.tpl
+++ b/setup2hd.tpl
@@ -37,8 +37,29 @@
export LANG=C
export LC_ALL=C
+# The script defaults to curses dialog but Xdialog is a good alternative:
+DIALOG=${DIALOG:-"dialog"}
+
+# Script needs to be run as root:
+if [ ${EUID} -ne 0 ]; then
+ ${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ --title "NOT ROOT" --msgbox "\
+\n\
+You must be root to run this program!" 7 68
+ exit 1
+fi
+
+# The terminal window needs to be sufficiently large for cgdisk to fit:
+if [ $(tput cols) -lt 80 ] || [ $(tput lines) -lt 24 ]; then
+ ${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ --title "TERMINAL TOO SMALL" --msgbox "\
+\n\
+Before you continue, re-size your terminal\nso it measures at least 80 x 24 characters.\n\
+Otherwise you will not be able to use disk partition tools." 11 68
+fi
+
if [ ! -d /mnt/livemedia/@LIVEMAIN@/system ]; then
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ ${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
--title "LIVE MEDIA NOT ACCESSIBLE" --msgbox "\
\n\
Before you can install software, complete the following tasks:\n\
@@ -66,7 +87,7 @@ echo "on" > $TMP/SeTcolor # turn on color menus
PATH="$PATH:/usr/share/@LIVEMAIN@"
export PATH;
export COLOR=on
-dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" --infobox "\n
+${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" --infobox "\n
Scanning your system for partition information...\n
\n" 5 55
# In case the machine is full of fast SSDs:
@@ -76,8 +97,8 @@ sleep 1
vgchange -ay 1> /dev/null 2> /dev/null
if probe -l 2> /dev/null | grep -E 'Linux$' 1> /dev/null 2> /dev/null ; then
RUNPART=no
- probe -l 2> /dev/null | grep -E 'Linux$' | sort 1> $TMP/SeTplist 2> /dev/null
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ probe -l 2>/dev/null |grep -E 'Linux$' |sort |uniq 1>$TMP/SeTplist 2>/dev/null
+ ${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
--title "LINUX PARTITIONS DETECTED" \
--yes-label "Continue" --no-label "Skip" --defaultno \
--yesno "Setup detected partitions on this machine of type Linux.\n\
@@ -92,7 +113,7 @@ Otherwise, select 'Skip' to skip disk partitioning and go on with the setup." \
fi
else
RUNPART=yes
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ ${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
--title "NO LINUX PARTITIONS DETECTED" \
--msgbox "There don't seem to be any partitions on this machine of type \
Linux. You'll need to make at least one of these to install Linux. \
@@ -100,9 +121,13 @@ To do this, you'll get a chance to make these partitions now using \
'cfdisk' (MBR partitions) or 'cgdisk' (GPT partitions)." 10 64
fi
if [ -d /sys/firmware/efi ]; then
+ # First, let's make sure that efivarfs is active:
+ if [ "$(/bin/ls /sys/firmware/efi/efivars 2> /dev/null | wc -l)" = "0" ]; then
+ mount -t efivarfs none /sys/firmware/efi/efivars
+ fi
if ! probe -l 2> /dev/null | grep "EFI System Partition" 1> /dev/null 2> /dev/null ; then
RUNPART=yes
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ ${DIALOG} --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
--title "NO EFI SYSTEM PARTITION DETECTED" \
--msgbox "This machine appears to be using EFI/UEFI, but no EFI System \
Partition was found. You'll need to make an EFI System Partition in order \
@@ -135,11 +160,11 @@ ROOT_DEVICE="`mount | grep "on / " | cut -f 1 -d ' '`"
echo "$ROOT_DEVICE" > $TMP/SeTrootdev
if mount | grep /var/log/mount 1> /dev/null 2> /dev/null ; then # clear source location:
# In case of bind mounts, try to unmount them first:
- umount /var/log/mount/dev 2> /dev/null
- umount /var/log/mount/proc 2> /dev/null
- umount /var/log/mount/sys 2> /dev/null
+ umount -R /var/log/mount/dev 2> /dev/null
+ umount -R /var/log/mount/proc 2> /dev/null
+ umount -R /var/log/mount/sys 2> /dev/null
# Unmount target partition:
- umount /var/log/mount
+ umount -R /var/log/mount
fi
# Anything mounted on /var/log/mount now is a fatal error:
if mount | grep /var/log/mount 1> /dev/null 2> /dev/null ; then
@@ -157,18 +182,18 @@ rm -f /var/log/mount 2> /dev/null
rmdir /var/log/mount 2> /dev/null
mkdir /var/log/mount 2> /dev/null
+MAINSELECT="ADDSWAP"
while [ 0 ]; do
- dialog --title "@CDISTRO@ Linux Setup (version @SL_VERSION@)" \
+ ${DIALOG} --title "@CDISTRO@ Linux Setup (version @SL_VERSION@)" \
--backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
+ --default-item "$MAINSELECT" \
--menu "Welcome to @CDISTRO@ Linux Setup (Live Edition).\n\
Select an option below using the UP/DOWN keys and SPACE or ENTER.\n\
-Alternate keys may also be used: '+', '-', and TAB." 18 72 9 \
-"HELP" "Read the @CDISTRO@ Setup HELP file" \
-"KEYMAP" "Remap your keyboard if you're not using a US one" \
+Alternate keys may also be used: '+', '-', and TAB." 14 72 5 \
"ADDSWAP" "Set up your swap partition(s)" \
"TARGET" "Set up your target partitions" \
-"INSTALL" "Install @CDISTRO@ Live to disk" \
+"INSTALL" "Install @CDISTRO@ to disk" \
"CONFIGURE" "Reconfigure your Linux system" \
"EXIT" "Exit @CDISTRO@ Linux Setup" 2> $TMP/hdset
if [ ! $? = 0 ]; then
@@ -181,21 +206,6 @@ Alternate keys may also be used: '+', '-', and TAB." 18 72 9 \
# Start checking what to do. Some modules may reset MAINSELECT to run the
# next item in line.
- if [ "$MAINSELECT" = "HELP" ]; then
- SeTfdHELP
- fi
-
- if [ "$MAINSELECT" = "KEYMAP" ]; then
- SeTkeymap
- if [ -r $TMP/SeTkeymap ]; then
- MAINSELECT="ADDSWAP"
- fi
- fi
-
- if [ "$MAINSELECT" = "MAKE TAGS" ]; then
- SeTmaketag
- fi
-
if [ "$MAINSELECT" = "ADDSWAP" ]; then
SeTswap
if [ -r $TMP/SeTswap ]; then
@@ -211,180 +221,38 @@ Alternate keys may also be used: '+', '-', and TAB." 18 72 9 \
SeTEFI
SeTDOS
if [ -r $TMP/SeTnative ]; then
- MAINSELECT="INSTALL"
+ MAINSELECT="SOURCE"
fi
fi
- if [ "$MAINSELECT" = "INSTALL" ]; then
- if [ ! -r $TMP/SeTnative ]; then
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "CANNOT INSTALL SOFTWARE YET" --msgbox "\
-\n\
-Before you can install software, complete the following tasks:\n\
-\n\
-1. Set up your target Linux partition(s).\n\
-\n\
-You may also optionally remap your keyboard and set up your\n\
-swap partition(s). \n\
-\n\
-Press ENTER to return to the main menu." 16 68
- continue
+ if [ "$MAINSELECT" = "SOURCE" ]; then
+ SeTumedia
+ if [ -r $TMP/SeTsource ]; then
+ if [ -r $TMP/SeTlive ]; then
+ MAINSELECT="INSTALL"
+ else
+ MAINSELECT="SELECT"
+ fi
fi
+ fi
- # --------------------------------------------- #
- # Slackware Live Edition - install to disk: #
- # --------------------------------------------- #
-
- # Buy us some time while we are calculating disk usage:
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "WELCOME TO @UDISTRO@ LIVE (@LIVEDE@)" --infobox \
- "\nCalculating disk usage, please be patient ..." 5 65
-
- ACT_MODS=$(ls -rt --indicator-style=none /mnt/live/modules/ |wc -l)
- TOT_MODS=$(find /mnt/livemedia/@LIVEMAIN@/ -type f -name "*.sxz" |wc -l)
- DU_LIVE=$(du -s /mnt/live/modules/ 2>/dev/null |tr -s '\t' ' ' |cut -f1 -d' ')
- PARTFREE=$(df -P -BM $T_PX |tail -1 |tr -s '\t' ' ' |cut -d' ' -f4)
- PARTFREE=${PARTFREE%M}
-
- # Warn when it looks we have insufficient room:
- if [ $PARTFREE -lt $(($DU_LIVE/1024)) ]; then
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "WELCOME TO @UDISTRO@ LIVE (@LIVEDE@)" --yesno \
- "\nAvailable space: $PARTFREE MB\nRequired space: $(($DU_LIVE/1024))\nIt looks like your hard drive partition is too small.\nDo you want to continue?" 10 65
- retval=$?
- if [ $retval = 1 ]; then
- umount $T_PX
- exit 1
- fi
+ if [ "$MAINSELECT" = "SELECT" ]; then
+ if [ -r /var/log/mount/isolinux/setpkg ]; then
+ sh /var/log/mount/isolinux/setpkg
else
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "WELCOME TO @UDISTRO@ LIVE (@LIVEDE@)" --msgbox \
- "\nAvailable space: $PARTFREE MB\nRequired space: $(($DU_LIVE/1024)) MB\nIt looks like you're good to go!" 10 65
+ SeTPKG
fi
-
- (
- # Install the Live OS by rsyncing the readonly overlay to the harddisk:
- rsync -HAXav --whole-file --checksum-choice=none --inplace --progress --no-inc-recursive \
- /mnt/@LIVEMAIN@fs/ $T_PX/ \
- | awk '{ if (index($0, "to-chk=") > 0) { split($0, pieces, "to-chk="); split(pieces[2], term, ")"); split(term[1], division, "/"); print (1-(division[1]/division[2]))*100 }; fflush(); }' \
- | sed --unbuffered 's/^\([0-9]*\).*/\1/'
- ) | dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "INSTALLING @UDISTRO@ LIVE (@LIVEDE@) TO DISK" --gauge \
- "\nProcessing ${TOT_MODS} @CDISTRO@ Live modules ($(( $DU_LIVE/1024 )) MB)" 8 65
-
- #
- # Live OS Post Install routine. If you want, you can override this routine
- # by (re-)defining this function "live_post_install()" in a file called
- # "/usr/share/@LIVEMAIN@/setup2hd.@DISTRO@".
- #
-
- live_post_install () {
- # Re-use some of the custom configuration from 0099-@DISTRO@_zzzconf-*.sxz
- # (some of these may not be present but the command will not fail):
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "POST-INSTALL @UDISTRO@ LIVE (@LIVEDE@) DATA" --infobox \
- "\nCopying Live modifications to hard disk ..." 5 65
- sleep 1 # It's too fast...
- # Do not overwrite a custom keymap:
- if [ ! -f $T_PX/etc/rc.d/rc.keymap ]; then
- unsquashfs -f -dest $T_PX \
- /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \
- /etc/rc.d/rc.keymap
- fi
- unsquashfs -f -dest $T_PX \
- /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \
- /etc/X11/xdm/liveslak-xdm \
- /etc/X11/xorg.conf.d/30-keyboard.conf \
- /etc/inittab \
- /etc/skel \
- /etc/profile.d/lang.sh \
- /etc/rc.d/rc.font \
- /etc/rc.d/rc.gpm \
- /etc/slackpkg \
- /etc/vconsole.conf
- # Point xdm to the custom /etc/X11/xdm/liveslak-xdm/xdm-config:
- sed -i ${T_PX}/etc/rc.d/rc.4 -e 's,bin/xdm -nodaemon,& -config /etc/X11/xdm/liveslak-xdm/xdm-config,'
- # Remove the marker file from the filesystem root:
- rm -f ${T_PX}/@MARKER@
-
- # ---------------------
- # Set up a user account,
- dialog --title "@UDISTRO@ (@LIVEDE@) USER CREATION" \
- --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --msgbox "You will first get the chance to create your user account, \
-and set its password.\nYour account will be added to sudoers and suauth.\n\n\
-Next you will be asked to set root's password." 9 55
- # This will set UFULLNAME, UACCOUNT and USHELL variables:
- SeTuacct 2>&1 1> $TMP/tempresult
- if [ $? = 0 ]; then
- # User filled out the form, so let's get the results for
- # UFULLNAME, UACCOUNT and USHELL:
- source $TMP/tempresult
- rm -f $TMP/tempresult
- # Set a password for the new account:
- UPASS=$(SeTupass $UACCOUNT)
- # Create the account and set the password:
- chroot ${T_PX} /usr/sbin/useradd -c "$UFULLNAME" -g users -G wheel,audio,cdrom,floppy,plugdev,video,power,netdev,lp,scanner,kmem,dialout,games,disk,input -u 1000 -d /home/${UACCOUNT} -m -s ${USHELL} ${UACCOUNT}
- echo "${UACCOUNT}:${UPASS}" | chroot ${T_PX} /usr/sbin/chpasswd
- unset UPASS
-
- # Configure suauth:
- cat <<EOT >${T_PX}/etc/suauth
-root:${UACCOUNT}:OWNPASS
-root:ALL EXCEPT GROUP wheel:DENY
-EOT
- chmod 600 ${LIVE_ROOTDIR}/etc/suauth
-
- # Configure sudoers:
- chmod 640 ${T_PX}/etc/sudoers
- sed -i ${T_PX}/etc/sudoers -e 's/# *\(%wheel\sALL=(ALL)\sALL\)/\1/'
- chmod 440 ${T_PX}/etc/sudoers
- fi # End user creation
- # ---------------------------
-
- if [ "$(cat $T_PX/etc/shadow | grep 'root:' | cut -f 2 -d :)" = "" ]; then
- # There is no root password yet:
- UPASS=$(SeTupass root)
- echo "root:${UPASS}" | chroot ${T_PX} /usr/sbin/chpasswd
- unset UPASS
- fi
-
- cat << EOF > $TMP/tempmsg
-
- @CDISTRO@ Live Edition (@LIVEDE@) has been installed to your hard drive!
- We installed the ${ACT_MODS} active modules (out of ${TOT_MODS} available).
- The following configuration was copied from the Live OS to your harddisk:
- - console font
- - default runlevel
- - keyboard layout
- - language setting
- After finishing system configuration and before rebooting, you can add any further Live modules from /@LIVEMAIN@/addons/ and /@LIVEMAIN@/optional/ to your hard drive, using a command similar to this:
- # unsquashfs -f -dest $T_PX /mnt/livemedia/@LIVEMAIN@/addons/mymodule.sxz
-
-EOF
- dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \
- --title "POST INSTALL HINTS AND TIPS" --msgbox "`cat $TMP/tempmsg`" \
- 20 65
- rm $TMP/tempmsg
-
- MAINSELECT="CONFIGURE"
- } # END live_post_install() function
-
-
- if [ -f /usr/share/@LIVEMAIN@/setup2hd.@DISTRO@ ]; then
- # If the setup2hd post-configuration file exists, source it.
- # The file should re-define the live_post_install() function.
- . /usr/share/@LIVEMAIN@/setup2hd.@DISTRO@
+ if [ -r $TMP/SeTSERIES ]; then
+ MAINSELECT="INSTALL"
fi
+ fi
- # Now, execute the function - either our own built-in version
- # or the re-defined function from the custom setup2hd.@DISTRO@ file.
- live_post_install
-
- # --------------------------------------------- #
- # Slackware Live Edition - end install to disk: #
- # --------------------------------------------- #
-
+ if [ "$MAINSELECT" = "INSTALL" ]; then
+ if [ -r $TMP/SeTlive ]; then
+ source setup.liveslak
+ else
+ source setup.slackware
+ fi
fi
if [ "$MAINSELECT" = "CONFIGURE" ]; then
@@ -396,14 +264,14 @@ EOF
cat /usr/sbin/eliloconfig > $T_PX/usr/sbin/eliloconfig
fi
# Make bind mounts for /dev, /proc, and /sys:
- mount -o bind /dev $T_PX/dev 2> /dev/null
- mount -o bind /proc $T_PX/proc 2> /dev/null
- mount -o bind /sys $T_PX/sys 2> /dev/null
+ mount -o rbind /dev $T_PX/dev 2> /dev/null
+ mount -o rbind /proc $T_PX/proc 2> /dev/null
+ mount -o rbind /sys $T_PX/sys 2> /dev/null
SeTconfig
REPLACE_FSTAB=Y
if [ -r $TMP/SeTnative ]; then
if [ -r $T_PX/etc/fstab ]; then
- dialog --title "REPLACE /etc/fstab?" --yesno "You already have an \
+ ${DIALOG} --title "REPLACE /etc/fstab?" --yesno "You already have an \
/etc/fstab on your install partition. If you were just adding software, \
you should probably keep your old /etc/fstab. If you've changed your \
partitioning scheme, you should use the new /etc/fstab. Do you want \
@@ -427,9 +295,10 @@ to replace your old /etc/fstab with the new one?" 10 58
printf "%-16s %-16s %-11s %-16s %-3s %s\n" "proc" "/proc" "proc" "defaults" "0" "0" >> $T_PX/etc/fstab
printf "%-16s %-16s %-11s %-16s %-3s %s\n" "tmpfs" "/dev/shm" "tmpfs" "defaults" "0" "0" >> $T_PX/etc/fstab
fi
- dialog --title "SETUP COMPLETE" --msgbox "System configuration \
+ ${DIALOG} --title "SETUP COMPLETE" --msgbox "System configuration \
and installation is complete. \
\n\nYou may now reboot your system." 7 55
+ MAINSELECT="DONE"
fi
fi
@@ -437,6 +306,10 @@ and installation is complete. \
break
fi
+ if [ "$MAINSELECT" = "DONE" ]; then
+ MAINSELECT="EXIT"
+ fi
+
done # end of main loop
sync
@@ -448,7 +321,7 @@ if mount | grep /var/log/mntiso 1> /dev/null 2> /dev/null ; then
umount -f /var/log/mntiso
fi
if mount | grep /var/log/mount 1> /dev/null 2> /dev/null ; then
- umount /var/log/mount
+ umount -R /var/log/mount
fi
# Anything mounted on /var/log/mount now is a fatal error:
if mount | grep /var/log/mount 1> /dev/null 2> /dev/null ; then
@@ -476,35 +349,26 @@ if [ -f ${T_PX}/etc/fstab ]; then
eject -s `cat $TMP/SeTCDdev`
# Tell the user to remove the disc, if one had previously been mounted
# (it should now be ejected):
- dialog \
+ ${DIALOG} \
--clear \
--title "@CDISTRO@ Linux Setup is complete" "$@" \
--msgbox "\nPlease remove the installation disc.\n" 7 40
fi
- # Offer to reboot or drop to shell:
- dialog \
+ # Sign off to the user:
+ ${DIALOG} \
+ --clear \
--title "@CDISTRO@ Linux Setup is complete" "$@" \
- --yesno \
- "\nWould you like to reboot your system?\n\n\n\
-If you choose \"No\", you will be dropped to a shell.\n" 11 50
- retval=$?
- if [ $retval = 1 ]; then
- clear
- echo
- echo "You may now reboot your system once you are ready."
- echo "You can issue the 'reboot' command; or if your system has"
- echo "a keyboard attached, you can use the key combination: control+alt+delete"
- echo
- else
- touch /reboot
- fi
+ --msgbox "\nInstallation is complete.\n\n
+You can reboot your system whenever you like,\n
+but don't forget to remove this Live medium first.\n" 11 50
+
fi
# Fix the date:
fixdate
# final cleanup
-rm -f $TMP/tagfile $TMP/SeT* $TMP/tar-error $TMP/unsquash_output $TMP/unsquash_error $TMP/PKGTOOL_REMOVED
+rm -f $TMP/tagfile $TMP/temp* $TMP/tmp* $TMP/SeT* $TMP/tar-error $TMP/unsquash_output $TMP/unsquash_error $TMP/PKGTOOL_REMOVED $TMP/LILO* $TMP/avail*
rm -f /var/log/mount/treecache
rmdir /var/log/mntiso 2>/dev/null
rm -rf $TMP/treecache