diff --git a/manifest.toml b/manifest.toml index 27e9948..24601a2 100644 --- a/manifest.toml +++ b/manifest.toml @@ -2,6 +2,7 @@ packaging_format = 2 id = "cjdns" name = "Cjdns" + description.en = "Encrypted IPv6 network" description.fr = "Réseau IPv6 chiffré" diff --git a/scripts/backup b/scripts/backup new file mode 100755 index 0000000..cbdac6b --- /dev/null +++ b/scripts/backup @@ -0,0 +1,34 @@ +#!/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 + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$install_dir" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." \ No newline at end of file diff --git a/scripts/restore b/scripts/restore new file mode 100755 index 0000000..6b548fe --- /dev/null +++ b/scripts/restore @@ -0,0 +1,55 @@ +#!/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 THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 + +ynh_restore_file --origin_path="$install_dir" + +# $install_dir will automatically be initialized with some decent +# permissions by default ... however, you may need to recursively reapply +# ownership to all files such as after the ynh_setup_source step +chown -R $app:www-data "$install_dir" + +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$data_dir" --not_mandatory + +# (Same as for install dir) +chown -R $app:www-data "$data_dir" + +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service --quiet + +yunohost service add $app --description="$app service" --log="/var/log/$app/$app.log" + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Typically you only have either $app or php-fpm but not both at the same time... +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100755 index 0000000..d5ed1aa --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,52 @@ +#!/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 +#================================================= + +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Installing latest version..." --weight=1 + ynh_setup_source --dest_dir="$install_dir" +fi + +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" +chmod +x "$install_dir/cjdroute" + + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Restarting cjdns service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last \ No newline at end of file