This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuninstall.sh
91 lines (75 loc) · 2.22 KB
/
uninstall.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
echo "#-----------------------------#"
echo "# _____ _____ __ __ #"
echo "# / ____/ ____| \/ | #"
echo "# | (___| (___ | \ / | #"
echo "# \___ \\\\___ \| |\/| | #"
echo "# ____) |___) | | | | #"
echo "# |_____/_____/|_| |_| #"
echo "#-----------------------------#"
echo "# Satisfactory Server Manager #"
echo "#-----------------------------#"
echo ""
echo "Uninstalling SSM will remove all SSM files and Server instances!"
echo ""
read -p "Are you sure you want to uninstall SSM (y/n)?" choice
case "$choice" in
y | Y) echo "yes" ;;
*) exit 0 ;;
esac
TEMP_DIR=$(mktemp -d /tmp/XXXXX)
INSTALL_DIR="/opt/SSM"
FORCE=0
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--force | -f)
FORCE=1
shift # past value
;;
--installdir)
INSTALL_DIR=$2
shift
shift
;;
*)
echo "Invalid option must be: [--force, --update, --noservice, --dev, --installdir=<Location>"
exit 1
;;
esac
done
ENV_SYSTEMD=$(pidof systemd | wc -l)
ENV_SYSTEMCTL=$(which systemctl | wc -l)
if [[ ${ENV_SYSTEMD} -eq 0 ]] && [[ ${ENV_SYSTEMCTL} -eq 0 ]]; then
echo "Error: Cant install service on this system!"
exit 3
fi
SSM_SERVICENAME="SSM.service"
SSM_SERVICEFILE="/etc/systemd/system/SSM.service"
SSM_SERVICE=$(
systemctl list-units --full -all | grep -Fq "${SSM_SERVICENAME}"
echo $?
)
if [ ${SSM_SERVICE} -eq 0 ]; then
echo "* Stopping SSM Service"
systemctl stop ${SSM_SERVICENAME}
fi
if [ ${SSM_SERVICE} -eq 0 ]; then
echo "* Removing SSM Service"
systemctl disable ${SSM_SERVICENAME} >/dev/null 2>&1
rm -r "${SSM_SERVICEFILE}" >/dev/null 2>&1
systemctl daemon-reload >/dev/null 2>&1
fi
echo "* Removing Install Directory ${INSTALL_DIR}"
rm -r ${INSTALL_DIR} >/dev/null 2>&1
echo "* Removing SSM user"
deluser --remove-home ssm >/dev/null 2>&1
delgroup ssm >/dev/null 2>&1
rm -r "/home/ssm" >/dev/null 2>&1
echo "* Removing Docker Containers"
docker rm -f $(docker ps -a --filter="name=SSMAgent" -q) >/dev/null 2>&1
echo "* Removing Docker Containers Directory /SSMAgents"
rm -r /SSMAgents >/dev/null 2>&1
echo "Successfully Uninstalled SSM!"
exit 0