Fixes the install script
parent
78235f057b
commit
a49f16c584
|
@ -12,16 +12,68 @@
|
|||
#
|
||||
###
|
||||
|
||||
# systemV
|
||||
cp jilo-agent.init /etc/init.d/jilo-agent
|
||||
|
||||
# Paths to init and systemd service files
|
||||
SYSVINIT_SCRIPT="./jilo-agent.init"
|
||||
SYSTEMD_SERVICE="./jilo-agent.service"
|
||||
UPSTART_CONF="./jilo-agent.conf"
|
||||
|
||||
# Function to install the SysVinit script
|
||||
install_sysvinit() {
|
||||
|
||||
echo "Detected SysVinit. Installing init script..."
|
||||
cp "$SYSVINIT_SCRIPT" /etc/init.d/jilo-agent
|
||||
chmod +x /etc/init.d/jilo-agent
|
||||
|
||||
# for Debian/Ubuntu
|
||||
if command -v update-rc.d >/dev/null 2>&1; then
|
||||
update-rc.d jilo-agent defaults
|
||||
|
||||
# systemd
|
||||
cp jilo-agent.service /lib/systemd/system/jilo-agent.service
|
||||
# for RedHat/CentOS/Fedora
|
||||
elif command -v chkconfig >/dev/null 2>&1; then
|
||||
chkconfig --add jilo-agent
|
||||
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-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
|
||||
sudo ln -s /etc/systemd/system/jilo-agent.service /etc/init.d/jilo-agent
|
||||
|
||||
# starting the agent
|
||||
systemctl start jilo-agent.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-agent.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
|
||||
|
|
Loading…
Reference in New Issue