Added overwrite install

This commit is contained in:
Suikan 2021-07-02 14:20:16 +09:00
parent 5cbe95252c
commit 791ffa6112
3 changed files with 58 additions and 20 deletions

View file

@ -5,12 +5,25 @@
function confirmation(){
# Consistency check for the OVERWRITEINSTALL and ERASEALL
if [ ${ERASEALL} -eq 1 -a ${OVERWRITEINSTALL} -eq 1 ] ; then
cat <<- HEREDOC 1>&2
***** ERROR : Confliction between ERASEALL and OVERWRITEINATALL *****
...ERASEALL = ${ERASEALL}
...OVERWRITEINSTALL = ${OVERWRITEINSTALL}
...Check configuration in config.txt
...Installation process terminated..
HEREDOC
fi
# Sanity check for volume group name
if echo ${VGNAME} | grep "-" -i > /dev/null ; then # "-" is found in the volume group name.
cat <<- HEREDOC 1>&2
***** ERROR : VGNAME is "${VGNAME}" *****
..."-" is not allowed in the volume name.
...Check passphrase and config.txt
...Check configuration in config.txt
...Installation process terminated..
HEREDOC
@ -22,7 +35,7 @@ function confirmation(){
cat <<- HEREDOC 1>&2
***** ERROR : LVROOTNAME is "${LVROOTNAME}" *****
..."-" is not allowed in the volume name.
...Check passphrase and config.txt
...Check configuration in config.txt
...Installation process terminated..
HEREDOC
@ -34,7 +47,7 @@ function confirmation(){
cat <<- HEREDOC 1>&2
***** ERROR : LVSWAPNAME is "${LVSWAPNAME}" *****
..."-" is not allowed in the volume name.
...Check passphrase and config.txt
...Check configuration in config.txt
...Installation process terminated..
HEREDOC

View file

@ -79,24 +79,45 @@ function pre_install() {
fi # if /dev/mapper/swap volume already exit.
# Create a ROOT Logical Volume on VG.
if [ -e /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then
cat <<- HEREDOC 1>&2
***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. *****
...Check LVROOTNAME environment variable in config.txt.
HEREDOC
echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"."
vgchange -a n ${VGNAME}
echo "...Close LUKS volume \"${CRYPTPARTNAME}\"."
cryptsetup close ${CRYPTPARTNAME}
cat <<- HEREDOC 1>&2
if [ -e /dev/mapper/${VGNAME}-${LVROOTNAME} ] ; then # exist
if [ ${OVERWRITEINATALL} -eq 1 ] ; then # exist and overwrite install
echo "...Logical volume "${VGNAME}-${LVROOTNAME}" already exists. OK."
else # exist and not overwriteinstall
cat <<- HEREDOC 1>&2
***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" already exists. *****
...Check LVROOTNAME environment variable in config.txt.
HEREDOC
echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"."
vgchange -a n ${VGNAME}
echo "...Close LUKS volume \"${CRYPTPARTNAME}\"."
cryptsetup close ${CRYPTPARTNAME}
cat <<- HEREDOC 1>&2
...Installation process terminated..
HEREDOC
return 1 # with error status
fi
else # not exsit
if [ ${OVERWRITEINATALL} -eq 1 ] ; then
cat <<- HEREDOC 1>&2
***** ERROR : Logical volume "${VGNAME}-${LVROOTNAME}" doesn't exist while overwrite install. *****
...Check consistency of config.txt.
HEREDOC
echo "...Deactivate all logical volumes in volume group \"${VGNAME}\"."
vgchange -a n ${VGNAME}
echo "...Close LUKS volume \"${CRYPTPARTNAME}\"."
cryptsetup close ${CRYPTPARTNAME}
cat <<- HEREDOC 1>&2
...Installation process terminated..
HEREDOC
return 1 # with error status
else # not exist and not overwrite install
echo "...Create logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"."
lvcreate -l ${LVROOTSIZE} -n ${LVROOTNAME} ${VGNAME}
fi
fi
...Installation process terminated..
HEREDOC
return 1 # with error status
else
echo "...Create logical volume \"${LVROOTNAME}\" on \"${VGNAME}\"."
lvcreate -l ${LVROOTSIZE} -n ${LVROOTNAME} ${VGNAME}
fi # if the root volun already exist
# successful return
return 0

View file

@ -26,6 +26,10 @@ export CRYPTPARTNAME="luks_volume"
export VGNAME="vg1"
export LVSWAPNAME="swap"
# Do not touch this parameter, unless you understand precisely what you are doing.
# 1 : Overwrite the existing logical volume as root vlume. 0 : Create new logical volume as root volume.
export OVERWRITEINSTALL=0
# Void Linux only. Ignored in Ubuntu.
# The font size of the void-installer
export XTERMFONTSIZE=11