mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
update
This commit is contained in:
parent
c4ee38a7a9
commit
b7a24107d4
10 changed files with 59 additions and 230 deletions
|
@ -9,7 +9,10 @@
|
|||
#=================================================
|
||||
|
||||
apticron_config="/etc/apticron/apticron.conf"
|
||||
apticron_config_backup="/etc/yunohost/apps/$app/conf/apticron.conf.backup"
|
||||
|
||||
apticron_cron="/etc/cron.d/apticron"
|
||||
apticron_cron_backup="/etc/yunohost/apps/$app/conf/apticron.crond.backup"
|
||||
|
||||
_apticron_set_config() {
|
||||
# If the config file doesn't exist, copy the model
|
||||
|
@ -18,7 +21,7 @@ _apticron_set_config() {
|
|||
fi
|
||||
|
||||
# Create a backup of the config file for the reset action
|
||||
cp "$apticron_config" "/etc/yunohost/apps/$app/conf/apticron.conf.backup"
|
||||
cp "$apticron_config" "$apticron_config_backup"
|
||||
|
||||
ynh_replace_string --match_string="# CUSTOM_SUBJECT=.*" \
|
||||
--replace_string="&\nCUSTOM_SUBJECT=\'[apticron] \$SYSTEM: \$NUM_PACKAGES package update(s)\'" --target_file="$apticron_config"
|
||||
|
@ -26,7 +29,7 @@ _apticron_set_config() {
|
|||
--replace_string="&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" --target_file="$apticron_config"
|
||||
|
||||
# Create a backup of the cron file for the reset action
|
||||
cp "$apticron_cron" "/etc/yunohost/apps/$app/conf/apticron.crond.backup"
|
||||
cp "$apticron_cron" "$apticron_cron_backup"
|
||||
|
||||
# Copy and comment the current cron
|
||||
ynh_replace_string --match_string="^.* root if.*" --replace_string="#&\n&" --target_file="$apticron_cron"
|
||||
|
@ -47,16 +50,17 @@ _apticron_set_config() {
|
|||
}
|
||||
|
||||
_apticron_restore_config() {
|
||||
mv "/etc/yunohost/apps/$app/conf/apticron.conf.backup" "$apticron_config"
|
||||
mv "/etc/yunohost/apps/$app/conf/apticron.crond.backup" "$apticron_cron"
|
||||
mv "$apticron_config_backup" "$apticron_config"
|
||||
mv "$apticron_cron_backup" "$apticron_cron"
|
||||
}
|
||||
|
||||
|
||||
unattended_upgrades_config="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
unattended_upgrades_config_backup="/etc/yunohost/apps/$app/conf/50unattended-upgrades.backup"
|
||||
|
||||
_unattended_upgrades_set_config() {
|
||||
# Make a backup of 50unattended-upgrades
|
||||
cp "$unattended_upgrades_config" "/etc/yunohost/apps/$app/conf/50unattended-upgrades.backup"
|
||||
cp "$unattended_upgrades_config" "$unattended_upgrades_config_backup"
|
||||
|
||||
# Configure upgrade sources
|
||||
# Allow other updates
|
||||
|
@ -89,15 +93,14 @@ _unattended_upgrades_set_config() {
|
|||
# Send mail only if there's an error
|
||||
ynh_replace_string --match_string="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"true\";" --target_file="$unattended_upgrades_config"
|
||||
|
||||
else # "Never"
|
||||
else # "Never"
|
||||
# Comment "Unattended-Upgrade::Mail" if it isn't already commented
|
||||
ynh_replace_string --match_string="^\(Unattended-Upgrade::Mail \)" --replace_string="//\1" --target_file="$unattended_upgrades_config"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
_unattended_upgrades_restore_config() {
|
||||
mv "/etc/yunohost/apps/$app/conf/50unattended-upgrades.backup" "$unattended_upgrades_config"
|
||||
mv "$unattended_upgrades_config_backup" "$unattended_upgrades_config"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -10,26 +10,6 @@
|
|||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
unattended_verbosity=$(ynh_app_setting_get --app=$app --key=unattended_verbosity)
|
||||
upgrade_level="$(ynh_app_setting_get --app=$app --key=upgrade_level)"
|
||||
ynh_update=$(ynh_app_setting_get --app=$app --key=ynh_update)
|
||||
unattended_mail="$(ynh_app_setting_get --app=$app --key=unattended_mail)"
|
||||
previous_apticron=$(ynh_app_setting_get --app=$app --key=previous_apticron)
|
||||
after_apticron=$(ynh_app_setting_get --app=$app --key=after_apticron)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
|
|
|
@ -93,7 +93,7 @@ then
|
|||
# Send mail only if there's an error
|
||||
ynh_replace_string --match_string="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"true\";" --target_file="$config_file"
|
||||
|
||||
else # "Never"
|
||||
else # "Never"
|
||||
# Comment "Unattended-Upgrade::Mail" if it isn't already commented
|
||||
ynh_replace_string --match_string="^\(Unattended-Upgrade::Mail \)" --replace_string="//\1" --target_file="$config_file"
|
||||
fi
|
||||
|
|
|
@ -9,20 +9,6 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
#REMOVEME? ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
|
@ -32,28 +18,17 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# BACKUP UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
# Backup also the backup of the config file
|
||||
ynh_backup --src_path="/etc/apt/50unattended-upgrades.backup"
|
||||
ynh_backup --src_path="$apticron_config"
|
||||
ynh_backup --src_path="$apticron_config_backup"
|
||||
|
||||
#=================================================
|
||||
# BACKUP APT PERIODIC
|
||||
#=================================================
|
||||
ynh_backup --src_path="$apticron_cron"
|
||||
ynh_backup --src_path="$apticron_cron_backup"
|
||||
|
||||
ynh_backup --src_path="$unattended_upgrades_config"
|
||||
ynh_backup --src_path="$unattended_upgrades_config_backup"
|
||||
|
||||
ynh_backup --src_path="/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# BACKUP APTICRON CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/apticron/apticron.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/cron.d/apticron"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -156,7 +156,7 @@ apply_config() {
|
|||
# Send mail only if there's an error
|
||||
ynh_replace_string --match_string="/*\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"true\";" --target_file="$unattended_upgrades_config"
|
||||
|
||||
else # "Never"
|
||||
else # "Never"
|
||||
# Comment "Unattended-Upgrade::Mail"
|
||||
ynh_replace_string --match_string="^\(Unattended-Upgrade::Mail \)" --replace_string="//\1" --target_file="$unattended_upgrades_config"
|
||||
fi
|
||||
|
|
|
@ -41,7 +41,6 @@ ynh_script_progression --message="Configure APT Periodic for Unattended" --weigh
|
|||
|
||||
ynh_add_config --template="../conf/02periodic" --destination="/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,21 +10,14 @@ source _common.sh
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# REMOVE THE APT PERIODIC FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the APT Periodic file..."
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
_apticron_restore_config
|
||||
_unattended_upgrades_restore_config
|
||||
ynh_secure_remove "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# DECONFIGURE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Deconfiguring unattended-upgrades..."
|
||||
|
||||
mv "/etc/apt/50unattended-upgrades.backup" "/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -9,78 +9,21 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading settings..."
|
||||
|
||||
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORE
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=10
|
||||
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
# Restore also the backup config file
|
||||
ynh_restore_file --origin_path="/etc/apt/50unattended-upgrades.backup"
|
||||
ynh_restore_file --origin_path="$apticron_config"
|
||||
ynh_restore_file --origin_path="$apticron_config_backup"
|
||||
|
||||
#=================================================
|
||||
# RESTORE APT PERIODIC
|
||||
#=================================================
|
||||
ynh_restore_file --origin_path="$apticron_cron"
|
||||
ynh_restore_file --origin_path="$apticron_cron_backup"
|
||||
|
||||
ynh_restore_file --origin_path="$unattended_upgrades_config"
|
||||
ynh_restore_file --origin_path="$unattended_upgrades_config_backup"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# RESTORE APTICRON CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/etc/apticron/apticron.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE CRON FILE
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/apticron"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
||||
# Get main domain and buid the url of the admin panel of the app.
|
||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||
|
||||
echo "To modify any option of unattended-upgrades, please have a look to /etc/apt/apt.conf.d/50unattended-upgrades and
|
||||
/etc/apt/apt.conf.d/02periodic
|
||||
Unattended-upgrades will be executed every day at midnight.
|
||||
|
||||
To modify the configuration of apticron, please have a look to /etc/apticron/apticron.conf.
|
||||
Apticron will be executed, depending of the requested configuration at 8 p.m. and 2 a.m. If you want to change this schedule, please have a look to the cron file /etc/cron.d/apticron.
|
||||
|
||||
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|
||||
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
|
||||
|
||||
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/unattended_upgrades_ynh__URL_TAG3__." > mail_to_send
|
||||
|
||||
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=restore
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
114
scripts/upgrade
114
scripts/upgrade
|
@ -17,124 +17,56 @@ upgrade_type=$(ynh_check_app_version_changed)
|
|||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# If overwrite_periodic doesn't exist, create it
|
||||
if [ -z "$overwrite_periodic" ]; then
|
||||
if [ -z "${overwrite_periodic:-}" ]; then
|
||||
overwrite_periodic=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_periodic --value=$overwrite_periodic
|
||||
fi
|
||||
|
||||
# If admin_mail_html doesn't exist, create it
|
||||
if [ -z "$admin_mail_html" ]; then
|
||||
admin_mail_html=1
|
||||
#REMOVEME? ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
||||
fi
|
||||
|
||||
# Make a non perfect backup for apticron.conf if non existent
|
||||
if [ ! -e "../conf/apticron.conf.backup" ]; then
|
||||
if [ ! -e "$apticron_config_backup" ]; then
|
||||
# Create a backup of the config file for the reset action
|
||||
cp "/etc/apticron/apticron.conf" "../conf/apticron.conf.backup"
|
||||
sed --in-place '/^CUSTOM_SUBJECT=/d' "../conf/apticron.conf.backup"
|
||||
sed --in-place '/^CUSTOM_NO_UPDATES_SUBJECT=/d' "../conf/apticron.conf.backup"
|
||||
cp "$apticron_config" "$apticron_config_backup"
|
||||
sed --in-place '/^CUSTOM_SUBJECT=/d' "$apticron_config_backup"
|
||||
sed --in-place '/^CUSTOM_NO_UPDATES_SUBJECT=/d' "$apticron_config_backup"
|
||||
fi
|
||||
|
||||
# Make a non perfect backup for apticron cron file if non existent
|
||||
if [ ! -e "../conf/apticron.crond.backup" ]; then
|
||||
if [ ! -e "$apticron_cron" ]; then
|
||||
# Create a backup of the config file for the reset action
|
||||
cp "/etc/cron.d/apticron" "../conf/apticron.crond.backup"
|
||||
sed --in-place '/^[[:digit:]]/d' "../conf/apticron.crond.backup"
|
||||
ynh_replace_string --match_string="^#\([[:digit:]].*\)" --replace_string="\1" --target_file="../conf/apticron.crond.backup"
|
||||
cp "$apticron_cron" "$apticron_cron"
|
||||
sed --in-place '/^[[:digit:]]/d' "$apticron_cron"
|
||||
ynh_replace_string --match_string="^#\([[:digit:]].*\)" --replace_string="\1" --target_file="$apticron_cron"
|
||||
fi
|
||||
|
||||
# Make a non perfect backup for apticron cron file if non existent
|
||||
if [ ! -e "$unattended_upgrades_config" ]; then
|
||||
cp "$unattended_upgrades_config" "$unattended_upgrades_config_backup"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
# CONFIGURE APTICRON
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
||||
ynh_script_progression --message="Configuring Apticron..."
|
||||
|
||||
# Backup the current version of the app
|
||||
#REMOVEME? ynh_backup_before_upgrade
|
||||
#REMOVEME? ynh_clean_setup () {
|
||||
# restore it if the upgrade fails
|
||||
#REMOVEME? ynh_restore_upgradebackup
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
#REMOVEME? ynh_abort_if_errors
|
||||
_apticron_set_config
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
# CONFIGURE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
||||
ynh_script_progression --message="Configuring Unattended-Upgrades..."
|
||||
|
||||
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
||||
_unattended_upgrades_set_config
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
# CONFIGURE APT PERIODIC FOR UNATTENDED
|
||||
#=================================================
|
||||
# UPGRADE APTICRON
|
||||
#=================================================
|
||||
|
||||
# Nothing to do here...
|
||||
|
||||
#=================================================
|
||||
# UPGRADE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
|
||||
# Nothing to do here...
|
||||
|
||||
#=================================================
|
||||
# UPGRADE APT PERIODIC FOR UNATTENDED
|
||||
#=================================================
|
||||
|
||||
# Overwrite 02periodic config file only if it's allowed
|
||||
if [ $overwrite_periodic -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading APT Periodic for Unattended..." --weight=3
|
||||
if [ "$overwrite_periodic" -eq 1 ]; then
|
||||
ynh_script_progression --message="Upgrading APT Periodic for Unattended..."
|
||||
|
||||
ynh_add_config --template="../conf/02periodic" --destination="/etc/apt/apt.conf.d/02periodic"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPGRADE APTICRON CRON FILE
|
||||
#=================================================
|
||||
|
||||
# Nothing to do here...
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# SEND A README FOR THE ADMIN
|
||||
#=================================================
|
||||
|
||||
# Get main domain and buid the url of the admin panel of the app.
|
||||
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
|
||||
|
||||
# If a html email is required. Apply html to the changelog.
|
||||
if [ "$admin_mail_html" -eq 1 ]; then
|
||||
format=html
|
||||
else
|
||||
format=plain
|
||||
fi
|
||||
ynh_app_changelog --format=$format
|
||||
|
||||
echo "To modify any option of unattended-upgrades, please have a look to /etc/apt/apt.conf.d/50unattended-upgrades and
|
||||
/etc/apt/apt.conf.d/02periodic
|
||||
Unattended-upgrades will be executed every day at midnight.
|
||||
|
||||
To modify the configuration of apticron, please have a look to /etc/apticron/apticron.conf.
|
||||
Apticron will be executed, depending of the requested configuration at 8 p.m. and 2 a.m. If you want to change this schedule, please have a look to the cron file /etc/cron.d/apticron.
|
||||
|
||||
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
|
||||
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
|
||||
|
||||
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/unattended_upgrades_ynh__URL_TAG3__.
|
||||
|
||||
---
|
||||
|
||||
Changelog since your last upgrade:
|
||||
$(cat changelog)" > mail_to_send
|
||||
|
||||
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=upgrade
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -10,7 +10,11 @@ test_format = 1.0
|
|||
args.unattended_mail = "on_upgrade"
|
||||
args.unattended_verbosity = "v1"
|
||||
|
||||
test_upgrade_from.4e342d41.name = "Merge pull request #16 from YunoHost-Apps/testing"
|
||||
[default.test_upgrade_from.4e342d41]
|
||||
name = "Merge pull request #16 from YunoHost-Apps/testing"
|
||||
args.upgrade_level = "Security only"
|
||||
args.unattended_mail = "On upgrade"
|
||||
args.unattended_verbosity = "1"
|
||||
|
||||
[suite_2]
|
||||
args.upgrade_level = "security_and_updates"
|
||||
|
|
Loading…
Reference in a new issue