Adds install script and init scripts

main
Yasen Pramatarov 2024-10-02 19:21:58 +03:00
parent 5d346bd01e
commit 78235f057b
4 changed files with 121 additions and 1 deletions

View File

@ -15,6 +15,9 @@ All notable changes to this project will be documented in this file.
### Added ### Added
- Removed PHP version - Removed PHP version
- Added support for HTTPS - Added support for HTTPS
- Added SysV init script
- Added Systemd service file
- Added installation script
--- ---
@ -31,5 +34,5 @@ All notable changes to this project will be documented in this file.
- New version in folder "go", written in Go - New version in folder "go", written in Go
- Added endpoints for /nginx, /prosody, /jicofo, /jvb, /jibri - Added endpoints for /nginx, /prosody, /jicofo, /jvb, /jibri
- Added a config file and default values - Added a config file and default values
- Initial vesion of a build script - Initial version of a build script
- Works with JWT tokens - Works with JWT tokens

27
doc/install.sh 100755
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
###
# Jilo Agent installation script
#
# Description: Installation script for Jilo Agent
# Author: Yasen Pramatarov
# License: GPLv2
# Project URL: https://lindeas.com/jilo
# Year: 2024
# Version: 0.1
#
###
# systemV
cp jilo-agent.init /etc/init.d/jilo-agent
chmod +x /etc/init.d/jilo-agent
update-rc.d jilo-agent defaults
# systemd
cp jilo-agent.service /lib/systemd/system/jilo-agent.service
systemctl daemon-reload
systemctl enable jilo-agent.service
systemctl start jilo-agent.service
# compatibility with sysV
sudo ln -s /lib/systemd/system/jilo-agent.service /etc/init.d/jilo-agent

View File

@ -0,0 +1,76 @@
#!/bin/bash
# /etc/init.d/jilo-agent
# Init script for Jilo Agent
### BEGIN INIT INFO
# Provides: jilo-agent
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the Jilo Agent service
# Description: This script starts and stops the Jilo Agent service.
### END INIT INFO
AGENT_PATH="/usr/local/bin/jilo-agent"
CONFIG_FILE="/usr/local/etc/jilo-agent.conf"
AGENT_NAME="Jilo Agent"
AGENT_PID="/var/run/jilo-agent.pid"
LOG_FILE="/var/log/jilo-agent.log"
# Function to start the jilo agent
start_agent() {
if [ -f "$AGENT_PID" ]; then
echo "$AGENT_NAME is already running."
else
echo "Starting $AGENT_NAME..."
nohup $AGENT_PATH -c $CONFIG_FILE > $LOG_FILE 2>&1 &
echo $! > "$AGENT_PID"
echo "$AGENT_NAME started."
fi
}
# Function to stop the jilo agent
stop_agent() {
if [ ! -f "$AGENT_PID" ]; then
echo "$AGENT_NAME is not running."
else
echo "Stopping $AGENT_NAME..."
kill -9 $(cat "$AGENT_PID") && rm -f "$AGENT_PID"
echo "$AGENT_NAME stopped."
fi
}
# Function to restart the jilo agent
restart_agent() {
echo "Restarting $AGENT_NAME..."
stop_agent
sleep 1
start_agent
}
# Check for the first argument
case "$1" in
start)
start_agent
;;
stop)
stop_agent
;;
restart)
restart_agent
;;
status)
if [ -f "$AGENT_PID" ]; then
echo "$AGENT_NAME is running with PID $(cat $AGENT_PID)."
else
echo "$AGENT_NAME is not running."
fi
;;
*)
echo "Usage: /etc/init.d/agent {start|stop|restart|status}"
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,14 @@
[Unit]
Description=Jilo Agent Service
After=network.target
[Service]
ExecStart=/usr/local/bin/jilo-agent -c /usr/local/etc/jilo-agent.conf
PIDFile=/run/jilo-agent.pid
Restart=always
SyslogIdentifier=jilo-agent
User=root
Group=root
[Install]
WantedBy=multi-user.target