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

Initial packaging

This commit is contained in:
tituspijean 2024-02-02 20:07:47 +01:00
commit b4418b142a
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
8 changed files with 248 additions and 0 deletions

5
conf/watchdog.conf Normal file
View file

@ -0,0 +1,5 @@
# This file has been generated by watchdog_ynh
# If your device hardware watchdog is not /dev/watchdog, feel free to alter it here and report your findings to YunoHost!
watchdog-device = /dev/watchdog
watchdog-timeout = 15
max-load-1 = 24

4
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1,4 @@
A Watchdog device makes sure that your server is still running.
The included service will regularly write to that watchdog device. If it stops doing so, most likely due to a freeze, then the server will be rebooted.
This Watchdog better (only?) works if you have a hardware watchdog integrated in your server. It has only been tested on Raspberry Pi so far.

33
manifest.toml Normal file
View file

@ -0,0 +1,33 @@
packaging_format = 2
id = "watchdog"
name = "Watchdog"
description.en = "Automatically reboot your server in case of freeze"
description.fr = "Redémarre automatiquement votre serveur en cas de plantage"
version = "5.16~ynh1"
maintainers = ["tituspijean"]
[upstream]
license = "GPL-2.0-or-later"
code = "https://sourceforge.net/projects/watchdog/"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = false
ldap = "not_relevant"
sso = "not_relevant"
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[resources]
[resources.apt]
packages = "watchdog"

25
scripts/backup Normal file
View file

@ -0,0 +1,25 @@
#!/bin/bash
#### App file generated with YoloGen, the YunoHost app generator, version .
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="/etc/watchdog.conf"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

59
scripts/install Normal file
View file

@ -0,0 +1,59 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INSTALL DEPENDENCIES
#=================================================
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..."
reboot_required=false
if [[ $(grep -ic "Raspberry Pi" /proc/cpuinfo) -ge 1 && $(grep -ic "dtparam=watchdog=on" /boot/config.txt) -eq 0 ]]; then
echo "dtparam=watchdog=on" >> /boot/config.txt
reboot_required=true
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"
#=================================================
# END OF SCRIPT
#=================================================
if [ reboot_required = true ]; then
echo "Your device boot configuration has been updated to enable the hardware watchdog. Please reboot it." > ../doc/POST_INSTALL.md
else
rm ../doc/POST_INSTALL.md
fi
ynh_script_progression --message="Installation of $app completed" --last

37
scripts/remove Normal file
View file

@ -0,0 +1,37 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
# REMOVE SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
fi
ynh_remove_systemd_config
ynh_remove_nginx_config
# Remove other various files specific to the app... such as :
ynh_secure_remove --file="/var/log/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

28
scripts/restore Normal file
View file

@ -0,0 +1,28 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/watchdog.conf"
systemctl enable $app.service --quiet
yunohost service add $app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

57
scripts/upgrade Normal file
View file

@ -0,0 +1,57 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop"
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..."
yunohost service add $app
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a 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 a systemd service..."
ynh_systemd_action --service_name=$app --action="start"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last