Skip to content

Commit 1b7a8d3

Browse files
author
Hunter T
committed
style: change formatting of color variable
1 parent 944ac56 commit 1b7a8d3

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

hardening/sshd.sh

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,41 @@ red="$(printf '\033[1;31m')"
2121
nc="$(printf '\033[0m')"
2222

2323

24-
##### End of [ Variables ]
24+
#### End of [ Variables ]
25+
########################################################################################
26+
#### [ Functions ]
27+
28+
29+
clean_up() {
30+
####
31+
# Function Info: Cleanly exit the script.
32+
#
33+
# Parameters:
34+
# $1 - required
35+
# Exit status code.
36+
####
37+
38+
echo -e "\nExiting..."
39+
exit "$1"
40+
}
41+
42+
43+
#### End of [ Functions ]
2544
########################################################################################
2645
#### [ Prepping ]
2746

2847

2948
## Check if the script was executed with root privilege.
3049
if [[ $EUID != 0 ]]; then
3150
echo "${red}Please run this script as or with root privilege${nc}" >&2
32-
echo -e "\nExiting..."
33-
exit 2
51+
clean_up 2
3452
fi
3553

3654
## Confirm that 'sshd_config' exists.
3755
if [[ ! -f $config_file ]]; then
3856
echo "${red}'sshd_config' doesn't exist" >&2
3957
echo "${cyan}openssh-server may not be installed${nc}"
40-
echo -e "\nExiting..."
41-
exit 3
58+
clean_up 3
4259
fi
4360

4461

@@ -61,18 +78,18 @@ if [[ -f $config_file_bak ]]; then
6178
echo "${red}Failed to back up sshd_config" >&2
6279
echo "${cyan}Please create a backup of the original 'sshd_config'" \
6380
"before continuing${nc}"
64-
exit 1
81+
clean_up 1
6582
}
6683
;;
67-
*) exit 0 ;;
84+
*) clean_up 0 ;;
6885
esac
6986
else
7087
echo "Backing up 'sshd_config'..."
7188
cp $config_file $config_file_bak || {
7289
echo "${red}Failed to back up sshd_config" >&2
7390
echo "${cyan}Please create a backup of the original 'sshd_config' before" \
7491
"continuing${nc}"
75-
exit 1
92+
clean_up 1
7693
}
7794
fi
7895

0 commit comments

Comments
 (0)