Modified logging function

This commit is contained in:
Jason Hee committed 2016-12-01 19:15:12 +08:00
1 parent 81d5636078
commit 13927cd311
1 file changed
+14 -9
+14 -9
View File
@@ -14,6 +14,7 @@ function includeDependencies() {
current_dir=$(getCurrentDir) current_dir=$(getCurrentDir)
includeDependencies includeDependencies
output_file="output.log"
function setupSwap() { function setupSwap() {
createSwap createSwap
@@ -62,21 +63,25 @@ addUserAccount "${username}" "${password}"
read -rp $'Paste in the public SSH key for the new user:\n' sshKey read -rp $'Paste in the public SSH key for the new user:\n' sshKey
echo 'Running setup script...' echo 'Running setup script...'
logTimestamp "output.log" logTimestamp "${output_file}"
disableSudoPassword "${username}" >>output.log 2>&1
addSSHKey "${username}" "${sshKey}" >>output.log 2>&1 disableSudoPassword "${username}" >>"${output_file}" 2>&1
changeSSHConfig >>output.log 2>&1 addSSHKey "${username}" "${sshKey}" >>"${output_file}" 2>&1
setupUfw >>output.log 2>&1 changeSSHConfig >>"${output_file}" 2>&1
setupUfw >>"${output_file}" 2>&1
if [[ $(hasSwap) == "false" ]]; then if [[ $(hasSwap) == "false" ]]; then
setupSwap >>output.log 2>&1 setupSwap >>"${output_file}" 2>&1
fi fi
setTimezone "Asia/Singapore" >>output.log 2>&1 timezone="Asia/Singapore"
configureNTP >>output.log 2>&1 setTimezone "${timezone}" >>"${output_file}" 2>&1
echo "Timezone is set to ${timezone}"
configureNTP >>"${output_file}" 2>&1
sudo service ssh restart sudo service ssh restart
cleanup cleanup
echo 'Setup Done! Log file is located at output.log' echo "Setup Done! Log file is located at ${output_file}"