From b199f7db48e8e76d2051102ec0af1c159d48fdb4 Mon Sep 17 00:00:00 2001 From: dateiexplorer Date: Mon, 28 Mar 2022 17:53:12 +0200 Subject: [PATCH 1/5] installer.sh.in: Add inital import and export function --- installer.sh.in | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/installer.sh.in b/installer.sh.in index 4cf2142220..95e7eb3931 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -40,6 +40,8 @@ BOOTLOADER_DONE= PARTITIONS_DONE= NETWORK_DONE= FILESYSTEMS_DONE= +IMPORT_DONE= +EXPORT_DONE= TARGETDIR=/mnt/target LOG=/dev/tty8 @@ -816,6 +818,7 @@ set_bootloader() { test_network() { rm -f xtraeme.asc && \ xbps-uhelper fetch http://alpha.de.repo.voidlinux.org/live/xtraeme.asc >$LOG 2>&1 + if [ $? -eq 0 ]; then DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE} NETWORK_DONE=1 @@ -1371,6 +1374,36 @@ menu_source() { set_option SOURCE $src } +menu_import() { + local _preset="" + + DIALOG --inputbox "Enter a path to the configuration file:" \ + ${INPUTSIZE} "$_preset" + if [ $? -eq 0 ]; then + cat "$(cat $ANSWER)" > "$CONF_FILE" + + IMPORT_DONE=1 + break + else + return + fi +} + +menu_export() { + local _preset="$HOME/void-installer.conf" + + DIALOG --inputbox "Enter a file where settings will be stored:" \ + ${INPUTSIZE} "$_preset" + if [ $? -eq 0 ]; then + cat "$CONF_FILE" > "$(cat $ANSWER)" + + EXPORT_DONE=1 + break + else + return + fi +} + menu() { local AFTER_HOSTNAME if [ -z "$DEFITEM" ]; then @@ -1383,6 +1416,7 @@ menu() { --extra-button --extra-label "Settings" \ --title " Void Linux installation menu " \ --menu "$MENULABEL" 10 70 0 \ + "Import" "Import settings from a configuration file" \ "Keyboard" "Set system keyboard" \ "Network" "Set up the network" \ "Source" "Set source installation" \ @@ -1393,6 +1427,7 @@ menu() { "BootLoader" "Set disk to install bootloader" \ "Partition" "Partition disk(s)" \ "Filesystems" "Configure filesystems and mount points" \ + "Export" "Export current settings to a file" \ "Install" "Start installation with saved settings" \ "Exit" "Exit installation" else @@ -1401,6 +1436,7 @@ menu() { --extra-button --extra-label "Settings" \ --title " Void Linux installation menu " \ --menu "$MENULABEL" 10 70 0 \ + "Import" "Import settings from a configuration file" \ "Keyboard" "Set system keyboard" \ "Network" "Set up the network" \ "Source" "Set source installation" \ @@ -1412,6 +1448,7 @@ menu() { "BootLoader" "Set disk to install bootloader" \ "Partition" "Partition disk(s)" \ "Filesystems" "Configure filesystems and mount points" \ + "Export" "Export current settings to a file" \ "Install" "Start installation with saved settings" \ "Exit" "Exit installation" fi @@ -1426,6 +1463,7 @@ menu() { fi case $(cat $ANSWER) in + "Import") menu_import && [ -n "$IMPORT_DONE" ] && DEFITEM="Install";; "Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";; "Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";; "Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Hostname";; @@ -1437,7 +1475,8 @@ menu() { && DEFITEM="BootLoader";; "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";; "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";; - "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";; + "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Export";; + "Export") menu_export && [ -n "$EXPORT_DONE" ] && DEFITEM="Install";; "Install") menu_install;; "Exit") DIE;; *) DIALOG --yesno "Abort Installation?" ${YESNOSIZE} && DIE From 9a9f861aedbaa735835c7138d8074ac3e2dbac01 Mon Sep 17 00:00:00 2001 From: dateiexplorer Date: Mon, 28 Mar 2022 18:09:56 +0200 Subject: [PATCH 2/5] installer.sh.in: Add POSTINSTALL to execute script for additional steps after installation For more automation in the install process the POSTINSTALL settings adds the ability to execute a script after the base installation process to configure the installation before reboot. This gives the ability to automate the installation process and install software, wm's or desktop environments flawlessly. The intention of this functionality is to give users the ability to configure the void installation for their needs at installation time. Could also be a good place to extend the installer functionality with custom scripts, e.g. to set up a working development VM with all needed packages and environment variables. --- installer.sh.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/installer.sh.in b/installer.sh.in index 95e7eb3931..6a4e3d98be 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -1340,6 +1340,13 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return # install bootloader. set_bootloader + + # execute postinstall script. + POSTINSTALL=$(get_option POSTINSTALL) + if [ -n "$POSTINSTALL" ]; then + source "$POSTINSTALL" + fi + sync && sync && sync # unmount all filesystems. From e2e5badaca9fc2d3acfd28fff402fc439985529f Mon Sep 17 00:00:00 2001 From: dateiexplorer Date: Tue, 29 Mar 2022 14:32:10 +0200 Subject: [PATCH 3/5] installer.sh.in: Improve import & export, add optional flag --- installer.sh.in | 50 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/installer.sh.in b/installer.sh.in index 6a4e3d98be..14940e464b 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -1387,27 +1387,47 @@ menu_import() { DIALOG --inputbox "Enter a path to the configuration file:" \ ${INPUTSIZE} "$_preset" if [ $? -eq 0 ]; then - cat "$(cat $ANSWER)" > "$CONF_FILE" + local file="$(cat $ANSWER)" + echo "Import settings from $file" >$LOG + cp "$file" "$CONF_FILE" >$LOG 2>&1 + if [ $? -ne 0 ]; then + DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ + failed to import settings! check $LOG for errors." ${MSGBOXSIZE} + return + fi + + DIALOG --msgbox "Settings successfully imported!" ${MSGBOXSIZE} IMPORT_DONE=1 - break - else - return fi } menu_export() { local _preset="$HOME/void-installer.conf" - DIALOG --inputbox "Enter a file where settings will be stored:" \ + DIALOG --inputbox "Enter a file path where settings will be stored:" \ ${INPUTSIZE} "$_preset" if [ $? -eq 0 ]; then - cat "$CONF_FILE" > "$(cat $ANSWER)" + local file="$(cat $ANSWER)" + if [ -f "$file" ]; then + DIALOG --yesno "${BOLD}${RED}WARNING: this file already exists.${RESET}\n\n +${BOLD}Do you really want to override this file?${RESET}" ${YESNOSIZE} + if [ $? -ne 0 ]; then + return + fi + fi + + echo "Export settings to $file" >$LOG + cp "$CONF_FILE" "$file" >$LOG 2>&1 + if [ $? -ne 0 ]; then + DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ + failed to export settings! check $LOG for errors." ${MSGBOXSIZE} + return + fi + + DIALOG --msgbox "Settings successfully exported!" ${MSGBOXSIZE} EXPORT_DONE=1 - break - else - return fi } @@ -1422,8 +1442,8 @@ menu() { DIALOG --default-item $DEFITEM \ --extra-button --extra-label "Settings" \ --title " Void Linux installation menu " \ - --menu "$MENULABEL" 10 70 0 \ - "Import" "Import settings from a configuration file" \ + --menu "$MENULABEL" 10 80 0 \ + "Import" "Import settings from a configuration file (Optional)" \ "Keyboard" "Set system keyboard" \ "Network" "Set up the network" \ "Source" "Set source installation" \ @@ -1434,7 +1454,7 @@ menu() { "BootLoader" "Set disk to install bootloader" \ "Partition" "Partition disk(s)" \ "Filesystems" "Configure filesystems and mount points" \ - "Export" "Export current settings to a file" \ + "Export" "Export current settings to a file (Optional)" \ "Install" "Start installation with saved settings" \ "Exit" "Exit installation" else @@ -1442,8 +1462,8 @@ menu() { DIALOG --default-item $DEFITEM \ --extra-button --extra-label "Settings" \ --title " Void Linux installation menu " \ - --menu "$MENULABEL" 10 70 0 \ - "Import" "Import settings from a configuration file" \ + --menu "$MENULABEL" 10 80 0 \ + "Import" "Import settings from a configuration file (Optional)" \ "Keyboard" "Set system keyboard" \ "Network" "Set up the network" \ "Source" "Set source installation" \ @@ -1455,7 +1475,7 @@ menu() { "BootLoader" "Set disk to install bootloader" \ "Partition" "Partition disk(s)" \ "Filesystems" "Configure filesystems and mount points" \ - "Export" "Export current settings to a file" \ + "Export" "Export current settings to a file (Optional)" \ "Install" "Start installation with saved settings" \ "Exit" "Exit installation" fi From a560d9d745ec9912a484c02b48f116b7c9aa28c2 Mon Sep 17 00:00:00 2001 From: dateiexplorer Date: Tue, 29 Mar 2022 15:38:33 +0200 Subject: [PATCH 4/5] installer.sh.in: Import & Export: Replace dialog inputbox with fselect --- installer.sh.in | 56 +++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/installer.sh.in b/installer.sh.in index 14940e464b..1db7c6e5fd 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -92,6 +92,7 @@ INPUTSIZE="8 60" MSGBOXSIZE="8 70" YESNOSIZE="$INPUTSIZE" WIDGET_SIZE="10 70" +FSELECT_SIZE="10 60" DIALOG() { rm -f $ANSWER @@ -1382,18 +1383,18 @@ menu_source() { } menu_import() { - local _preset="" + local _preset="$HOME/void-installer.conf" file= - DIALOG --inputbox "Enter a path to the configuration file:" \ - ${INPUTSIZE} "$_preset" + DIALOG --title "Select a path to the configuration file" \ + --fselect "$_preset" ${FSELECT_SIZE} if [ $? -eq 0 ]; then - local file="$(cat $ANSWER)" + file="$(cat $ANSWER)" echo "Import settings from $file" >$LOG cp "$file" "$CONF_FILE" >$LOG 2>&1 if [ $? -ne 0 ]; then DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ - failed to import settings! check $LOG for errors." ${MSGBOXSIZE} + failed to import settings! check $LOG for errors." ${MSGBOXSIZE} return fi @@ -1403,32 +1404,37 @@ menu_import() { } menu_export() { - local _preset="$HOME/void-installer.conf" + local _preset="$HOME/void-installer.conf" file= - DIALOG --inputbox "Enter a file path where settings will be stored:" \ - ${INPUTSIZE} "$_preset" - if [ $? -eq 0 ]; then - local file="$(cat $ANSWER)" - - if [ -f "$file" ]; then - DIALOG --yesno "${BOLD}${RED}WARNING: this file already exists.${RESET}\n\n + while true; do + DIALOG --title "Select a file where settings will be stored" \ + --fselect "$_preset" ${FSELECT_SIZE} + if [ $? -eq 0 ]; then + # Check if file already exists. + file="$(cat $ANSWER)" + if [ -f "$file" ]; then + DIALOG --yesno \ + "${BOLD}${RED}WARNING: this file already exists.${RESET}\n\n ${BOLD}Do you really want to override this file?${RESET}" ${YESNOSIZE} - if [ $? -ne 0 ]; then - return + if [ $? -ne 0 ]; then + continue + fi fi + break # override this file fi + return # abort export process + done - echo "Export settings to $file" >$LOG - cp "$CONF_FILE" "$file" >$LOG 2>&1 - if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ - failed to export settings! check $LOG for errors." ${MSGBOXSIZE} - return - fi - - DIALOG --msgbox "Settings successfully exported!" ${MSGBOXSIZE} - EXPORT_DONE=1 + echo "Export settings to $file" >$LOG + cp "$CONF_FILE" "$file" >$LOG 2>&1 + if [ $? -ne 0 ]; then + DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ + failed to export settings! check $LOG for errors." ${MSGBOXSIZE} + return fi + + DIALOG --msgbox "Settings successfully exported!" ${MSGBOXSIZE} + EXPORT_DONE=1 } menu() { From 6061859e2bccf184120dd6d1b97cbfed17d3c3c1 Mon Sep 17 00:00:00 2001 From: dateiexplorer Date: Wed, 30 Mar 2022 21:17:31 +0200 Subject: [PATCH 5/5] installer.sh.in: menu_import: Add disclaimer for right usage --- installer.sh.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/installer.sh.in b/installer.sh.in index 1db7c6e5fd..1e667b994a 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -1385,6 +1385,20 @@ menu_source() { menu_import() { local _preset="$HOME/void-installer.conf" file= + # Disclaimer for the import functionality. + DIALOG --title "Import settings from a configuration file" --msgbox "\n +${BOLD}${RED}This function is for advanced users. Don't use it if you don't +understand what you're doing. If this is your first installation of Void Linux it is +highly recommended to configure your installation manually.${RESET}\n\n +If you import a configuration file it is recommended to change the passwords +especially for the root user.\n\n +Make sure that your system has the same partitions (with the same size) as +described in the configuration file (as MOUNTPOINTs). Otherwise the +installation will fail. Maybe you need to configure partitions manually, +use the menu entry 'Partition' to do so.\n\n +Also check if the disk for the boot loader installation is correct if the +BOOTLOADER option is set in your configuration file.\n" 18 80 + DIALOG --title "Select a path to the configuration file" \ --fselect "$_preset" ${FSELECT_SIZE} if [ $? -eq 0 ]; then