updated install script and uninstall script

This commit is contained in:
2025-07-23 15:49:14 -05:00
parent 7230171518
commit 79289dee10
3 changed files with 54 additions and 27 deletions
+9
View File
@@ -4,4 +4,13 @@ The server handler for the sentryx control panel
# Installation # Installation
```bash ```bash
wget -qO- https://raw.githubusercontent.com/orus-dev/sentryx-server/refs/heads/master/install.sh | bash wget -qO- https://raw.githubusercontent.com/orus-dev/sentryx-server/refs/heads/master/install.sh | bash
```
# Uninstall
```bash
sh $HOME/sentryx-server/uninstall.sh
```
If that fails
```bash
wget -qO- https://raw.githubusercontent.com/orus-dev/sentryx-server/refs/heads/master/uninstall.sh | bash
``` ```
+23 -27
View File
@@ -1,50 +1,46 @@
#!/bin/bash #!/bin/bash
set -e set -e
REPO_URL="https://github.com/orus-dev/sentryx-server.git" REPO_URL="https://github.com/orus-dev/sentryx-server.git"
INSTALL_DIR="$HOME/sentryx-server" INSTALL_DIR="$HOME/sentryx-server" # expanded
SERVICE_NAME="sentryx-server" SERVICE_NAME="sentryx-server"
SERVICE_FILE="$HOME/.config/systemd/user/$SERVICE_NAME.service" SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
CARGO_BIN="$(which cargo)" CARGO_BIN="$(which cargo)"
RUN_USER="$(whoami)" # change if needed
if [ -d $INSTALL_DIR ]; then # Backup if exists
echo "Sentryx already exists, creating a backup then updating it, NOTE: you will need to transfer configs manually"
mv $INSTALL_DIR $INSTALL_DIR"-backup"
fi
# Step 1: Clone the repo
if [ -d "$INSTALL_DIR" ]; then if [ -d "$INSTALL_DIR" ]; then
echo "Directory $INSTALL_DIR already exists. Pulling latest changes..." echo "Sentryx already exists, backing up..."
git -C "$INSTALL_DIR" pull rm -rf "$INSTALL_DIR-backup"
else mv "$INSTALL_DIR" "$INSTALL_DIR-backup"
echo "Cloning $REPO_URL into $INSTALL_DIR..."
git clone "$REPO_URL" "$INSTALL_DIR"
fi fi
# Step 2: Create systemd user service file # Clone as current user
mkdir -p "$(dirname "$SERVICE_FILE")" git clone "$REPO_URL" "$INSTALL_DIR"
cat > "$SERVICE_FILE" <<EOF # Build as current user inside INSTALL_DIR
$CARGO_BIN build --release --manifest-path "$INSTALL_DIR/Cargo.toml"
# Create systemd service file with absolute ExecStart path
echo "Creating systemd service..."
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
[Unit] [Unit]
Description=SentryX Server Description=SentryX Server
After=network.target
[Service] [Service]
Type=simple Type=simple
User=$RUN_USER
WorkingDirectory=$INSTALL_DIR WorkingDirectory=$INSTALL_DIR
ExecStart=$CARGO_BIN run --release ExecStart=$INSTALL_DIR/target/release/sentryx-server
Restart=on-failure Restart=on-failure
[Install] [Install]
WantedBy=default.target WantedBy=multi-user.target
EOF EOF
# Step 3: Reload systemd, enable and start service # Reload systemd and enable service
echo "Reloading user systemd daemon..." sudo systemctl daemon-reload
systemctl --user daemon-reexec sudo systemctl enable --now "$SERVICE_NAME.service"
systemctl --user daemon-reload
echo "Enabling and starting the service..." echo "Done! Check service with: sudo systemctl status $SERVICE_NAME"
systemctl --user enable --now "$SERVICE_NAME.service"
echo "Installation complete. Use 'systemctl --user status $SERVICE_NAME' to check the service status."
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
set -e
SERVICE_NAME="sentryx-server"
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
INSTALL_DIR="$HOME/sentryx-server" # Make sure this matches your install script
echo "Stopping and disabling systemd service..."
sudo systemctl stop "$SERVICE_NAME.service" || true
sudo systemctl disable "$SERVICE_NAME.service" || true
echo "Removing systemd service file..."
sudo rm -f "$SERVICE_FILE"
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
echo "Removing installation directory..."
rm -rf "$INSTALL_DIR"
rm -rf "${INSTALL_DIR}-backup"
echo "Uninstall complete."