diff --git a/script/config.sh b/script/config.sh index 7c2b81b..527617e 100644 --- a/script/config.sh +++ b/script/config.sh @@ -48,3 +48,11 @@ else # BIOS firmware export CRYPTPARTITION=1 fi # EFI firmware + +# Void Linux only. Ignored in Ubuntu. +# Detect the GUI environment +if env | grep XDG_SESSION_TYPE > /dev/null ; then + export GUIENV=1 # set 1 if GUI env. +else + export GUIENV=0 # set 0 if not GUI env. +fi \ No newline at end of file diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index ba2ec59..7d5085c 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -21,8 +21,7 @@ source config.sh # ******************************************************************************* # Distribution check -uname -a | grep ubuntu -i > /dev/null -if [ $? -eq 1 ] ; then # "Ubuntu" is not found in the OS name. +if ! uname -a | grep ubuntu -i > /dev/null ; then # "Ubuntu" is not found in the OS name. echo "*******************************************************************************" uname -a cat < /dev/null -if [ $? -eq 0 ] ; then # "-" is found in the volume group name. + +if echo ${VGNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. cat <&2 ***** ERROR : VGNAME is "${VGNAME}" ***** THe "-" is not allowed in the volume name. @@ -55,8 +54,8 @@ HEREDOC fi # "-" is found in the volume group name. # Sanity check for root volume name -echo ${LVROOTNAME} | grep "-" -i > /dev/null -if [ $? -eq 0 ] ; then # "-" is found in the volume name. + +if echo ${LVROOTNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. cat <&2 ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** THe "-" is not allowed in the volume name. @@ -68,8 +67,7 @@ HEREDOC fi # "-" is found in the volume name. # Sanity check for swap volume name -echo ${LVSWAPNAME} | grep "-" -i > /dev/null -if [ $? -eq 0 ] ; then # "-" is found in the volume name. +if echo ${LVSWAPNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. cat <&2 ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** THe "-" is not allowed in the volume name. @@ -187,15 +185,14 @@ fi # if crypt volume is unable to open # ----- Configure the LVM in LUKS volume ----- # Check volume group ${VGNAME} exist or not -vgdisplay -s ${VGNAME} &> /dev/null -if [ $? -eq 0 ] ; then # is return value 0? ( exist ?) +if vgdisplay -s ${VGNAME} &> /dev/null ; then # exist ? echo "...Volume group ${VGNAME} already exist. Skipped to create. No problem." else echo "...Initialize a physical volume on \"${CRYPTPARTNAME}\"" pvcreate /dev/mapper/${CRYPTPARTNAME} echo "...And then create Volume group \"${VGNAME}\"." vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME} -fi # if /dev/volume-groupt not exist +fi # if /dev/volume-groupt exist # Create a SWAP Logical Volume on VG, if it doesn't exist if [ -e /dev/mapper/${VGNAME}-${LVSWAPNAME} ] ; then @@ -271,8 +268,8 @@ while [ ! -e /target/etc/default/grub ] do sleep 1 # 1sec. - ps $ubiquity_pid > /dev/null # ps return 0 if process exists. - if [ $? -ne 0 ] ; then # If not exists + # Check if installer still exist + if ! ps $ubiquity_pid > /dev/null ; then # If not exists cat <&2 The ubiquity installer terminated unexpectedly. @@ -281,7 +278,7 @@ HEREDOC return fi -done +done # while # Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition. sleep 1 # 1sec. diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index b840c0b..3952626 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -21,8 +21,7 @@ source config.sh # ******************************************************************************* # Distribution check -uname -a | grep void -i > /dev/null -if [ $? -eq 1 ] ; then # "Void" is not found in the OS name. +if ! uname -a | grep void -i > /dev/null ; then # "Void" is not found in the OS name. echo "*********************************************************************************" uname -a cat < /dev/null -if [ $? -eq 0 ] ; then # "-" is found in the volume group name. +if echo ${VGNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume group name. cat <&2 ***** ERROR : VGNAME is "${VGNAME}" ***** THe "-" is not allowed in the volume name. @@ -55,8 +53,7 @@ HEREDOC fi # "-" is found in the volume group name. # Sanity check for root volume name -echo ${LVROOTNAME} | grep "-" -i > /dev/null -if [ $? -eq 0 ] ; then # "-" is found in the volume name. +if echo ${LVROOTNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. cat <&2 ***** ERROR : LVROOTNAME is "${LVROOTNAME}" ***** THe "-" is not allowed in the volume name. @@ -68,8 +65,8 @@ HEREDOC fi # "-" is found in the volume name. # Sanity check for swap volume name -echo ${LVSWAPNAME} | grep "-" -i > /dev/null -if [ $? -eq 0 ] ; then # "-" is found in the volume name. + +if echo ${LVSWAPNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume name. cat <&2 ***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" ***** THe "-" is not allowed in the volume name. @@ -129,8 +126,11 @@ HEREDOC fi # passphrase validation # Install essential packages. -xbps-install -y -Su xbps gptfdisk xterm - +if [ ${GUIENV} -eq 1 ] ; then + xbps-install -y -Su xbps gptfdisk xterm +else + xbps-install -y -Su xbps gptfdisk +fi # ******************************************************************************* # Pre-install stage @@ -190,15 +190,14 @@ fi # if crypt volume is unable to open # ----- Configure the LVM in LUKS volume ----- # Check volume group ${VGNAME} exist or not -vgdisplay -s ${VGNAME} &> /dev/null -if [ $? -eq 0 ] ; then # is return value 0? ( exist ?) +if vgdisplay -s ${VGNAME} &> /dev/null ; then # if exist echo "...Volume group ${VGNAME} already exist. Skipped to create. No problem." else echo "...Initialize a physical volume on \"${CRYPTPARTNAME}\"" pvcreate /dev/mapper/${CRYPTPARTNAME} echo "...And then create Volume group \"${VGNAME}\"." vgcreate ${VGNAME} /dev/mapper/${CRYPTPARTNAME} -fi # if /dev/volume-groupt not exist +fi # if /dev/volume-groupt exist # Create a SWAP Logical Volume on VG, if it doesn't exist if [ -e /dev/mapper/${VGNAME}-${LVSWAPNAME} ] ; then @@ -270,8 +269,12 @@ HEREDOC # waitfor a console input read dummy_var -# Start GUI installer -xterm -fa monospace -fs ${XTERMFONTSIZE} -e void-installer & +# Start TUI installer +if [ $GUIENV -eq 1 ]; then + xterm -fa monospace -fs ${XTERMFONTSIZE} -e void-installer & +else + void-installer & +fi # Record the PID voidinstaller_pid=$! @@ -281,8 +284,8 @@ while [ ! -e /mnt/target/etc/default/grub ] do sleep 1 # 1sec. - ps $voidinstaller_pid > /dev/null # ps return 0 if process exists. - if [ $? -ne 0 ] ; then # If not exists + # Chcheck if installer still exist + if ! ps $voidinstaller_pid > /dev/null ; then # If not exists cat <&2 The void-installer terminated unexpectedly. @@ -291,19 +294,25 @@ HEREDOC return fi -done +done # while # Perhaps, too neuvous. Wait 1 more sectond to avoid the rece condition. sleep 1 # 1sec. # Make target GRUB aware to the crypt partition # This must do it after start of the file copy by void-installer, but before the end of the file copy. -echo "...Add GRUB_ENABLE_CRYPTODISK entry to /mnt/target/etc/default/grub " +# If the environment is not GUI, keep quiet not to bother the TUI installer. +if [ $GUIENV -eq 1 ]; then + echo "...Add GRUB_ENABLE_CRYPTODISK entry to /mnt/target/etc/default/grub " +fi echo "GRUB_ENABLE_CRYPTODISK=y" >> /mnt/target/etc/default/grub # And then, wait for the end of void-installer process -echo "...Waiting for the end of void-installer." +# If the environment is not GUI, keep quiet not to bother the TUI installer. +if [ $GUIENV -eq 1 ]; then + echo "...Waiting for the end of void-installer." +fi wait $voidinstaller_pid # *******************************************************************************