Skip to content

Commit c2e9ba5

Browse files
committed
fix(tools): install script
1 parent 91493ac commit c2e9ba5

File tree

2 files changed

+121
-4
lines changed

2 files changed

+121
-4
lines changed

deploy/systemd/install.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ TAG=""
1111
REPO="$REPO_DEFAULT"
1212
INSTALL_PREFIX="/opt/streamkit"
1313
NO_START="0"
14+
UNINSTALL="0"
15+
PURGE="0"
16+
YES="0"
1417

1518
usage() {
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
2935
Examples:
3036
sudo ./install.sh --tag v0.2.0
3137
sudo ./install.sh --latest
38+
sudo ./install.sh --uninstall
39+
sudo ./install.sh --uninstall --purge
3240
EOF
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
7999
fi
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+
81179
need_cmd curl
82180
need_cmd tar
83181
need_cmd sed

docs/src/content/docs/deployment/systemd.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ This install path is a middle-ground between Docker and "build from source": you
1212
On a systemd-based Linux host:
1313

1414
```bash
15-
TAG=v0.1.0 # replace with the latest release tag
16-
curl -fsSL https://raw.githubusercontent.com/streamer45/streamkit/${TAG}/deploy/systemd/install.sh -o streamkit-install.sh
15+
export TAG=v0.1.0 # replace with the latest release tag
16+
curl -fsSL "https://raw.githubusercontent.com/streamer45/streamkit/${TAG}/deploy/systemd/install.sh" -o streamkit-install.sh
1717
chmod +x streamkit-install.sh
18-
19-
sudo ./streamkit-install.sh --tag ${TAG}
18+
sudo ./streamkit-install.sh --tag "${TAG}"
2019
```
2120

2221
> [!TIP]
@@ -61,3 +60,23 @@ Re-run the installer with a newer tag (or `--latest`) and restart:
6160
sudo ./streamkit-install.sh --latest
6261
sudo systemctl restart streamkit
6362
```
63+
64+
## Uninstall
65+
66+
To remove StreamKit while preserving configuration and data:
67+
68+
```bash
69+
sudo ./streamkit-install.sh --uninstall
70+
```
71+
72+
To completely remove everything including config, data, and the streamkit user:
73+
74+
```bash
75+
sudo ./streamkit-install.sh --uninstall --purge
76+
```
77+
78+
> [!NOTE]
79+
> Without `--purge`, the following are preserved for potential reinstallation:
80+
> - `/etc/streamkit/` (configuration)
81+
> - `/var/lib/streamkit/` (plugins and data)
82+
> - The `streamkit` system user

0 commit comments

Comments
 (0)