From a933bb2031b5bea5d1542452cc064e0934d575d5 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Tue, 29 Jun 2021 13:39:58 +0900 Subject: [PATCH] Renamed scripts --- ubuntu/1-config.sh | 123 ++++++++++++++++++ ubuntu/{1-pre-install.sh => 2-pre-install.sh} | 47 ------- .../{2-para-install.sh => 3-para-install.sh} | 0 .../{3-post-install.sh => 4-post-install.sh} | 0 ubuntu/config.sh | 44 ------- 5 files changed, 123 insertions(+), 91 deletions(-) create mode 100644 ubuntu/1-config.sh rename ubuntu/{1-pre-install.sh => 2-pre-install.sh} (77%) rename ubuntu/{2-para-install.sh => 3-para-install.sh} (100%) rename ubuntu/{3-post-install.sh => 4-post-install.sh} (100%) delete mode 100644 ubuntu/config.sh diff --git a/ubuntu/1-config.sh b/ubuntu/1-config.sh new file mode 100644 index 0000000..e79a2c5 --- /dev/null +++ b/ubuntu/1-config.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# Storage device to install the linux. +export DEV="/dev/sda" + +# Whether you want to erase all contents of the storage device or not. +# 1 : Yes, I want to erase all. +# 2 : No, I want to add to the existing Linux distributions. +export ERASEALL=1 + +# Logical Volume name for your Linux installation. Keep it unique from other distribution. +export LVROOTNAME="ubuntu" + +# Logical volume size of the Linux installation. +# 50% mean, new logical volume will use 50% of the free space in the LVM volume group. +export LVROOTSIZE="50%FREE" + +# Set the size of EFI partition and swap partition. The unit is Byte. you can use M,G... notation. +export EFISIZE="100M" +export LVSWAPSIZE="8G" + +# Usually, these names can be left untouched. +# If you change, keep them consistent through all distributions in your system. +export CRYPTPARTNAME="luks_volume" +export VGNAME="vg1" +export LVSWAPNAME="swap" + +# DO NOT touch following lines. + + +# Detect firmware type. 1 : EFI, 0 : BIOS +if [ -d /sys/firmware/efi ]; then +export ISEFI=1 # Yes, EFI +else +export ISEFI=0 # No, BIOS +fi # is EFI firmaare? + +# Set partition number based on the firmware type +if [ ${ISEFI} -eq 1 ] ; then +# EFI firmware +export EFIPARTITION=1 +export CRYPTPARTITION=2 +else +# BIOS firmware +export CRYPTPARTITION=1 +fi # EFI firmware + + +# Varidate whether script is executed as sourced or not +(return 0 2>/dev/null) && sourced=1 || sourced=0 +if [ $sourced -eq 0 ] ; then + cat <&2 +***** ERROR : Must execute as source ***** +Execute as following : +source 1-pre-install.sh + +Installation terminated. +HEREDOC + exit # use "exit" instead of "return", if not "sourced" execusion +fi # "sourced" validation + + + +# ----- Confirmations ----- +# Distribution check +uname -a | grep ubuntu -i > /dev/null +if [ $? -eq 1 ] ; then # "Ubuntu" is not found in the OS name. + uname -a + echo "This system seems to be netiher Ubuntu nor Ubuntu variants, while this script is dediated to the Ubuntu or its variants" + echo "Are you sure you want to run this script for installation? [Y/N]" + read YESNO + if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + cat <&2 + +Installation terminated. +HEREDOC + return + fi # if YES + +fi # "Ubuntu" is not found in the OS name. + +# For surre ask the config.sh is edited +echo "Did you edit config.sys? Are you ready to install? [Y/N]" +read YESNO +if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + cat <&2 + +Installation terminated. +HEREDOC + return +fi # if YES + +# For sure ask ready to erase. +if [ ${ERASEALL} -eq 1 ] ; then + echo "Are you sure you want to erase entire ${DEV}? [Y/N]" + read YESNO + if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then + cat <&2 +Check config.sh. The variable ERASEALL is ${ERASEALL}. + +Installation terminated. +HEREDOC + return + fi # if YES +fi # if erase all + +# ----- Set Passphrase ----- +# Input passphrase +echo "Type passphrase for the disk encryption." +read -sr PASSPHRASE +export PASSPHRASE + +echo "Type passphrase again, to confirm." +read -sr PASSPHRASE_C + +# Validate whether both are indentical or not +if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then + cat <&2 +***** ERROR : Passphrase doesn't match ***** +Installation terminated. +HEREDOC + return +fi # passphrase validation diff --git a/ubuntu/1-pre-install.sh b/ubuntu/2-pre-install.sh similarity index 77% rename from ubuntu/1-pre-install.sh rename to ubuntu/2-pre-install.sh index eeb7cf4..adbb367 100644 --- a/ubuntu/1-pre-install.sh +++ b/ubuntu/2-pre-install.sh @@ -13,53 +13,6 @@ HEREDOC exit # use "exit" instead of "return", if not "sourced" execusion fi # "sourced" validation -# ----- Configuration Parameter ----- -# Load the configuration parameter -source config.sh - -# For surre ask the config.sh is edited -echo "Did you edit config.sys? Are you ready to install? [Y/N]" -read YESNO -if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then - cat <&2 - -Installation terminated. -HEREDOC - return -fi # if YES - - -# For sure ask ready to erase. -if [ ${ERASEALL} -eq 1 ] ; then - echo "Are you sure you want to erase entire ${DEV}? [Y/N]" - read YESNO - if [ ${YESNO} != "Y" -a ${YESNO} != "y" ] ; then - cat <&2 -Check config.sh. The variable ERASEALL is ${ERASEALL}. - -Installation terminated. -HEREDOC - return - fi # if YES -fi # if erase all - -# ----- Set Passphrase ----- -# Input passphrase -echo "Type passphrase for the disk encryption." -read -sr PASSPHRASE -export PASSPHRASE - -echo "Type passphrase again, to confirm." -read -sr PASSPHRASE_C - -# Validate whether both are indentical or not -if [ ${PASSPHRASE} != ${PASSPHRASE_C} ] ; then - cat <&2 -***** ERROR : Passphrase doesn't match ***** -Installation terminated. -HEREDOC - return -fi # passphrase validation # ----- Erase entire disk, create partitions, format them and encrypt the LUKS partition ----- if [ ${ERASEALL} -eq 1 ] ; then diff --git a/ubuntu/2-para-install.sh b/ubuntu/3-para-install.sh similarity index 100% rename from ubuntu/2-para-install.sh rename to ubuntu/3-para-install.sh diff --git a/ubuntu/3-post-install.sh b/ubuntu/4-post-install.sh similarity index 100% rename from ubuntu/3-post-install.sh rename to ubuntu/4-post-install.sh diff --git a/ubuntu/config.sh b/ubuntu/config.sh deleted file mode 100644 index 9c33cc5..0000000 --- a/ubuntu/config.sh +++ /dev/null @@ -1,44 +0,0 @@ -# Storage device to install the linux. -export DEV="/dev/sda" - -# Whether you want to erase all contents of the storage device or not. -# 1 : Yes, I want to erase all. -# 2 : No, I want to add to the existing Linux distributions. -export ERASEALL=1 - -# Logical Volume name for your Linux installation. Keep it unique from other distribution. -export LVROOTNAME="ubuntu" - -# Logical volume size of the Linux installation. -# 50% mean, new logical volume will use 50% of the free space in the LVM volume group. -export LVROOTSIZE="50%FREE" - -# Set the size of EFI partition and swap partition. The unit is Byte. you can use M,G... notation. -export EFISIZE="100M" -export LVSWAPSIZE="8G" - -# Usually, these names can be left untouched. -# If you change, keep them consistent through all distributions in your system. -export CRYPTPARTNAME="luks_volume" -export VGNAME="vg1" -export LVSWAPNAME="swap" - -# DO NOT touch following lines. - - -# Detect firmware type. 1 : EFI, 0 : BIOS -if [ -d /sys/firmware/efi ]; then -export ISEFI=1 # Yes, EFI -else -export ISEFI=0 # No, BIOS -fi # is EFI firmaare? - -# Set partition number based on the firmware type -if [ ${ISEFI} -eq 1 ] ; then -# EFI firmware -export EFIPARTITION=1 -export CRYPTPARTITION=2 -else -# BIOS firmware -export CRYPTPARTITION=1 -fi # EFI firmware