mirror of
https://github.com/YunoHost-Apps/watchdog_ynh.git
synced 2024-06-22 05:42:53 +02:00
62 lines
2.2 KiB
Bash
62 lines
2.2 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# WATCHDOG DEVICE CHECK
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Checking the hardware watchdog device presence..."
|
|
|
|
if [ ! -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
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# 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
|
|
|
|
yunohost service add $app
|
|
|
|
#=================================================
|
|
# APP INITIAL CONFIGURATION
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding app's configuration file..."
|
|
|
|
ynh_add_config --template="watchdog.conf" --destination="/etc/watchdog.conf"
|
|
|
|
chmod 400 "/etc/watchdog.conf"
|
|
chown root: "/etc/watchdog.conf"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting app's systemd service..."
|
|
|
|
# Enable and start a systemd service
|
|
systemctl enable $app.service --quiet
|
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|