diff options
Diffstat (limited to '')
-rwxr-xr-x | SeTuacct.tpl | 67 | ||||
-rw-r--r-- | SeTudiskpart.tpl | 61 | ||||
-rwxr-xr-x | SeTupass.tpl | 42 | ||||
-rwxr-xr-x | setup2hd.tpl | 176 |
4 files changed, 311 insertions, 35 deletions
diff --git a/SeTuacct.tpl b/SeTuacct.tpl new file mode 100755 index 0000000..017afaa --- /dev/null +++ b/SeTuacct.tpl @@ -0,0 +1,67 @@ +#!/bin/sh +#TMP=/var/log/setup/tmp +TMP=/tmp +if [ ! -d $TMP ]; then + mkdir -p $TMP +fi + + UFULLNAME="" + UACCOUNT="" + USHELL="/bin/bash" + UFORM="Fill out your user details:" + while [ 0 ]; do + dialog --stdout --ok-label "Submit" --no-cancel \ + --title "@UDISTRO@ (@LIVEDE@) USER CREATION" \ + --form "$UFORM" \ + 10 64 0 \ + "Full Name:" 1 1 "$UFULLNAME" 1 14 40 0 \ + "Logonname:" 2 1 "$UACCOUNT" 2 14 32 0 \ + "Login Shell:" 3 1 "$USHELL" 3 14 12 0 \ + 2>&1 1> $TMP/tempresult + iii=0 + declare -a USERATTR + while read LINE ; do + USERATTR[$iii]="$LINE" + iii=$(expr $iii + 1) + done < $TMP/tempresult + rm -f $TMP/tempresult + UFULLNAME="${USERATTR[0]}" + UACCOUNT="${USERATTR[1]}" + USHELL="${USERATTR[2]}" + unset USERATTR + UINPUT=0 + # Validate the input: + UACC_INVALID1="$(echo ${UACCOUNT:0:1} |tr -d 'a-z_')" + UACC_INVALID="$(echo ${UACCOUNT:1} |tr -d 'a-z0-9_-')" + if [ -n "$UACC_INVALID1" -o -n "$UACC_INVALID" ]; then + # User account contains invalid characters, let's remove them all: + UINPUT=1 + UACCOUNT="$(echo ${UACCOUNT} |tr -cd 'a-z_')" + fi + if [ -z "$UACCOUNT" -o -z "$UFULLNAME" ]; then + # User account or fullname is empty, let's try again: + UINPUT=$(expr $UINPUT + 2) + fi + if ! grep -q ${USHELL} ${T_PX}/etc/shells ; then + # Login shell is invalid, suggest the bash shell again: + UINPUT=$(expr $UINPUT + 4) + USHELL=/bin/bash + fi + if [ $UINPUT -eq 0 ]; then + break + elif [ $UINPUT -eq 1 ]; then + UFORM="Please only use valid characters for logonname" + elif [ $UINPUT -eq 2 ]; then + UFORM="Please enter your logon and full name" + elif [ $UINPUT -eq 3 ]; then + UFORM="Use valid characters for logonname, and enter full name" + elif [ $UINPUT -eq 4 ]; then + UFORM="Please enter a valid shell" + else + UFORM="Fill all fields, and only use valid characters for logonname" + fi + done + + echo "UACCOUNT=$UACCOUNT" + echo "UFULLNAME='$UFULLNAME'" + echo "USHELL=$USHELL" diff --git a/SeTudiskpart.tpl b/SeTudiskpart.tpl new file mode 100644 index 0000000..5a244a8 --- /dev/null +++ b/SeTudiskpart.tpl @@ -0,0 +1,61 @@ +#!/bin/sh +TMP=/var/log/setup/tmp +if [ ! -d $TMP ]; then + mkdir -p $TMP +fi + + # If we do not find any useful disks at all, we must bail: + if [ -z "$(lsblk -a -o NAME,SIZE,RM,RO,TYPE,MODEL |tr -s '[:blank:]' ' ' |grep '0 *0 *disk' | grep -v '^ram')" ]; then + dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \ + --title "NO HARD DRIVE DETECTED" \ + --msgbox "This machine appears not to have any hard drives installed.\ +This setup will not work. Please add a hard drive to the computer first." 10 64 + exit + fi + + # Generate a list of local hard drives we can write to: + rm -f $TMP/tempscript + cat <<EOT > $TMP/tempscript +dialog --stdout \\ + --title "SELECT DISK DRIVES" \\ + --backtitle "Creating Linux, swap and EFI partitions" \\ + --checklist "Select from available drives.\nA disk partitioning utility \\ +will be presented for any drive you select here:" \\ + 19 0 9 \\ +EOT + lsblk -a -o NAME,SIZE,RM,RO,TYPE,MODEL | \ + tr -s '[:blank:]' ' ' | grep '0 *0 *disk' | grep -v '^ram' | \ + while read LINE ; do + DISKATTR=($LINE) + DISKVENDOR="${DISKATTR[@]:5}" + if [ -z "${DISKVENDOR}" ]; then + DISKVENDOR="UnknownVendor" + fi + echo "\"/dev/${DISKATTR[0]}\" \"${DISKATTR[1]}: ${DISKVENDOR}\" off \\" >> $TMP/tempscript + done + echo '2>&1 1>$TMP/availdisks' >> $TMP/tempscript + + # Loop until the user makes a choice: + while [ 0 ]; do + source $TMP/tempscript + if [ ! $? = 0 ] || [ ! -s $TMP/availdisks ]; then + # Canceled the dialog, or did not select anything: + rm -f $TMP/availdisks + else + # We got an answer: + for DISKDRIVE in $(cat $TMP/availdisks) ; do + # Determine which disk partitioning tool to use: + if gdisk -l $DISKDRIVE |tr -s '[:blank:]' ' ' |grep -q "MBR: MBR only" ; then + PARTTOOL=cfdisk + else + PARTTOOL=cgdisk + fi + # Now let the user create her partitions: + $PARTTOOL $DISKDRIVE + done + break + fi + done + # We should have partitions now, so re-run probe and collect that list: + probe -l 2> /dev/null | grep -E 'Linux$' | sort 1> $TMP/SeTplist 2> /dev/null + diff --git a/SeTupass.tpl b/SeTupass.tpl new file mode 100755 index 0000000..ff662ab --- /dev/null +++ b/SeTupass.tpl @@ -0,0 +1,42 @@ +#!/bin/sh +TMP=/var/log/setup/tmp +if [ ! -d $TMP ]; then + mkdir -p $TMP +fi + +UACCOUNT="$1" + + UPASS1="" + UPASS2="" + UFORM="Define a new password for user '$UACCOUNT'" + while [ 0 ]; do + dialog --stdout --insecure --ok-label "Submit" --no-cancel \ + --title "@UDISTRO@ (@LIVEDE@) USER CREATION" \ + --passwordform "$UFORM" \ + 9 64 0 \ + "Password:" 1 1 "$UPASS1" 1 18 40 0 \ + "Repeat password:" 2 1 "$UPASS2" 2 18 40 0 \ + 2>&1 1> $TMP/tempresult + iii=0 + declare -a USERATTR + while read LINE ; do + USERATTR[$iii]="$LINE" + iii=$(expr $iii + 1) + done < $TMP/tempresult + rm -f $TMP/tempresult + UPASS1="${USERATTR[0]}" + UPASS2="${USERATTR[1]}" + unset USERATTR + if [ -z "$UPASS1" ]; then + UFORM="Password must not be empty, try again for user '$UACCOUNT'" + elif [ "$UPASS1" == "$UPASS2" ]; then + break + else + UFORM="Passwords do not match, try again for user '$UACCOUNT'" + fi + done + echo "${UPASS1}" + unset UPASS1 + unset UPASS2 + unset USERATTR + diff --git a/setup2hd.tpl b/setup2hd.tpl index eb076a3..4bc48bb 100755 --- a/setup2hd.tpl +++ b/setup2hd.tpl @@ -24,9 +24,13 @@ # # As always, bug reports, suggestions, etc: volkerdi@slackware.com # -# Modifications 2016, 2017 by Eric Hameleers <alien@slackware.com> +# Modifications 2016, 2017, 2019, 2020 by Eric Hameleers <alien@slackware.com> # +# -------------------------------------------- # +# Slackware Live Edition - check the media # +# -------------------------------------------- # + # The Slackware setup depends on english language settings because it # parses program output like that of "fdisk -l". So, we need to override # the Live user's local language settings here: @@ -34,17 +38,25 @@ export LANG=C export LC_ALL=C if [ ! -d /mnt/livemedia/@LIVEMAIN@/system ]; then - dialog --title "LIVE MEDIA NOT ACCESSIBLE" --msgbox "\ + dialog --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \ + --title "LIVE MEDIA NOT ACCESSIBLE" --msgbox "\ \n\ Before you can install software, complete the following tasks:\n\ \n\ 1. Mount your Live media partition on /mnt/livemedia." 16 68 exit 1 fi + +# ------------------------------------------------ # +# Slackware Live Edition - end check the media # +# ------------------------------------------------ # + TMP=/var/log/setup/tmp if [ ! -d $TMP ]; then mkdir -p $TMP fi +# Wipe the probe md5sum to force rescanning partitions if setup is restarted: +rm -f $TMP/SeTpartition.md5 rm -f $TMP/SeT* # If a keymap was set up, restore that data: if [ -r $TMP/Pkeymap ]; then @@ -54,43 +66,80 @@ echo "on" > $TMP/SeTcolor # turn on color menus PATH="$PATH:/usr/share/@LIVEMAIN@" export PATH; export COLOR=on -#echo -#echo -#echo "Probing disk partitions. (Hint: if your ATAPI CD-ROM causes timeouts" -#echo "during the probe process, try hitting the eject button)" -#echo -#sleep 5 -# +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: +sleep 1 # Before probing, activate any LVM partitions # that may exist from before the boot: 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)" \ + --title "LINUX PARTITIONS DETECTED" \ + --yes-label "Continue" --no-label "Skip" --defaultno \ + --yesno "Setup detected partitions on this machine of type Linux.\n\ +You probably created these before running '$(basename $0)'. Great!\n\n\ +If you would like to re-consider your partitioning scheme, \ +you can click 'Continue' now to start 'cfdisk' (MBR disk) \ +and/or 'cgdisk' (GPT disk) for all your hard drives.\n\ +Otherwise, select 'Skip' to skip disk partitioning and go on with the setup." \ +12 64 + if [ $? -eq 0 ]; then + RUNPART=yes + fi else - dialog --title "NO LINUX PARTITIONS DETECTED" \ - --msgbox "There don't seem to be any partitions on this machine of type \ + RUNPART=yes + 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. \ -To do this, you'll need to leave 'setup', and make the partitions using \ -'cfdisk' (MBR partitions) or 'cgdisk' (GPT partitions). For more \ -information, read the 'setup' help file from the next menu." 10 64 +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 if ! probe -l 2> /dev/null | grep "EFI System Partition" 1> /dev/null 2> /dev/null ; then - dialog --title "NO EFI SYSTEM PARTITION DETECTED" \ - --msgbox "This machine appears to be using EFI/UEFI, but no EFI System \ + RUNPART=yes + 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 \ -to boot from the hard drive. To do this, leave 'setup', and \ -use 'cgdisk' to make a 100MB partition of type EF00. For more information, \ -read the 'setup' help file from the next menu." 10 64 +to boot from the hard drive. In the next step, using cfdisk/cgdisk, \ +make a 100MB partition of type EF00." 10 64 fi fi +if [ "$RUNPART" = "yes" ]; then + + # ------------------------------------------------------- # + # Slackware Live Edition - find/partition the disk(s) # + # ------------------------------------------------------- # + + SeTudiskpart + if [ ! $? = 0 ]; then + # No disks found or user canceled, means: abort. + exit 1 + fi + + # ----------------------------------------------------------- # + # Slackware Live Edition - end find/partition the disk(s) # + # ----------------------------------------------------------- # + +fi # End RUNPART = yes + T_PX="/setup2hd" mkdir -p ${T_PX} echo "$T_PX" > $TMP/SeTT_PX 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 - umount /var/log/mount # location +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 + # Unmount target partition: + umount /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 @@ -111,8 +160,8 @@ mkdir /var/log/mount 2> /dev/null while [ 0 ]; do dialog --title "@CDISTRO@ Linux Setup (version @SL_VERSION@)" \ ---menu \ -"Welcome to @CDISTRO@ Linux Setup (Live Edition).\n\ + --backtitle "@CDISTRO@ Linux Setup (Live Edition)" \ + --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" \ @@ -168,7 +217,8 @@ Alternate keys may also be used: '+', '-', and TAB." 18 72 9 \ if [ "$MAINSELECT" = "INSTALL" ]; then if [ ! -r $TMP/SeTnative ]; then - dialog --title "CANNOT INSTALL SOFTWARE YET" --msgbox "\ + 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\ @@ -186,35 +236,40 @@ Press ENTER to return to the main menu." 16 68 # --------------------------------------------- # # Buy us some time while we are calculating disk usage: - dialog --title "WELCOME TO @UDISTRO@ LIVE (@LIVEDE@)" --infobox \ + 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/@LIVEMAIN@fs/ |tr -s '\t' ' ' |cut -f1 -d' ') + 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 --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 + 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 else - dialog --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 + 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 fi ( # Install the Live OS by rsyncing the readonly overlay to the harddisk: - rsync -Hav --progress --no-inc-recursive /mnt/@LIVEMAIN@fs/ $T_PX/ \ + 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 --title "INSTALLING @UDISTRO@ LIVE (@LIVEDE@) TO DISK" --gauge \ + ) | 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 # @@ -226,8 +281,10 @@ Press ENTER to return to the main menu." 16 68 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 --title "POST-INSTALL @UDISTRO@ LIVE (@LIVEDE@) DATA" --infobox \ + 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 \ @@ -239,6 +296,7 @@ Press ENTER to return to the main menu." 16 68 /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 \ @@ -249,6 +307,48 @@ Press ENTER to return to the main menu." 16 68 # 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! @@ -262,12 +362,14 @@ Press ENTER to return to the main menu." 16 68 # unsquashfs -f -dest $T_PX /mnt/livemedia/@LIVEMAIN@/addons/mymodule.sxz EOF - dialog --title "POST INSTALL HINTS AND TIPS" --msgbox "`cat $TMP/tempmsg`" \ + 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. @@ -293,6 +395,10 @@ EOF if [ -f /usr/sbin/eliloconfig -a -f $T_PX/usr/sbin/eliloconfig ]; then 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 SeTconfig REPLACE_FSTAB=Y if [ -r $TMP/SeTnative ]; then |