Adds build and install scripts, init scripts
parent
21091a2a04
commit
05e7b43a37
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###
|
||||
# Jilo Server building script
|
||||
#
|
||||
# Description: Building script for Jilo Server
|
||||
# Author: Yasen Pramatarov
|
||||
# License: GPLv2
|
||||
# Project URL: https://lindeas.com/jilo
|
||||
# Year: 2025
|
||||
# Version: 0.1
|
||||
#
|
||||
# requirements:
|
||||
# - go
|
||||
# - upx
|
||||
###
|
||||
|
||||
#CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o jilo-server ../main.go
|
||||
CGO_ENABLED=1 go build -trimpath -ldflags="-s -w" -o jilo-server ../main.go
|
||||
upx --best --lzma -o jilo-server-upx jilo-server
|
||||
mv jilo-server-upx jilo-server
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###
|
||||
# Jilo Server installation script
|
||||
#
|
||||
# Description: Installation script for Jilo Server
|
||||
# Author: Yasen Pramatarov
|
||||
# License: GPLv2
|
||||
# Project URL: https://lindeas.com/jilo
|
||||
# Year: 2025
|
||||
# Version: 0.1
|
||||
#
|
||||
###
|
||||
|
||||
|
||||
# Paths to init and systemd service files
|
||||
SYSVINIT_SCRIPT="./jilo-server.init"
|
||||
SYSTEMD_SERVICE="./jilo-server.service"
|
||||
UPSTART_CONF="./jilo-server.conf"
|
||||
|
||||
# Function to install the SysVinit script
|
||||
install_sysvinit() {
|
||||
|
||||
echo "Detected SysVinit. Installing init script..."
|
||||
cp "$SYSVINIT_SCRIPT" /etc/init.d/jilo-server
|
||||
chmod +x /etc/init.d/jilo-server
|
||||
|
||||
# for Debian/Ubuntu
|
||||
if command -v update-rc.d >/dev/null 2>&1; then
|
||||
update-rc.d jilo-server defaults
|
||||
|
||||
# for RedHat/CentOS/Fedora
|
||||
elif command -v chkconfig >/dev/null 2>&1; then
|
||||
chkconfig --add jilo-server
|
||||
fi
|
||||
|
||||
echo "SysVinit script installed."
|
||||
}
|
||||
|
||||
# Function to install the systemd service file
|
||||
install_systemd() {
|
||||
|
||||
echo "Detected systemd. Installing systemd service file..."
|
||||
cp "$SYSTEMD_SERVICE" /etc/systemd/system/jilo-server.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable jilo-server.service
|
||||
|
||||
# compatibility with sysV
|
||||
sudo ln -s /etc/systemd/system/jilo-server.service /etc/init.d/jilo-server
|
||||
|
||||
# starting the server
|
||||
systemctl start jilo-server.service
|
||||
|
||||
echo "Systemd service file installed."
|
||||
}
|
||||
|
||||
# Function to install the Upstart configuration
|
||||
install_upstart() {
|
||||
|
||||
echo "Detected Upstart. Installing Upstart configuration..."
|
||||
cp "$UPSTART_CONF" /etc/init/jilo-server.conf
|
||||
initctl reload-configuration
|
||||
|
||||
echo "Upstart configuration installed."
|
||||
}
|
||||
|
||||
# Detect the init system
|
||||
if [[ `readlink /proc/1/exe` == */systemd ]]; then
|
||||
install_systemd
|
||||
|
||||
elif [[ -f /sbin/init && `/sbin/init --version 2>/dev/null` =~ upstart ]]; then
|
||||
install_upstart
|
||||
|
||||
else
|
||||
install_sysvinit
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -1,5 +1,9 @@
|
|||
##
|
||||
# configuration file for Jilo Server
|
||||
##
|
||||
|
||||
# database location
|
||||
database_path: "./jilo-server.db"
|
||||
database_path: "/usr/local/etc/jilo-server.db"
|
||||
|
||||
# health check
|
||||
health_check_enabled: true
|
|
@ -0,0 +1,76 @@
|
|||
#!/bin/bash
|
||||
# /etc/init.d/jilo-server
|
||||
# Init script for Jilo Server
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: jilo-server
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start the Jilo Server service
|
||||
# Description: This script starts and stops the Jilo Server service.
|
||||
### END INIT INFO
|
||||
|
||||
SERVER_PATH="/usr/local/bin/jilo-server"
|
||||
CONFIG_FILE="/usr/local/etc/jilo-server.conf"
|
||||
SERVER_NAME="Jilo Agent"
|
||||
SERVER_PID="/var/run/jilo-server.pid"
|
||||
LOG_FILE="/var/log/jilo-server.log"
|
||||
|
||||
# Function to start the jilo server
|
||||
start_server() {
|
||||
if [ -f "$SERVER_PID" ]; then
|
||||
echo "$SERVER_NAME is already running."
|
||||
else
|
||||
echo "Starting $SERVER_NAME..."
|
||||
nohup $SERVER_PATH -c $CONFIG_FILE > $LOG_FILE 2>&1 &
|
||||
echo $! > "$SERVER_PID"
|
||||
echo "$SERVER_NAME started."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to stop the jilo server
|
||||
stop_server() {
|
||||
if [ ! -f "$SERVER_PID" ]; then
|
||||
echo "$SERVER_NAME is not running."
|
||||
else
|
||||
echo "Stopping $SERVER_NAME..."
|
||||
kill -9 $(cat "$SERVER_PID") && rm -f "$SERVER_PID"
|
||||
echo "$SERVER_NAME stopped."
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to restart the jilo server
|
||||
restart_server() {
|
||||
echo "Restarting $SERVER_NAME..."
|
||||
stop_server
|
||||
sleep 1
|
||||
start_server
|
||||
}
|
||||
|
||||
# Check for the first argument
|
||||
case "$1" in
|
||||
start)
|
||||
start_server
|
||||
;;
|
||||
stop)
|
||||
stop_server
|
||||
;;
|
||||
restart)
|
||||
restart_server
|
||||
;;
|
||||
status)
|
||||
if [ -f "$SERVER_PID" ]; then
|
||||
echo "$SERVER_NAME is running with PID $(cat $SERVER_PID)."
|
||||
else
|
||||
echo "$SERVER_NAME is not running."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: /etc/init.d/jilo-server {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Jilo Server Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/jilo-server -c /usr/local/etc/jilo-server.conf
|
||||
PIDFile=/run/jilo-server.pid
|
||||
Restart=on-failure
|
||||
SyslogIdentifier=jilo-server
|
||||
User=root
|
||||
Group=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue