1111REPO=" $REPO_DEFAULT "
1212INSTALL_PREFIX=" /opt/streamkit"
1313NO_START=" 0"
14+ UNINSTALL=" 0"
15+ PURGE=" 0"
16+ YES=" 0"
1417
1518usage () {
1619 cat << 'EOF '
@@ -24,11 +27,16 @@ Options:
2427 --repo owner/name GitHub repo to install from (default: streamer45/streamkit)
2528 --prefix PATH Install prefix (default: /opt/streamkit)
2629 --no-start Only install files; don't enable/start the service
30+ --uninstall Uninstall StreamKit (removes service and binaries)
31+ --purge With --uninstall: also remove config, data, and user
32+ -y, --yes Skip confirmation prompts
2733 -h, --help Show help
2834
2935Examples:
3036 sudo ./install.sh --tag v0.2.0
3137 sudo ./install.sh --latest
38+ sudo ./install.sh --uninstall
39+ sudo ./install.sh --uninstall --purge
3240EOF
3341}
3442
@@ -61,6 +69,18 @@ while [[ $# -gt 0 ]]; do
6169 NO_START=" 1"
6270 shift
6371 ;;
72+ --uninstall)
73+ UNINSTALL=" 1"
74+ shift
75+ ;;
76+ --purge)
77+ PURGE=" 1"
78+ shift
79+ ;;
80+ -y|--yes)
81+ YES=" 1"
82+ shift
83+ ;;
6484 -h|--help)
6585 usage
6686 exit 0
@@ -78,6 +98,84 @@ if [[ "${EUID:-$(id -u)}" -ne 0 ]]; then
7898 exit 1
7999fi
80100
101+ do_uninstall () {
102+ echo " This will remove:"
103+ echo " - StreamKit binaries (${INSTALL_PREFIX} )"
104+ echo " - systemd service unit"
105+ if [[ " $PURGE " == " 1" ]]; then
106+ echo " - Configuration (/etc/streamkit)"
107+ echo " - Data and plugins (/var/lib/streamkit)"
108+ echo " - streamkit system user"
109+ fi
110+ echo " "
111+ if [[ " $YES " != " 1" ]]; then
112+ read -r -p " Continue? [y/N] " confirm
113+ if [[ ! " $confirm " =~ ^[Yy]$ ]]; then
114+ echo " Aborted."
115+ exit 0
116+ fi
117+ fi
118+
119+ echo " "
120+ echo " Uninstalling StreamKit..."
121+
122+ if systemctl is-active --quiet streamkit 2> /dev/null; then
123+ echo " Stopping streamkit service..."
124+ systemctl stop streamkit
125+ fi
126+
127+ if systemctl is-enabled --quiet streamkit 2> /dev/null; then
128+ echo " Disabling streamkit service..."
129+ systemctl disable streamkit
130+ fi
131+
132+ if [[ -f /etc/systemd/system/streamkit.service ]]; then
133+ echo " Removing service unit..."
134+ rm -f /etc/systemd/system/streamkit.service
135+ systemctl daemon-reload
136+ fi
137+
138+ if [[ -d " $INSTALL_PREFIX " ]]; then
139+ echo " Removing installation directory ${INSTALL_PREFIX} ..."
140+ rm -rf " $INSTALL_PREFIX "
141+ fi
142+
143+ if [[ " $PURGE " == " 1" ]]; then
144+ echo " Purging configuration and data..."
145+
146+ if [[ -d /etc/streamkit ]]; then
147+ echo " Removing /etc/streamkit..."
148+ rm -rf /etc/streamkit
149+ fi
150+
151+ if [[ -d /var/lib/streamkit ]]; then
152+ echo " Removing /var/lib/streamkit..."
153+ rm -rf /var/lib/streamkit
154+ fi
155+
156+ if id -u streamkit > /dev/null 2>&1 ; then
157+ echo " Removing streamkit user..."
158+ userdel streamkit 2> /dev/null || true
159+ fi
160+
161+ if getent group streamkit > /dev/null 2>&1 ; then
162+ echo " Removing streamkit group..."
163+ groupdel streamkit 2> /dev/null || true
164+ fi
165+ else
166+ echo " "
167+ echo " Note: Config (/etc/streamkit) and data (/var/lib/streamkit) preserved."
168+ echo " Use --purge to remove everything including the streamkit user."
169+ fi
170+
171+ echo " StreamKit uninstalled."
172+ exit 0
173+ }
174+
175+ if [[ " $UNINSTALL " == " 1" ]]; then
176+ do_uninstall
177+ fi
178+
81179need_cmd curl
82180need_cmd tar
83181need_cmd sed
0 commit comments