mirror of
https://github.com/darksaid98/ubuntu-server-setup.git
synced 2026-12-03 14:38:57 +00:00
Added prompting of server timezone
- User can now specify the timezone of the server rather than needing to set it via editing the bash script
This commit is contained in:
1 parent
69b536300d
commit
1e31d3f823
2 files changed
+28
-12
No files matched your search
@@ -43,17 +43,34 @@ function logTimestamp() {
|
|||||||
} >>"${filename}" 2>&1
|
} >>"${filename}" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupTimezone() {
|
||||||
|
echo -ne "Enter the timezone for the server (Default is 'Asia/Singapore'):\n" >&3
|
||||||
|
read -r timezone
|
||||||
|
if [ -z "${timezone}" ]; then
|
||||||
|
timezone="Asia/Singapore"
|
||||||
|
fi
|
||||||
|
setTimezone "${timezone}"
|
||||||
|
echo "Timezone is set to $(cat /etc/timezone)" >&3
|
||||||
|
}
|
||||||
|
|
||||||
read -rp "Enter the username of the new user account:" username
|
read -rp "Enter the username of the new user account:" username
|
||||||
read -s -rp "Enter new UNIX password:" password
|
|
||||||
printf "\n"
|
|
||||||
read -s -rp "Retype new UNIX password:" password_confirmation
|
|
||||||
printf "\n"
|
|
||||||
|
|
||||||
if [[ "${password}" != "${password_confirmation}" ]]; then
|
# Keep prompting for the password and password confirmation
|
||||||
echo "Passwords do not match!"
|
PASSWORDS_MATCH=0
|
||||||
exit 1
|
while [ "${PASSWORDS_MATCH}" -eq "0" ]; do
|
||||||
fi
|
read -s -rp "Enter new UNIX password:" password
|
||||||
|
printf "\n"
|
||||||
|
read -s -rp "Retype new UNIX password:" password_confirmation
|
||||||
|
printf "\n"
|
||||||
|
|
||||||
|
if [[ "${password}" != "${password_confirmation}" ]]; then
|
||||||
|
echo "Passwords do not match! Please try again."
|
||||||
|
else
|
||||||
|
PASSWORDS_MATCH=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Run setup functions
|
||||||
trap cleanup EXIT SIGHUP SIGINT SIGTERM
|
trap cleanup EXIT SIGHUP SIGINT SIGTERM
|
||||||
|
|
||||||
addUserAccount "${username}" "${password}"
|
addUserAccount "${username}" "${password}"
|
||||||
@@ -72,10 +89,9 @@ if ! hasSwap; then
|
|||||||
setupSwap
|
setupSwap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
timezone="Asia/Singapore"
|
setupTimezone
|
||||||
setTimezone "${timezone}"
|
|
||||||
echo "Timezone is set to ${timezone}" >&3
|
|
||||||
|
|
||||||
|
echo "Installing Network Time Protocol... " >&3
|
||||||
configureNTP
|
configureNTP
|
||||||
|
|
||||||
sudo service ssh restart
|
sudo service ssh restart
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ function createSwap() {
|
|||||||
phymem=4
|
phymem=4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo fallocate -l ${swapmem}G /swapfile
|
sudo fallocate -l "${swapmem}G" /swapfile
|
||||||
sudo chmod 600 /swapfile
|
sudo chmod 600 /swapfile
|
||||||
sudo mkswap /swapfile
|
sudo mkswap /swapfile
|
||||||
sudo swapon /swapfile
|
sudo swapon /swapfile
|
||||||
|
|||||||
Reference in new issue
Block a user