added install script and uninstall script
This commit is contained in:
@@ -40,8 +40,11 @@
|
||||
|
||||
## 📚 Table of Contents
|
||||
|
||||
- [📚 Table of Contents](#-table-of-contents)
|
||||
- [About The Project](#about-the-project)
|
||||
- [Built With](#built-with)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Uninstalling](#uninstalling)
|
||||
|
||||
---
|
||||
|
||||
@@ -59,7 +62,18 @@
|
||||
|
||||
## Getting Started
|
||||
|
||||
Not yet :/
|
||||
```bash
|
||||
wget -qO- https://raw.githubusercontent.com/orus-dev/sentryx/refs/heads/master/install.sh | bash
|
||||
```
|
||||
|
||||
## Uninstalling
|
||||
```bash
|
||||
sh $HOME/sentryx-server/uninstall.sh
|
||||
```
|
||||
If that fails
|
||||
```bash
|
||||
wget -qO- https://raw.githubusercontent.com/orus-dev/sentryx/refs/heads/master/uninstall.sh | bash
|
||||
```
|
||||
|
||||
[contributors-shield]: https://img.shields.io/github/contributors/orus-dev/sentryx.svg?style=flat-square&color=blue&label=contributors
|
||||
[contributors-url]: https://github.com/orus-dev/sentryx/graphs/contributors
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
REPO_URL="https://github.com/orus-dev/sentryx.git"
|
||||
INSTALL_DIR="$HOME/sentryx" # expanded
|
||||
SERVICE_NAME="sentryx"
|
||||
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
|
||||
NODE_BIN="$(which node)"
|
||||
RUN_USER="$(whoami)" # change if needed
|
||||
|
||||
# Backup if exists
|
||||
if [ -d "$INSTALL_DIR" ]; then
|
||||
echo "Sentryx already exists, backing up..."
|
||||
rm -rf "$INSTALL_DIR-backup"
|
||||
mv "$INSTALL_DIR" "$INSTALL_DIR-backup"
|
||||
fi
|
||||
|
||||
# Clone as current user
|
||||
git clone "$REPO_URL" "$INSTALL_DIR"
|
||||
|
||||
# Build as current user inside INSTALL_DIR
|
||||
cd $INSTALL_DIR
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
# Create systemd service file with absolute ExecStart path
|
||||
echo "Creating systemd service..."
|
||||
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
||||
[Unit]
|
||||
Description=SentryX Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$RUN_USER
|
||||
WorkingDirectory=$INSTALL_DIR
|
||||
ExecStart=$NODE_BIN "$INSTALL_DIR/node_modules/.bin/next" start
|
||||
Restart=on-failure
|
||||
Environment=NODE_ENV=production
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Reload systemd and enable service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now "$SERVICE_NAME.service"
|
||||
|
||||
echo "Done! Check service with: sudo systemctl status $SERVICE_NAME"
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SERVICE_NAME="sentryx"
|
||||
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
|
||||
INSTALL_DIR="$HOME/sentryx"
|
||||
|
||||
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