-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall_service.sh
More file actions
executable file
·52 lines (42 loc) · 1.28 KB
/
uninstall_service.sh
File metadata and controls
executable file
·52 lines (42 loc) · 1.28 KB
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
#!/bin/bash
# Uninstallation script for PikaFileService systemd service
set -e
SERVICE_NAME="pikafileservice"
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
INSTALL_DIR="/opt/${SERVICE_NAME}"
LOG_DIR="/var/log/${SERVICE_NAME}"
echo "Uninstalling PikaFileService systemd service..."
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (use sudo)"
exit 1
fi
# Stop and disable service
echo "Stopping and disabling service..."
systemctl stop "${SERVICE_NAME}" 2>/dev/null || true
systemctl disable "${SERVICE_NAME}" 2>/dev/null || true
# Remove service file
echo "Removing service file..."
rm -f "${SERVICE_FILE}"
# Remove installation directory (with confirmation)
if [ -d "${INSTALL_DIR}" ]; then
read -p "Remove installation directory ${INSTALL_DIR}? [y/N]: " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "${INSTALL_DIR}"
echo "Removed ${INSTALL_DIR}"
fi
fi
# Remove log directory (with confirmation)
if [ -d "${LOG_DIR}" ]; then
read -p "Remove log directory ${LOG_DIR}? [y/N]: " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf "${LOG_DIR}"
echo "Removed ${LOG_DIR}"
fi
fi
# Reload systemd
echo "Reloading systemd daemon..."
systemctl daemon-reload
echo "Uninstallation complete!"