updated install script and uninstall script
This commit is contained in:
@@ -5,3 +5,12 @@ The server handler for the sentryx control panel
|
|||||||
```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
@@ -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."
|
|
||||||
|
|||||||
@@ -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."
|
||||||
Reference in New Issue
Block a user