Add default -y flag to install

This commit is contained in:
Rico Tiongson 2019-02-12 21:13:40 +08:00
parent 16742495eb
commit 1c9b497b56

16
install
View File

@ -17,6 +17,20 @@ abort () {
exec echo "Installation aborted"
}
sudo mkdir -p $(dirname $CONF_PATH) || abort
# check if "-y" or "--yes" is passed as an argument
YES=false
while test $# -gt 0
do
case "$1" in
-y) YES=true
;;
--yes) YES=true
;;
esac
shift
done
sudo chown $USER $(dirname $CONF_PATH)
if [ ! -f $CONF_PATH ]; then
if [ ! -f $OLD_CONF_PATH ]; then
@ -30,6 +44,7 @@ if [ ! -f $CONF_PATH ]; then
else
# config file found, ask user if overwrite
echo "Old conf file found in $CONF_PATH"
if [ $YES == false ]; then
read -r -p "Keep the old conf file? (default: yes) [Y/n] " response
response=${response,,} # tolower
if [[ "$response" =~ ^(no|n)$ ]]; then
@ -41,6 +56,7 @@ else
abort
fi
fi
fi
fi
echo "Installing..."