1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/watchdog_ynh.git synced 2024-06-22 05:42:53 +02:00
watchdog_ynh/scripts/install

47 lines
1.8 KiB
Bash

#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# WATCHDOG DEVICE CHECK
#=================================================
ynh_script_progression --message="Checking the hardware watchdog device presence..."
# Don't issue this error in CI
if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 0 ] && [ ! -f /dev/watchdog ]; then
ynh_die --message="Your server doesn't seem to have a '/dev/watchdog' device, this certainly means that it has no hardware watchdog device. However, this package is only relevant if such a device exists, we're sorry."
fi
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..."
if [[ $(grep -ic "Raspberry Pi" /proc/cpuinfo) -ge 1 && $(grep -ic "dtparam=watchdog=on" /boot/config.txt) -eq 0 ]]; then
cp /boot/config.txt "/boot/config.bak$(date '+%y%m%dT%H%M%S')"
echo "dtparam=watchdog=on" >> /boot/config.txt
fi
ynh_add_config --template="watchdog.conf" --destination="/etc/watchdog.conf"
chmod 400 "/etc/watchdog.conf"
chown root: "/etc/watchdog.conf"
systemctl enable "$app.service" --quiet
yunohost service add "$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting app's systemd service..."
ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last