clearing bash syntax issues
This commit is contained in:
parent
d0af744e79
commit
c700852936
44
startup.sh
44
startup.sh
|
|
@ -6,16 +6,16 @@
|
||||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
# set up a config file
|
# set up a config file
|
||||||
CONFIG_FILE=$SCRIPT_DIR/setup.conf
|
CONFIG_FILE=$SCRIPT_DIR/setup.conf
|
||||||
if [ ! -f $CONFIG_FILE ]; then # check if file exists
|
if [ ! -f "$CONFIG_FILE" ]; then # check if file exists
|
||||||
touch -f $CONFIG_FILE # create file if not exists
|
touch -f "$CONFIG_FILE" # create file if not exists
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set options in setup.conf
|
# set options in setup.conf
|
||||||
set_option() {
|
set_option() {
|
||||||
if grep -Eq "^${1}.*" $CONFIG_FILE; then # check if option exists
|
if grep -Eq "^${1}.*" "$CONFIG_FILE"; then # check if option exists
|
||||||
sed -i -e "/^${1}.*/d" $CONFIG_FILE # delete option if exists
|
sed -i -e "/^${1}.*/d" "$CONFIG_FILE" # delete option if exists
|
||||||
fi
|
fi
|
||||||
echo "${1}=${2}" >>$CONFIG_FILE # add option
|
echo "${1}=${2}" >> "$CONFIG_FILE" # add option
|
||||||
}
|
}
|
||||||
logo () {
|
logo () {
|
||||||
# This will be shown on every set as user is progressing
|
# This will be shown on every set as user is progressing
|
||||||
|
|
@ -42,14 +42,14 @@ echo -ne "
|
||||||
3) luks with btrfs
|
3) luks with btrfs
|
||||||
0) exit
|
0) exit
|
||||||
"
|
"
|
||||||
read FS
|
read -r FS
|
||||||
case $FS in
|
case $FS in
|
||||||
1) set_option FS btrfs;;
|
1) set_option FS btrfs;;
|
||||||
2) set_option FS ext4;;
|
2) set_option FS ext4;;
|
||||||
3)
|
3)
|
||||||
echo -ne "Please enter your luks password: "
|
echo -ne "Please enter your luks password: "
|
||||||
read -s luks_password # read password without echo
|
read -rs luks_password # read password without echo
|
||||||
set_option luks_password $luks_password
|
set_option luks_password "$luks_password"
|
||||||
set_option FS luks;;
|
set_option FS luks;;
|
||||||
0) exit ;;
|
0) exit ;;
|
||||||
*) echo "Wrong option please select again"; filesystem;;
|
*) echo "Wrong option please select again"; filesystem;;
|
||||||
|
|
@ -60,14 +60,14 @@ timezone () {
|
||||||
time_zone="$(curl --fail https://ipapi.co/timezone)"
|
time_zone="$(curl --fail https://ipapi.co/timezone)"
|
||||||
echo -ne "System detected your timezone to be '$time_zone' \n"
|
echo -ne "System detected your timezone to be '$time_zone' \n"
|
||||||
echo -ne "Is this correct? yes/no:"
|
echo -ne "Is this correct? yes/no:"
|
||||||
read answer
|
read -r answer
|
||||||
case $answer in
|
case $answer in
|
||||||
y|Y|yes|Yes|YES)
|
y|Y|yes|Yes|YES)
|
||||||
set_option TIMEZONE $time_zone;;
|
set_option TIMEZONE "$time_zone";;
|
||||||
n|N|no|NO|No)
|
n|N|no|NO|No)
|
||||||
echo "Please enter your desired timezone e.g. Europe/London :"
|
echo "Please enter your desired timezone e.g. Europe/London :"
|
||||||
read new_timezone
|
read -r new_timezone
|
||||||
set_option TIMEZONE $new_timezone;;
|
set_option TIMEZONE "$new_timezone";;
|
||||||
*) echo "Wrong option. Try again";timezone;;
|
*) echo "Wrong option. Try again";timezone;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +104,7 @@ Please select key board layout from this list
|
||||||
-us
|
-us
|
||||||
|
|
||||||
"
|
"
|
||||||
read -p "Your key boards layout:" keymap
|
read -rp "Your key boards layout:" keymap
|
||||||
set_option KEYMAP $keymap
|
set_option KEYMAP $keymap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ drivessd () {
|
||||||
echo -ne "
|
echo -ne "
|
||||||
Is this an ssd? yes/no:
|
Is this an ssd? yes/no:
|
||||||
"
|
"
|
||||||
read ssd_drive
|
read -r ssd_drive
|
||||||
|
|
||||||
case $ssd_drive in
|
case $ssd_drive in
|
||||||
y|Y|yes|Yes|YES)
|
y|Y|yes|Yes|YES)
|
||||||
|
|
@ -136,20 +136,20 @@ echo -ne "
|
||||||
|
|
||||||
Please enter full path to disk: (example /dev/sda):
|
Please enter full path to disk: (example /dev/sda):
|
||||||
"
|
"
|
||||||
read option
|
read -r option
|
||||||
echo "DISK=$option" >> setup.conf
|
echo "DISK=$option" >> setup.conf
|
||||||
|
|
||||||
drivessd
|
drivessd
|
||||||
set_option DISK $option
|
set_option DISK "$option"
|
||||||
}
|
}
|
||||||
userinfo () {
|
userinfo () {
|
||||||
read -p "Please enter your username: " username
|
read -rp "Please enter your username: " username
|
||||||
set_option USERNAME ${username,,} # convert to lower case as in issue #109
|
set_option USERNAME "${username,,} "# convert to lower case as in issue #109
|
||||||
echo -ne "Please enter your password: \n"
|
echo -ne "Please enter your password: \n"
|
||||||
read -s password # read password without echo
|
read -rs password # read password without echo
|
||||||
set_option PASSWORD $password
|
set_option PASSWORD "$password"
|
||||||
read -rep "Please enter your hostname: " nameofmachine
|
read -rp "Please enter your hostname: " nameofmachine
|
||||||
set_option nameofmachine $nameofmachine
|
set_option nameofmachine "$nameofmachine"
|
||||||
}
|
}
|
||||||
# More features in future
|
# More features in future
|
||||||
# language (){}
|
# language (){}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue