updated install script to check for commands
This commit is contained in:
+6
-7
@@ -10,11 +10,11 @@ for cmd in node npm git sudo; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
REPO_URL="https://github.com/orus-dev/sentryx.git"
|
REPO_URL="https://github.com/orus-dev/sentryx.git"
|
||||||
INSTALL_DIR="$HOME/sentryx" # expanded
|
INSTALL_DIR="$HOME/sentryx"
|
||||||
SERVICE_NAME="sentryx"
|
SERVICE_NAME="sentryx"
|
||||||
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
|
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
|
||||||
NODE_BIN="$(which node)"
|
NODE_BIN="$(which node)"
|
||||||
RUN_USER="$(whoami)" # change if needed
|
RUN_USER="$(whoami)"
|
||||||
|
|
||||||
# Backup if exists
|
# Backup if exists
|
||||||
if [ -d "$INSTALL_DIR" ]; then
|
if [ -d "$INSTALL_DIR" ]; then
|
||||||
@@ -26,12 +26,12 @@ fi
|
|||||||
# Clone as current user
|
# Clone as current user
|
||||||
git clone "$REPO_URL" "$INSTALL_DIR"
|
git clone "$REPO_URL" "$INSTALL_DIR"
|
||||||
|
|
||||||
# Build as current user inside INSTALL_DIR
|
# Build as current user
|
||||||
cd $INSTALL_DIR
|
cd "$INSTALL_DIR"
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
# Create systemd service file with absolute ExecStart path
|
# Create systemd service
|
||||||
echo "Creating systemd service..."
|
echo "Creating systemd service..."
|
||||||
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -42,7 +42,7 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=$RUN_USER
|
User=$RUN_USER
|
||||||
WorkingDirectory=$INSTALL_DIR
|
WorkingDirectory=$INSTALL_DIR
|
||||||
ExecStart=$NODE_BIN "$INSTALL_DIR/node_modules/.bin/next" start
|
ExecStart="$NODE_BIN" "$INSTALL_DIR/node_modules/.bin/next" start
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
|
|
||||||
@@ -50,7 +50,6 @@ Environment=NODE_ENV=production
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Reload systemd and enable service
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable --now "$SERVICE_NAME.service"
|
sudo systemctl enable --now "$SERVICE_NAME.service"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user