diff --git a/script/lib.sh b/script/lib.sh index 032adae..5149dea 100644 --- a/script/lib.sh +++ b/script/lib.sh @@ -276,7 +276,6 @@ function deactivate_and_close(){ # ******************************************************************************* # Delete the nwe volume if overwrite install, and close all # ******************************************************************************* - function on_unexpected_installer_quit(){ echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it @@ -287,3 +286,31 @@ function on_unexpected_installer_quit(){ deactivate_and_close echo "...The new logical volume has been deleted. You can retry Kaiten-yaki again." } + + +# ******************************************************************************* +# Check whether given signaure is in the system information +# ******************************************************************************* +function distribution_check(){ + if ! uname -a | grep "${DISTRIBUTIONSIGNATURE}" -i > /dev/null ; then # Signature is not found in the OS name. + echo "*******************************************************************************" + uname -a + cat <<- HEREDOC + ******************************************************************************* + This system seems to be not $DISTRIBUTIONNAME, while this script is dediated to the $DISTRIBUTIONNAME. + Are you sure you want to run this script? [Y/N] + HEREDOC + read -r YESNO + if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then + cat <<- HEREDOC + + ...Installation process terminated.. + HEREDOC + return 1 # with error status + fi # if YES + + fi # Distribution check + + # no error + return 0 +} \ No newline at end of file diff --git a/script/ubuntu-kaiten-yaki.sh b/script/ubuntu-kaiten-yaki.sh index 2207d67..27ef8a6 100644 --- a/script/ubuntu-kaiten-yaki.sh +++ b/script/ubuntu-kaiten-yaki.sh @@ -4,7 +4,7 @@ # Load configuration parameter source ./config.sh - # Load functions + # Load common functions source ./lib.sh function main() { @@ -12,30 +12,20 @@ function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/target" - # Distribution check - if ! uname -a | grep ubuntu -i > /dev/null ; then # "Ubuntu" is not found in the OS name. - echo "*******************************************************************************" - uname -a - cat <<- HEREDOC - ******************************************************************************* - This system seems to be not Ubuntu, while this script is dediated to the Ubuntu. - Are you sure you want to run this script? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - fi # Distribution check # ******************************************************************************* # Confirmation before installation # ******************************************************************************* + # parameters for distribution check + export DISTRIBUTIONSIGNATURE="ubuntu" + export DISTRIBUTIONNAME="Ubuntu" + + # Check whetehr given signature exist or not + if ! distribution_check ; then + return 1 # with error status + fi + # Common part of the parameter confirmation if ! confirmation ; then return 1 # with error status diff --git a/script/void-kaiten-yaki.sh b/script/void-kaiten-yaki.sh index a089463..4af9fea 100644 --- a/script/void-kaiten-yaki.sh +++ b/script/void-kaiten-yaki.sh @@ -4,38 +4,28 @@ # Load configuration parameter source ./config.sh - # Load functions + # Load common functions source ./lib.sh function main() { # This is the mount point of the install target. export TARGETMOUNTPOINT="/mnt/target" - - # Distribution check - if ! uname -a | grep void -i > /dev/null ; then # "Void" is not found in the OS name. - echo "*******************************************************************************" - uname -a - cat <<- HEREDOC - ******************************************************************************* - This system seems to be not Void Linux, while this script is dediated to the Void Linux. - Are you sure you want to run this script? [Y/N] - HEREDOC - read -r YESNO - if [ "${YESNO}" != "Y" ] && [ "${YESNO}" != "y" ] ; then - cat <<- HEREDOC - - ...Installation process terminated.. - HEREDOC - return 1 # with error status - fi # if YES - - fi # Distribution check + # ******************************************************************************* # Confirmation before installation # ******************************************************************************* + # parameters for distribution check + export DISTRIBUTIONSIGNATURE="void" + export DISTRIBUTIONNAME="Void Linux" + + # Check whetehr given signature exist or not + if ! distribution_check ; then + return 1 # with error status + fi + # Common part of the parameter confirmation if ! confirmation ; then return 1 # with error status