Skip to content

Commit 13927cd

Browse files
committed
Modified logging function
1 parent 81d5636 commit 13927cd

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

setup.sh

+14-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function includeDependencies() {
1414

1515
current_dir=$(getCurrentDir)
1616
includeDependencies
17+
output_file="output.log"
1718

1819
function setupSwap() {
1920
createSwap
@@ -62,21 +63,25 @@ addUserAccount "${username}" "${password}"
6263

6364
read -rp $'Paste in the public SSH key for the new user:\n' sshKey
6465
echo 'Running setup script...'
65-
logTimestamp "output.log"
66-
disableSudoPassword "${username}" >>output.log 2>&1
67-
addSSHKey "${username}" "${sshKey}" >>output.log 2>&1
68-
changeSSHConfig >>output.log 2>&1
69-
setupUfw >>output.log 2>&1
66+
logTimestamp "${output_file}"
67+
68+
disableSudoPassword "${username}" >>"${output_file}" 2>&1
69+
addSSHKey "${username}" "${sshKey}" >>"${output_file}" 2>&1
70+
changeSSHConfig >>"${output_file}" 2>&1
71+
setupUfw >>"${output_file}" 2>&1
7072

7173
if [[ $(hasSwap) == "false" ]]; then
72-
setupSwap >>output.log 2>&1
74+
setupSwap >>"${output_file}" 2>&1
7375
fi
7476

75-
setTimezone "Asia/Singapore" >>output.log 2>&1
76-
configureNTP >>output.log 2>&1
77+
timezone="Asia/Singapore"
78+
setTimezone "${timezone}" >>"${output_file}" 2>&1
79+
echo "Timezone is set to ${timezone}"
80+
81+
configureNTP >>"${output_file}" 2>&1
7782

7883
sudo service ssh restart
7984

8085
cleanup
8186

82-
echo 'Setup Done! Log file is located at output.log'
87+
echo "Setup Done! Log file is located at ${output_file}"

0 commit comments

Comments
 (0)