Refactored

Distribution check is now common function
This commit is contained in:
Suikan 2021-07-03 09:47:42 +09:00
parent 8ab8143838
commit 2d2d200fef
3 changed files with 49 additions and 42 deletions

View file

@ -276,7 +276,6 @@ function deactivate_and_close(){
# ******************************************************************************* # *******************************************************************************
# Delete the nwe volume if overwrite install, and close all # Delete the nwe volume if overwrite install, and close all
# ******************************************************************************* # *******************************************************************************
function on_unexpected_installer_quit(){ function on_unexpected_installer_quit(){
echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****" echo "***** ERROR : The GUI/TUI installer terminated unexpectedly. *****"
if [ "${OVERWRITEINSTALL}" -eq 0 ] ; then # If not over install, volume is new. So delete it 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 deactivate_and_close
echo "...The new logical volume has been deleted. You can retry Kaiten-yaki again." 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
}

View file

@ -4,7 +4,7 @@
# Load configuration parameter # Load configuration parameter
source ./config.sh source ./config.sh
# Load functions # Load common functions
source ./lib.sh source ./lib.sh
function main() { function main() {
@ -12,30 +12,20 @@ function main() {
# This is the mount point of the install target. # This is the mount point of the install target.
export TARGETMOUNTPOINT="/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 # 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 # Common part of the parameter confirmation
if ! confirmation ; then if ! confirmation ; then
return 1 # with error status return 1 # with error status

View file

@ -4,38 +4,28 @@
# Load configuration parameter # Load configuration parameter
source ./config.sh source ./config.sh
# Load functions # Load common functions
source ./lib.sh source ./lib.sh
function main() { function main() {
# This is the mount point of the install target. # This is the mount point of the install target.
export TARGETMOUNTPOINT="/mnt/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 # 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 # Common part of the parameter confirmation
if ! confirmation ; then if ! confirmation ; then
return 1 # with error status return 1 # with error status