mirror of
https://github.com/YunoHost-Apps/restic_ynh.git
synced 2024-09-03 20:16:22 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
6891b390ed
commit
425cc99eb3
8 changed files with 102 additions and 108 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
*.sw*
|
||||
.vagrant
|
||||
*~
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -18,7 +18,8 @@ admindoc = "https://restic.readthedocs.io/en/latest/"
|
|||
code = "https://github.com/restic/restic"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = "not_relevant"
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
RESTIC_VERSION="0.16.2"
|
||||
|
||||
systemd_services_suffixes=( "" "_check" "_check_read_data" )
|
||||
|
||||
|
||||
_gen_and_save_public_key() {
|
||||
public_key=""
|
||||
|
||||
|
@ -20,7 +19,7 @@ _gen_and_save_public_key() {
|
|||
public_key=$(cat "$private_key.pub")
|
||||
fi
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=public_key --value="$public_key"
|
||||
ynh_app_setting_set --key=public_key --value="$public_key"
|
||||
}
|
||||
|
||||
_set_ssh_config() {
|
||||
|
@ -42,14 +41,13 @@ EOCONF
|
|||
|
||||
}
|
||||
|
||||
|
||||
#=================================================
|
||||
# COMMON HELPERS
|
||||
#=================================================
|
||||
|
||||
_ynh_add_config_j2() {
|
||||
_ynh_config_add_j2() {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=tdv
|
||||
#REMOVEME? local legacy_args=tdv
|
||||
local -A args_array=([t]=template= [d]=destination=)
|
||||
local template
|
||||
local destination
|
||||
|
@ -62,10 +60,10 @@ _ynh_add_config_j2() {
|
|||
elif [ -f "$template" ]; then
|
||||
template_path=$template
|
||||
else
|
||||
ynh_die --message="The provided template $template doesn't exist"
|
||||
ynh_die "The provided template $template doesn't exist"
|
||||
fi
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$destination"
|
||||
ynh_backup_if_checksum_is_different "$destination"
|
||||
|
||||
# Make sure to set the permissions before we copy the file
|
||||
# This is to cover a case where an attacker could have
|
||||
|
@ -75,9 +73,9 @@ _ynh_add_config_j2() {
|
|||
chown root:root $destination
|
||||
chmod 640 $destination
|
||||
|
||||
ynh_render_template "$template_path" "$destination"
|
||||
ynh_config_add --jinja "$template_path" "$destination"
|
||||
|
||||
_ynh_apply_default_permissions $destination
|
||||
|
||||
ynh_store_file_checksum --file="$destination"
|
||||
ynh_store_file_checksum "$destination"
|
||||
}
|
||||
|
|
|
@ -8,36 +8,33 @@
|
|||
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_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
for suffix in "${systemd_services_suffixes[@]}"; do
|
||||
ynh_backup --src_path="/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app$suffix.service"
|
||||
ynh_backup "/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_backup "/etc/systemd/system/$app$suffix.service"
|
||||
done
|
||||
|
||||
ynh_backup --src_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_backup --src_path="/etc/sudoers.d/$app"
|
||||
ynh_backup "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_backup "/etc/sudoers.d/$app"
|
||||
|
||||
ynh_backup --src_path="/root/.ssh/id_${app}_ed25519"
|
||||
ynh_backup --src_path="/root/.ssh/id_${app}_ed25519.pub"
|
||||
ynh_backup "/root/.ssh/id_${app}_ed25519"
|
||||
ynh_backup "/root/.ssh/id_${app}_ed25519.pub"
|
||||
# FIXME: uh do we really want to backup it all?
|
||||
ynh_backup --src_path="/root/.ssh/config"
|
||||
ynh_backup "/root/.ssh/config"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -12,12 +12,12 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
|
||||
# passwords aren't saved by default
|
||||
ynh_app_setting_set --app=$app --key=passphrase --value="$passphrase"
|
||||
ynh_app_setting_set --key=passphrase --value="$passphrase"
|
||||
|
||||
#=================================================
|
||||
# INSTALL RESTIC
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Restic..." --weight=7
|
||||
ynh_script_progression "Installing Restic..."
|
||||
|
||||
ynh_setup_source --source_id=main --dest_dir="$install_dir"
|
||||
chmod +x "$install_dir/restic"
|
||||
|
@ -29,63 +29,61 @@ _set_ssh_config
|
|||
#=================================================
|
||||
# SETUP THE BACKUP METHOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up backup method..." --weight=1
|
||||
ynh_script_progression "Setting up backup method..."
|
||||
|
||||
mkdir -p /etc/yunohost/hooks.d/backup
|
||||
mkdir -p /etc/yunohost/hooks.d/backup_method
|
||||
mkdir -p /usr/share/yunohost/backup_method
|
||||
|
||||
## Backup method
|
||||
_ynh_add_config_j2 --template="backup_method.j2" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
_ynh_config_add_j2 --template="backup_method.j2" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
_ynh_add_config_j2 --template="backup-with-restic.j2" --destination="$install_dir/backup-with-restic"
|
||||
_ynh_config_add_j2 --template="backup-with-restic.j2" --destination="$install_dir/backup-with-restic"
|
||||
chmod u+x "$install_dir/backup-with-restic"
|
||||
|
||||
## Check method
|
||||
_ynh_add_config_j2 --template="check_method.j2" --destination="$install_dir/check_method_restic"
|
||||
_ynh_config_add_j2 --template="check_method.j2" --destination="$install_dir/check_method_restic"
|
||||
|
||||
_ynh_add_config_j2 --template="check-restic.j2" --destination="$install_dir/check-restic"
|
||||
_ynh_config_add_j2 --template="check-restic.j2" --destination="$install_dir/check-restic"
|
||||
chmod u+x "$install_dir/check-restic"
|
||||
|
||||
## Backup log script
|
||||
_ynh_add_config_j2 --template="restic_log.j2" --destination="$install_dir/restic_log"
|
||||
_ynh_config_add_j2 --template="restic_log.j2" --destination="$install_dir/restic_log"
|
||||
chmod u+x "$install_dir/restic_log"
|
||||
|
||||
# Check log script
|
||||
_ynh_add_config_j2 --template="restic_check_log.j2" --destination="$install_dir/restic_check_log"
|
||||
_ynh_config_add_j2 --template="restic_check_log.j2" --destination="$install_dir/restic_check_log"
|
||||
chmod u+x "$install_dir/restic_check_log"
|
||||
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Systemd services and timers
|
||||
for suffix in "${systemd_services_suffixes[@]}"; do
|
||||
ynh_add_systemd_config --service="$app$suffix" --template="systemd$suffix.service"
|
||||
_ynh_add_config_j2 --template="systemd$suffix.timer.j2" --destination="/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_systemd_action --service_name="${app}$suffix.service" --action="disable"
|
||||
ynh_config_add_systemd --service="$app$suffix" --template="systemd$suffix.service"
|
||||
_ynh_config_add_j2 --template="systemd$suffix.timer.j2" --destination="/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_systemctl --service="${app}$suffix.service" --action="disable"
|
||||
systemctl enable --quiet "${app}$suffix.timer"
|
||||
ynh_systemd_action --service_name="${app}$suffix.timer" --action="start"
|
||||
ynh_systemctl --service="${app}$suffix.timer" --action="start"
|
||||
|
||||
yunohost service add "$app$suffix" --description="Restic backup program ($app$suffix)" \
|
||||
--test_status="systemctl show $app$suffix.service -p ActiveState --value | grep -v failed"
|
||||
done
|
||||
|
||||
ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
chown root:root "/etc/sudoers.d/$app"
|
||||
|
||||
ynh_use_logrotate --logfile="/var/log/restic_backup_${app}.log"
|
||||
ynh_use_logrotate --logfile="/var/log/restic_backup_${app}.err"
|
||||
ynh_use_logrotate --logfile="/var/log/restic_check_${app}.log"
|
||||
ynh_use_logrotate --logfile="/var/log/restic_check_${app}.err"
|
||||
ynh_config_add --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root:root "/etc/sudoers.d/$app"
|
||||
|
||||
ynh_config_add_logrotate "/var/log/restic_backup_${app}.log"
|
||||
ynh_config_add_logrotate "/var/log/restic_backup_${app}.err"
|
||||
ynh_config_add_logrotate "/var/log/restic_check_${app}.log"
|
||||
ynh_config_add_logrotate "/var/log/restic_check_${app}.err"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -7,35 +7,34 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# Systemd services and timers
|
||||
for suffix in "${systemd_services_suffixes[@]}"; do
|
||||
if ynh_exec_warn_less yunohost service status "$app_suffix" >/dev/null; then
|
||||
if ynh_hide_warnings yunohost service status "$app_suffix" >/dev/null; then
|
||||
yunohost service remove "$app_suffix"
|
||||
fi
|
||||
ynh_systemd_action --service_name="$app$suffix.timer" --action="stop"
|
||||
ynh_systemd_action --service_name="$app$suffix.timer" --action="disable"
|
||||
ynh_remove_systemd_config --service="$app$suffix"
|
||||
ynh_secure_remove "/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_systemctl --service="$app$suffix.timer" --action="stop"
|
||||
ynh_systemctl --service="$app$suffix.timer" --action="disable"
|
||||
ynh_config_remove_systemd"$app$suffix"
|
||||
ynh_safe_rm "/etc/systemd/system/$app$suffix.timer"
|
||||
done
|
||||
|
||||
# Remove the app-specific logrotate config
|
||||
ynh_remove_logrotate
|
||||
ynh_config_remove_logrotate
|
||||
|
||||
# Remove sudoers
|
||||
rm "/etc/sudoers.d/$app"
|
||||
|
||||
ynh_secure_remove "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_safe_rm "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
#=================================================
|
||||
# REMOVE SSH CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing ssh config"
|
||||
ynh_script_progression "Removing ssh config"
|
||||
|
||||
sed -e "/begin ${app}/,/end ${app}/{/.*/d}" /root/.ssh/config -i || true
|
||||
|
||||
|
@ -43,4 +42,4 @@ sed -e "/begin ${app}/,/end ${app}/{/.*/d}" /root/.ssh/config -i || true
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed"
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -11,47 +11,46 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
|
||||
# ynh_setup_source --source_id=main --dest_dir="$install_dir"
|
||||
# chmod +x "$install_dir/restic"
|
||||
|
||||
_gen_and_save_public_key
|
||||
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
|
||||
#=================================================
|
||||
# ACTIVATE BACKUP METHODS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up backup method..." --weight=1
|
||||
ynh_script_progression "Setting up backup method..."
|
||||
|
||||
mkdir -p /etc/yunohost/hooks.d/backup
|
||||
mkdir -p /etc/yunohost/hooks.d/backup_method
|
||||
mkdir -p /usr/share/yunohost/backup_method
|
||||
|
||||
ynh_restore_file --origin_path="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
ynh_restore "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/sudoers.d/$app"
|
||||
chown root:root "/etc/sudoers.d/$app"
|
||||
ynh_restore "/etc/sudoers.d/$app"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root:root "/etc/sudoers.d/$app"
|
||||
|
||||
ynh_restore_file --origin_path="/root/.ssh/id_${app}_ed25519"
|
||||
ynh_restore_file --origin_path="/root/.ssh/id_${app}_ed25519.pub"
|
||||
ynh_restore "/root/.ssh/id_${app}_ed25519"
|
||||
ynh_restore "/root/.ssh/id_${app}_ed25519.pub"
|
||||
# FIXME: restore the .ssh/config instead?
|
||||
_set_ssh_config
|
||||
|
||||
for suffix in "${systemd_services_suffixes[@]}"; do
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/$app$suffix.service"
|
||||
ynh_restore "/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_restore "/etc/systemd/system/$app$suffix.service"
|
||||
systemctl enable --quiet "$app$suffix.timer"
|
||||
ynh_systemd_action --service_name="$app$suffix.timer" --action="start"
|
||||
ynh_systemctl --service="$app$suffix.timer" --action="start"
|
||||
|
||||
yunohost service add "$app$suffix" --description="Restic backup program ($app$suffix)" \
|
||||
--test_status="systemctl show $app$suffix.service -p ActiveState --value | grep -v failed"
|
||||
|
@ -61,4 +60,4 @@ done
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -10,35 +10,35 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
if grep "${app}.timer" /etc/yunohost/services.yml > /dev/null ; then
|
||||
yunohost service remove $app.timer
|
||||
ynh_systemd_action --service="$app" --action="stop"
|
||||
ynh_systemd_action --service="$app.timer" --action="disable"
|
||||
ynh_systemctl --action="stop"
|
||||
ynh_systemctl --service="$app.timer" --action="disable"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
if [ -f "/usr/local/bin/backup-with-${app}" ]; then
|
||||
ynh_delete_file_checksum --file="/usr/local/bin/backup-with-${app}"
|
||||
ynh_secure_remove --file="/usr/local/bin/backup-with-${app}"
|
||||
ynh_delete_file_checksum "/usr/local/bin/backup-with-${app}"
|
||||
ynh_safe_rm "/usr/local/bin/backup-with-${app}"
|
||||
fi
|
||||
|
||||
if [ -f "/usr/local/bin/$app" ]; then
|
||||
ynh_secure_remove --file="/usr/local/bin/$app"
|
||||
ynh_safe_rm "/usr/local/bin/$app"
|
||||
fi
|
||||
|
||||
if [ -d "/opt/yunohost/$app" ]; then
|
||||
mv "/opt/yunohost/$app/"* "$install_dir"
|
||||
ynh_delete_file_checksum --file="/opt/yunohost/$app/check-restic"
|
||||
ynh_delete_file_checksum --file="/opt/yunohost/$app/check_method_restic"
|
||||
ynh_delete_file_checksum --file="/opt/yunohost/$app/restic_check_log_restic"
|
||||
ynh_delete_file_checksum --file="/opt/yunohost/$app/restic_log_restic"
|
||||
ynh_secure_remove --file="/opt/yunohost/$app/"
|
||||
ynh_delete_file_checksum "/opt/yunohost/$app/check-restic"
|
||||
ynh_delete_file_checksum "/opt/yunohost/$app/check_method_restic"
|
||||
ynh_delete_file_checksum "/opt/yunohost/$app/restic_check_log_restic"
|
||||
ynh_delete_file_checksum "/opt/yunohost/$app/restic_log_restic"
|
||||
ynh_safe_rm "/opt/yunohost/$app/"
|
||||
fi
|
||||
|
||||
# old versions did not have delimiters in ~/.ssh/config making removal in
|
||||
|
@ -53,7 +53,7 @@ fi
|
|||
#=================================================
|
||||
# INSTALL RESTIC
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Restic..." --weight=7
|
||||
ynh_script_progression "Installing Restic..."
|
||||
|
||||
ynh_setup_source --source_id=main --dest_dir="$install_dir"
|
||||
chmod +x "$install_dir/restic"
|
||||
|
@ -69,62 +69,61 @@ fi
|
|||
#=================================================
|
||||
# SETUP THE BACKUP METHOD
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up backup method..." --weight=1
|
||||
ynh_script_progression "Setting up backup method..."
|
||||
|
||||
mkdir -p /etc/yunohost/hooks.d/backup
|
||||
mkdir -p /etc/yunohost/hooks.d/backup_method
|
||||
mkdir -p /usr/share/yunohost/backup_method
|
||||
|
||||
## Backup method
|
||||
_ynh_add_config_j2 --template="backup_method.j2" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
_ynh_config_add_j2 --template="backup_method.j2" --destination="/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
chmod go=--- "/etc/yunohost/hooks.d/backup_method/05-${app}_app"
|
||||
|
||||
_ynh_add_config_j2 --template="backup-with-restic.j2" --destination="$install_dir/backup-with-restic"
|
||||
_ynh_config_add_j2 --template="backup-with-restic.j2" --destination="$install_dir/backup-with-restic"
|
||||
chmod u+x "$install_dir/backup-with-restic"
|
||||
|
||||
## Check method
|
||||
_ynh_add_config_j2 --template="check_method.j2" --destination="$install_dir/check_method_restic"
|
||||
_ynh_config_add_j2 --template="check_method.j2" --destination="$install_dir/check_method_restic"
|
||||
|
||||
_ynh_add_config_j2 --template="check-restic.j2" --destination="$install_dir/check-restic"
|
||||
_ynh_config_add_j2 --template="check-restic.j2" --destination="$install_dir/check-restic"
|
||||
chmod u+x "$install_dir/check-restic"
|
||||
|
||||
## Backup log script
|
||||
_ynh_add_config_j2 --template="restic_log.j2" --destination="$install_dir/restic_log"
|
||||
_ynh_config_add_j2 --template="restic_log.j2" --destination="$install_dir/restic_log"
|
||||
chmod u+x "$install_dir/restic_log"
|
||||
|
||||
# Check log script
|
||||
_ynh_add_config_j2 --template="restic_check_log.j2" --destination="$install_dir/restic_check_log"
|
||||
_ynh_config_add_j2 --template="restic_check_log.j2" --destination="$install_dir/restic_check_log"
|
||||
chmod u+x "$install_dir/restic_check_log"
|
||||
|
||||
chown -R "$app:$app" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "$install_dir"
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Systemd services and timers
|
||||
for suffix in "${systemd_services_suffixes[@]}"; do
|
||||
ynh_add_systemd_config --service="$app$suffix" --template="systemd$suffix.service"
|
||||
_ynh_add_config_j2 --template="systemd$suffix.timer.j2" --destination="/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_systemd_action --service_name="${app}$suffix.service" --action="disable"
|
||||
ynh_config_add_systemd --service="$app$suffix" --template="systemd$suffix.service"
|
||||
_ynh_config_add_j2 --template="systemd$suffix.timer.j2" --destination="/etc/systemd/system/$app$suffix.timer"
|
||||
ynh_systemctl --service="${app}$suffix.service" --action="disable"
|
||||
systemctl enable --quiet "${app}$suffix.timer"
|
||||
ynh_systemd_action --service_name="${app}$suffix.timer" --action="start"
|
||||
ynh_systemctl --service="${app}$suffix.timer" --action="start"
|
||||
|
||||
yunohost service add "$app$suffix" --description="Restic backup program ($app$suffix)" \
|
||||
--test_status="systemctl show $app$suffix.service -p ActiveState --value | grep -v failed"
|
||||
done
|
||||
|
||||
ynh_add_config --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
chown root:root "/etc/sudoers.d/$app"
|
||||
ynh_config_add --template="sudoer" --destination="/etc/sudoers.d/$app"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root:root "/etc/sudoers.d/$app"
|
||||
|
||||
ynh_use_logrotate --logfile="/var/log/restic_backup_${app}.log"
|
||||
ynh_use_logrotate --logfile="/var/log/restic_backup_${app}.err"
|
||||
ynh_use_logrotate --logfile="/var/log/restic_check_${app}.log"
|
||||
ynh_use_logrotate --logfile="/var/log/restic_check_${app}.err"
|
||||
ynh_config_add_logrotate "/var/log/restic_backup_${app}.log"
|
||||
ynh_config_add_logrotate "/var/log/restic_backup_${app}.err"
|
||||
ynh_config_add_logrotate "/var/log/restic_check_${app}.log"
|
||||
ynh_config_add_logrotate "/var/log/restic_check_${app}.err"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed"
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue