forked from johnbrandborg/aws-clientvpn-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanup.sh
executable file
·46 lines (34 loc) · 1.14 KB
/
cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
echo -e "---------------------------- AWS Client VPN Helper ----------------------------\n"
# Load variables from Configuration file
. variables.cfg
# Check that all variables are available
REQUIRED_ARGUMENTS=("WORKDIR" "OVPNCFGFILE")
for REQUIRED in ${REQUIRED_ARGUMENTS[@]}; do
if [ -z $(eval echo \$$REQUIRED) ]; then
echo -e " ERROR: Configuration is missing the argument $REQUIRED.\n \
Required variables are ${REQUIRED_ARGUMENTS[@]}."; exit 1
fi
done
# Make sure the working directory has correct
if [ -f "$WORKDIR/`basename "$0"`" ]; then
cd $WORKDIR
else
echo " ERROR: The working directory doesn't look valid. \
Please make sure you update variables.cfg"; exit 1
fi
# Operational Function
function clean-up-keys {
echo -e "Cleaning up all of the above\n"
rm -fr ./easy-rsa
rm -fr ./pki
rm $OVPNCFGFILE openvpn.log 2> /dev/null
echo -e "Proceedure completed."
}
# Main Execution
read -p "Do you want to cleanup the local Certificates & Keys, Logs and Binaries? [y/n] " createopt
if [ "$createopt" == "y" ] || [ "$createopt" == "yes" ]; then
clean-up-keys
else
echo "Exiting"; exit
fi