From 3bb48a9c945dbafbbc912ef8d65234d88cb65794 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Sat, 24 Oct 2020 22:29:54 +0200 Subject: setup2hd fixes and enhancements DAW configuration is now properly copied Extracting the Live OS to hard disk is roughly 10 times faster now, after abandoning the fancy progress bar and just showing the rsync status. Use an enhanced Slackware SeTpasswd to add a non-root user and set the root password. Various syntax and logic errors removed. --- make_slackware_live.sh | 9 +++++---- setup2hd.tpl | 28 +++++++------------------- setup2hd/SeTpasswd | 30 ---------------------------- setup2hd/SeTpasswd.tpl | 48 +++++++++++++++++++++++++++++++++++++++++++++ setup2hd/SeTuacct.tpl | 20 +++++++++---------- setup2hd/SeTumedia.tpl | 6 +++--- setup2hd/SeTupass.tpl | 6 +++--- setup2hd/setup.liveslak.tpl | 41 +++++++++++++++++++------------------- 8 files changed, 96 insertions(+), 92 deletions(-) delete mode 100644 setup2hd/SeTpasswd create mode 100644 setup2hd/SeTpasswd.tpl diff --git a/make_slackware_live.sh b/make_slackware_live.sh index d3f104a..b25416f 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -1825,11 +1825,12 @@ if [ -f ${DEF_SL_PKGROOT}/../isolinux/initrd.img ]; then fi # Fix some occurrences of '/usr/lib/setup/' that are covered by $PATH: sed -i -e 's,/usr/lib/setup/,,g' -e 's,:/usr/lib/setup,:/usr/share/${LIVEMAIN},g' ${LIVE_ROOTDIR}/usr/share/${LIVEMAIN}/* - # Overwrite Slackware's SeTpasswd script with our enhanceded version: - cat ${LIVE_TOOLDIR}/setup2hd/SeTpasswd \ - > ${LIVE_ROOTDIR}/usr/share/${LIVEMAIN}/SeTpasswd + # Prevent SeTconfig from asking redundant questions after a Live OS install: + sed -i ${LIVE_ROOTDIR}/usr/share/${LIVEMAIN}/SeTconfig \ + -e '/.\/var\/log\/setup\/$SCRIPT $T_PX $ROOT_DEVICE/i # Skip stuff that was taken care of by liveslak\nif [ -f $TMP/SeTlive ] && echo $SCRIPT |grep -qE "(make-bootdisk|mouse|setconsolefont|xwmconfig)"; then true; else' \ + -e '/.\/var\/log\/setup\/$SCRIPT $T_PX $ROOT_DEVICE/a fi' # Add the Slackware Live HD installer scripts: - for USCRIPT in SeTuacct SeTudiskpart SeTumedia SeTupass setup.liveslak setup.slackware ; do + for USCRIPT in SeTuacct SeTudiskpart SeTumedia SeTupass SeTpasswd setup.liveslak setup.slackware ; do cat ${LIVE_TOOLDIR}/setup2hd/${USCRIPT}.tpl | sed \ -e "s/@DIRSUFFIX@/$DIRSUFFIX/g" \ -e "s/@DISTRO@/$DISTRO/g" \ diff --git a/setup2hd.tpl b/setup2hd.tpl index 92bbdbc..d600996 100755 --- a/setup2hd.tpl +++ b/setup2hd.tpl @@ -164,11 +164,10 @@ while [ 0 ]; do --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" \ "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,10 +180,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 @@ -339,23 +334,14 @@ if [ -f ${T_PX}/etc/fstab ]; then --title "@CDISTRO@ Linux Setup is complete" "$@" \ --msgbox "\nPlease remove the installation disc.\n" 7 40 fi - # Offer to reboot or drop to shell: + # 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: diff --git a/setup2hd/SeTpasswd b/setup2hd/SeTpasswd deleted file mode 100644 index 4208306..0000000 --- a/setup2hd/SeTpasswd +++ /dev/null @@ -1,30 +0,0 @@ -# Liveslak replacement for Slackware's SeTpassword script. - -# 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\ -After that, you will be asked to set the root 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, UACCTNR 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,dialout,games,disk,input -u ${UACCTNR} -d /home/${UACCOUNT} -m -s ${USHELL} ${UACCOUNT} - echo "${UACCOUNT}:${UPASS}" | chroot ${T_PX} /usr/sbin/chpasswd - unset UPASS -fi # End user creation - -# Check for root password: -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 diff --git a/setup2hd/SeTpasswd.tpl b/setup2hd/SeTpasswd.tpl new file mode 100644 index 0000000..04d7c8c --- /dev/null +++ b/setup2hd/SeTpasswd.tpl @@ -0,0 +1,48 @@ +#!/bin/sh +# Liveslak replacement for Slackware's SeTpassword script. + +TMP=/var/log/setup/tmp +if [ ! -d $TMP ]; then + mkdir -p $TMP +fi +T_PX="$(cat $TMP/SeTT_PX)" + +# Check for root password: +if [ "$(cat $T_PX/etc/shadow | grep 'root:' | cut -f 2 -d :)" != "" ]; then + # Root password has been set, nothing further to be done. + exit 0 +fi + +# No root password has been set yet, which means no user was created either. + +# Set up a user account, +if [ -r $TMP/SeTlive ]; then + # We will only configgure su access when installing a Live OS: + SUTEXT="\nYour account will be added to sudoers and suauth." +else + SUTEXT="" +fi +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.${SUTEXT}\n\n\ +After that, you will be asked to set the root password." 11 55 +# This will set UFULLNAME, UACCOUNT and USHELL variables: +SeTuacct 2>&1 1> $TMP/temppasswd +if [ $? = 0 ]; then + # User filled out the form, so let's get the results for + # UFULLNAME, UACCOUNT, UACCTNR and USHELL: + source $TMP/temppasswd + rm -f $TMP/temppasswd + # 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,dialout,games,disk,input -u ${UACCTNR} -d /home/${UACCOUNT} -m -s ${USHELL} ${UACCOUNT} + echo "${UACCOUNT}:${UPASS}" | chroot ${T_PX} /usr/sbin/chpasswd + unset UPASS +fi # End user creation + +# Finally, set the root password: +UPASS=$(SeTupass root) +echo "root:${UPASS}" | chroot ${T_PX} /usr/sbin/chpasswd +unset UPASS diff --git a/setup2hd/SeTuacct.tpl b/setup2hd/SeTuacct.tpl index 5024f5d..e07564f 100644 --- a/setup2hd/SeTuacct.tpl +++ b/setup2hd/SeTuacct.tpl @@ -1,21 +1,21 @@ #!/bin/sh -#TMP=/var/log/setup/tmp -TMP=/tmp +TMP=/var/log/setup/tmp if [ ! -d $TMP ]; then mkdir -p $TMP fi +T_PX="$(cat $TMP/SeTT_PX)" freeuid() { # Get the first free UIDNumber after 999: - local UIDS=$( cat ${T_PX}/etc/passwd | cut -d: -f3 | sort -n ) - local UID=999 + local LUIDS=$( cat ${T_PX}/etc/passwd | cut -d: -f3 | sort -n ) + local LUID=999 while true; do - UID=$(( $UID + 1)) - if ! echo $UIDS | grep -F -q -w "$UID"; then + LUID=$(( $LUID + 1)) + if ! echo $LUIDS | grep -F -q -w "$LUID"; then break; fi done - echo $UID + echo $LUID } FREEUID="$(freeuid)" @@ -33,14 +33,14 @@ while [ 0 ]; do "Logonname:" 2 1 "$UACCOUNT" 2 14 32 0 \ "UIDNumber:" 3 1 "$UACCTNR" 3 14 12 0 \ "Login Shell:" 4 1 "$USHELL" 4 14 12 0 \ - 2>&1 1> $TMP/tempresult + 2>&1 1> $TMP/tempuacct iii=0 declare -a USERATTR while read LINE ; do USERATTR[$iii]="$LINE" iii=$(expr $iii + 1) - done < $TMP/tempresult - rm -f $TMP/tempresult + done < $TMP/tempuacct + rm -f $TMP/tempuacct UFULLNAME="${USERATTR[0]}" UACCOUNT="${USERATTR[1]}" UACCTNR="${USERATTR[2]}" diff --git a/setup2hd/SeTumedia.tpl b/setup2hd/SeTumedia.tpl index 9a68eaf..f14e37c 100644 --- a/setup2hd/SeTumedia.tpl +++ b/setup2hd/SeTumedia.tpl @@ -8,9 +8,9 @@ dialog --backtitle "Select Slackware installation source." \ --title "SOURCE MEDIA SELECTION" --menu \ "Please select the media from which to install Slackware Linux:" \ 14 70 7 \ -"1" "Install from NFS (Network File System)" \ -"2" "Install from FTP/HTTP server" \ -"3" "Install from Samba share" \ +"1" "Install Slackware from NFS (Network File System)" \ +"2" "Install Slackware from FTP/HTTP server" \ +"3" "Install Slackware from Samba share" \ "4" "Install @UDISTRO@ (@LIVEDE@) Live OS to disk" \ 2> $TMP/media if [ ! $? = 0 ]; then diff --git a/setup2hd/SeTupass.tpl b/setup2hd/SeTupass.tpl index ff662ab..8cbadea 100644 --- a/setup2hd/SeTupass.tpl +++ b/setup2hd/SeTupass.tpl @@ -16,14 +16,14 @@ UACCOUNT="$1" 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 + 2>&1 1> $TMP/tempupass iii=0 declare -a USERATTR while read LINE ; do USERATTR[$iii]="$LINE" iii=$(expr $iii + 1) - done < $TMP/tempresult - rm -f $TMP/tempresult + done < $TMP/tempupass + rm -f $TMP/tempupass UPASS1="${USERATTR[0]}" UPASS2="${USERATTR[1]}" unset USERATTR diff --git a/setup2hd/setup.liveslak.tpl b/setup2hd/setup.liveslak.tpl index 5b6e65a..ce99461 100644 --- a/setup2hd/setup.liveslak.tpl +++ b/setup2hd/setup.liveslak.tpl @@ -48,13 +48,12 @@ Press ENTER to return to the main menu." 16 68 ( # 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/' + rsync -HAXa --whole-file --checksum-choice=none --inplace \ + --info=progress2 --no-inc-recursive \ + /mnt/liveslakfs/ $T_PX/ ; echo DONE \ ) | 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 + --title "INSTALLING @UDISTRO@ LIVE (@LIVEDE@) TO DISK" --programbox \ + "\nProcessing ${TOT_MODS} @CDISTRO@ Live modules ($(( $DU_LIVE/1024 )) MB)" 8 80 # # Live OS Post Install routine. If you want, you can override this routine @@ -69,14 +68,14 @@ Press ENTER to return to the main menu." 16 68 --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\ -After that, you will be asked to set the root password." 9 55 +After that, you will be asked to set the root password." 11 55 # This will set UFULLNAME, UACCOUNT, UACCTNR and USHELL variables: - SeTuacct 2>&1 1> $TMP/tempresult + SeTuacct 2>&1 1> $TMP/uacctresult if [ $? = 0 ]; then # User filled out the form, so let's get the results for # UFULLNAME, UACCOUNT, UACCTNR and USHELL: - source $TMP/tempresult - rm -f $TMP/tempresult + source $TMP/uacctresult + rm -f $TMP/uacctresult # Set a password for the new account: UPASS=$(SeTupass $UACCOUNT) # Create the account and set the password: @@ -116,11 +115,11 @@ EOT 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 \ + unsquashfs -n -f -dest $T_PX \ /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \ /etc/rc.d/rc.keymap fi - unsquashfs -f -dest $T_PX \ + unsquashfs -n -f -dest $T_PX \ /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \ /etc/X11/xinit/xinitrc \ /etc/X11/xdm/liveslak-xdm \ @@ -134,13 +133,13 @@ EOT /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,' - # Prevent Slackware's SeTconfig from asking redundant questions later on: - sed -i ${T_PX}/usr/lib/setup/SeTconfig \ + # Prevent SeTconfig from asking redundant questions later on: + sed -i ${T_PX}/usr/share/@LIVEMAIN@/SeTconfig \ -e '/.\/var\/log\/setup\/$SCRIPT $T_PX $ROOT_DEVICE/i # Skip stuff that was taken care of by liveslak\nif echo $SCRIPT |grep -E "(make-bootdisk|mouse|setconsolefont|xwmconfig)"; then continue; fi' # If a user account was created, we restore some of the user customization: if [ -n "${UACCOUNT}" ] && [ -d "${T_PX}/home/${UACCOUNT}" ]; then - unsquashfs -f -dest $T_PX \ + unsquashfs -n -f -dest $T_PX \ /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \ /home/@LIVEUID@/.face \ /home/@LIVEUID@/.face.icon @@ -153,7 +152,7 @@ EOT # If the Live OS is real-time capable we need to apply that to the install: if [ "@LIVEDE@" = "PLASMA5" -o "@LIVEDE@" = "DAW" -o "@LIVEDE@" = "STUDIOWARE" ]; then - unsquashfs -f -dest $T_PX \ + unsquashfs -n -f -dest $T_PX \ /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \ /etc/security/limits.d/rt_audio.conf \ /etc/initscript \ @@ -165,7 +164,7 @@ then if [ "@LIVEDE@" = "DAW" ]; then LCLIVEDE=$(echo @LIVEDE@ |tr 'A-Z' 'a-z') - unsquashfs -f -dest $T_PX \ + unsquashfs -n -f -dest $T_PX \ /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \ /etc/pulse/daemon.conf \ /etc/xdg/menus/applications-merged/liveslak-daw.menu \ @@ -179,12 +178,12 @@ then # If a user account was created, we restore DAW user customization: if [ -n "${UACCOUNT}" ] && [ -d "${T_PX}/home/${UACCOUNT}" ]; then - unsquashfs -f -dest $T_PX \ + unsquashfs -n -f -dest $T_PX \ /mnt/livemedia/@LIVEMAIN@/system/0099*zzzconf*.sxz \ /home/@LIVEUID@/.jackdrc \ - /home/${LIVEUID}/.config/autostart/qjackctl.desktop \ - /home/${LIVEUID}/.config/rncbc.org/QjackCtl.conf \ - /home/${LIVEUID}/.config/kscreenlockerrc + /home/@LIVEUID@/.config/autostart/qjackctl.desktop \ + /home/@LIVEUID@/.config/rncbc.org/QjackCtl.conf \ + /home/@LIVEUID@/.config/kscreenlockerrc if [ "@LIVEUID@" != ${UACCOUNT} ]; then rsync -a $T_PX/home/@LIVEUID@/ $T_PX/home/${UACCOUNT}/ rm -rf $T_PX/home/@LIVEUID@ -- cgit v1.2.3