mirror of
https://github.com/YunoHost-Apps/unattended_upgrades_ynh.git
synced 2024-10-01 13:35:00 +02:00
Merge c7e8cc51cd
into c8a4bd7838
This commit is contained in:
commit
18c56d3e88
10 changed files with 59 additions and 390 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
*.swp
|
||||
*~
|
||||
Notes
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -18,7 +18,8 @@ admindoc = "https://wiki.debian.org/UnattendedUpgrades"
|
|||
userdoc = "https://manpages.debian.org/stretch/apticron/apticron.1.en.html"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = false
|
||||
ldap = "not_relevant"
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
apticron_config="/etc/apticron/apticron.conf"
|
||||
|
@ -23,10 +19,10 @@ _apticron_set_config() {
|
|||
# Create a backup of the config file for the reset action
|
||||
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"
|
||||
ynh_replace_string --match_string="# CUSTOM_NO_UPDATES_SUBJECT=.*" \
|
||||
--replace_string="&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" --target_file="$apticron_config"
|
||||
ynh_replace --match="# CUSTOM_SUBJECT=.*" \
|
||||
--replace="&\nCUSTOM_SUBJECT=\'[apticron] \$SYSTEM: \$NUM_PACKAGES package update(s)\'" --file="$apticron_config"
|
||||
ynh_replace --match="# CUSTOM_NO_UPDATES_SUBJECT=.*" \
|
||||
--replace="&\nCUSTOM_NO_UPDATES_SUBJECT=\'[apticron] \$SYSTEM: Up to date \\\\o/\'" --file="$apticron_config"
|
||||
|
||||
# Create a backup of the cron file for the reset action
|
||||
cp "$apticron_cron" "$apticron_cron_backup"
|
||||
|
@ -35,7 +31,7 @@ _apticron_set_config() {
|
|||
origin_line=$(grep -m 1 "apticron --cron" "$apticron_cron" | sed 's/^#* *//')
|
||||
|
||||
# Remove all lines matching
|
||||
ynh_replace_string --match_string=".*apticron --cron.*" --replace_string="" --target_file="$apticron_cron"
|
||||
ynh_replace --match=".*apticron --cron.*" --replace="" --file="$apticron_cron"
|
||||
# Remove empty lines
|
||||
sed -i '/^\s*$/d' "$apticron_cron"
|
||||
(
|
||||
|
@ -54,7 +50,6 @@ _apticron_restore_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"
|
||||
|
||||
|
@ -65,37 +60,37 @@ _unattended_upgrades_set_config() {
|
|||
# Configure upgrade sources
|
||||
# Allow other updates
|
||||
if [ "$upgrade_level" = "security_and_updates" ]; then
|
||||
ynh_replace_string --match_string="//\(.*\"o=Debian,a=stable\)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace_string --match_string="//\(.*\"o=Debian,a=stable-updates\)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace --match="//\(.*\"o=Debian,a=stable\)" --replace="\1" --file="$unattended_upgrades_config"
|
||||
ynh_replace --match="//\(.*\"o=Debian,a=stable-updates\)" --replace="\1" --file="$unattended_upgrades_config"
|
||||
fi
|
||||
|
||||
# Add YunoHost upgrade source
|
||||
if [ $ynh_update -eq 1 ]; then
|
||||
ynh_replace_string --match_string="origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \
|
||||
--replace_string="&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace --match="origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \
|
||||
--replace="&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" --file="$unattended_upgrades_config"
|
||||
fi
|
||||
|
||||
# Allow MinimalSteps upgrading to reduce risk in case of reboot
|
||||
ynh_replace_string --match_string="//\(Unattended-Upgrade::MinimalSteps\).*" --replace_string="\1 \"true\";" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace --match="//\(Unattended-Upgrade::MinimalSteps\).*" --replace="\1 \"true\";" --file="$unattended_upgrades_config"
|
||||
|
||||
# Configure Unattended Upgrades mailing
|
||||
if [ "$unattended_mail" = "on_upgrade" ]; then
|
||||
# Allow mail to root
|
||||
ynh_replace_string --match_string="//\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace --match="//\(Unattended-Upgrade::Mail \)" --replace="\1" --file="$unattended_upgrades_config"
|
||||
|
||||
# Send mail even if there's no errors
|
||||
ynh_replace_string --match_string="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"false\";" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace --match="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace="\1\"false\";" --file="$unattended_upgrades_config"
|
||||
|
||||
elif [ "$unattended_mail" = "on_error" ]; then
|
||||
# Allow mail to root
|
||||
ynh_replace_string --match_string="//\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace --match="//\(Unattended-Upgrade::Mail \)" --replace="\1" --file="$unattended_upgrades_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"
|
||||
ynh_replace --match="//\(Unattended-Upgrade::MailOnlyOnError \).*" --replace="\1\"true\";" --file="$unattended_upgrades_config"
|
||||
|
||||
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"
|
||||
ynh_replace --match="^\(Unattended-Upgrade::Mail \)" --replace="//\1" --file="$unattended_upgrades_config"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -103,15 +98,14 @@ _unattended_upgrades_restore_config() {
|
|||
mv "$unattended_upgrades_config_backup" "$unattended_upgrades_config"
|
||||
}
|
||||
|
||||
|
||||
_02periodic_config="/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
_02periodic_set_config() {
|
||||
ynh_add_config --template="../conf/02periodic" --destination="$_02periodic_config"
|
||||
ynh_config_add --template="02periodic" --destination="$_02periodic_config"
|
||||
}
|
||||
|
||||
_02periodic_remove() {
|
||||
ynh_secure_remove "$_02periodic_config"
|
||||
ynh_safe_rm "$_02periodic_config"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -126,10 +120,6 @@ _02periodic_remove() {
|
|||
# FUTUR OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Create a changelog for an app after an upgrade from the file CHANGELOG.md.
|
||||
#
|
||||
# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
|
||||
|
@ -143,7 +133,7 @@ _02periodic_remove() {
|
|||
# The changelog is printed into the file ./changelog and ./changelog_lite
|
||||
ynh_app_changelog () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=foc
|
||||
#REMOVEME? local legacy_args=foc
|
||||
declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
|
||||
local format
|
||||
local output
|
||||
|
@ -165,8 +155,8 @@ ynh_app_changelog () {
|
|||
return 0
|
||||
fi
|
||||
|
||||
#REMOVEME? local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
|
||||
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
|
||||
#REMOVEME? local current_version=$(ynh_read_manifest --key="version")
|
||||
local update_version=$(ynh_read_manifest --key="version")
|
||||
|
||||
# Get the line of the version to update to into the changelog
|
||||
local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
|
||||
|
@ -210,14 +200,14 @@ ynh_app_changelog () {
|
|||
if [ "$format" = "html" ]
|
||||
then
|
||||
# Replace markdown links by html links
|
||||
ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
|
||||
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
|
||||
ynh_replace --match="\[\(.*\)\](\(.*\)))" --replace="<a href=\"\2\">\1</a>)" --file="$final_changelog"
|
||||
ynh_replace --match="\[\(.*\)\](\(.*\))" --replace="<a href=\"\2\">\1</a>" --file="$final_changelog"
|
||||
elif [ "$format" = "plain" ]
|
||||
then
|
||||
# Change title format.
|
||||
ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
|
||||
ynh_replace --match="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace="## \1 (\3) - \2" --file="$final_changelog"
|
||||
# Change modifications lines format.
|
||||
ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
|
||||
ynh_replace --match="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace="\1 \2 \3" --file="$final_changelog"
|
||||
fi
|
||||
# else markdown. As the file is already in markdown, nothing to do.
|
||||
|
||||
|
@ -239,7 +229,7 @@ ynh_app_changelog () {
|
|||
# Remove the line if it's a title or a blank line, and the previous one was a title as well.
|
||||
if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
|
||||
then
|
||||
ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
|
||||
ynh_replace_regex --match="${previous_line//[/.}" --replace="" --file="${final_changelog}_lite"
|
||||
fi
|
||||
fi
|
||||
previous_line="$line"
|
||||
|
@ -249,7 +239,7 @@ ynh_app_changelog () {
|
|||
sed --in-place '/^$/d' "${final_changelog}_lite"
|
||||
|
||||
# Restore changelog format with blank lines
|
||||
ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
|
||||
ynh_replace --match="^##.*" --replace="\n\n&\n" --file="${final_changelog}_lite"
|
||||
# Remove the 2 first blank lines
|
||||
sed --in-place '1,2d' "${final_changelog}_lite"
|
||||
# Add a blank line at the end
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Load common variables for all scripts.
|
||||
source scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC ACTION
|
||||
#=================================================
|
||||
# RESET APTICRON CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [[ "$*" =~ ^apticron$ ]]; then
|
||||
ynh_script_progression --message="Resetting Apticron..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$apticron_config"
|
||||
ynh_backup_if_checksum_is_different --file="$apticron_cron"
|
||||
|
||||
_apticron_restore_config
|
||||
_apticron_set_config
|
||||
|
||||
ynh_store_file_checksum --file="$apticron_config"
|
||||
ynh_store_file_checksum --file="$apticron_cron"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESET UNATTENDED-UPGRADES CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [[ "$*" =~ ^50unattended-upgrades$ ]]; then
|
||||
ynh_script_progression --message="Resetting unattended-upgrades..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$unattended_upgrades_config"
|
||||
_unattended_upgrades_restore_config
|
||||
_unattended_upgrades_set_config
|
||||
ynh_store_file_checksum --file="$unattended_upgrades_config"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESET APT PERIODIC CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [[ "$*" =~ ^02periodic$ ]]; then
|
||||
ynh_script_progression --message="Resetting apt periodic..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$_02periodic_config"
|
||||
_02periodic_set_config
|
||||
ynh_store_file_checksum --file="$_02periodic_config"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Execution completed" --last
|
|
@ -1,33 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
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 UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$apticron_config"
|
||||
ynh_backup "$apticron_config"
|
||||
|
||||
ynh_backup --src_path="$apticron_cron"
|
||||
ynh_backup "$apticron_cron"
|
||||
|
||||
ynh_backup --src_path="$unattended_upgrades_config"
|
||||
ynh_backup "$unattended_upgrades_config"
|
||||
|
||||
ynh_backup --src_path="/etc/apt/apt.conf.d/02periodic"
|
||||
ynh_backup "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# 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)."
|
||||
|
|
229
scripts/config
229
scripts/config
|
@ -1,229 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC CODE
|
||||
#=================================================
|
||||
# LOAD VALUES
|
||||
#=================================================
|
||||
|
||||
# Load the real value from the app config or elsewhere.
|
||||
# Then get the value from the form.
|
||||
# If the form has a value for a variable, take the value from the form,
|
||||
# Otherwise, keep the value from the app config.
|
||||
|
||||
# upgrade_level
|
||||
old_upgrade_level="$(ynh_app_setting_get --app=$app --key=upgrade_level)"
|
||||
upgrade_level="${YNH_CONFIG_MAIN_UNATTENDED_CONFIGURATION_UPGRADE_LEVEL:-$old_upgrade_level}"
|
||||
|
||||
# ynh_update
|
||||
old_ynh_update="$(ynh_app_setting_get --app=$app --key=ynh_update)"
|
||||
ynh_update="${YNH_CONFIG_MAIN_UNATTENDED_CONFIGURATION_YNH_UPDATE:-$old_ynh_update}"
|
||||
|
||||
# unattended_mail
|
||||
old_unattended_mail="$(ynh_app_setting_get --app=$app --key=unattended_mail)"
|
||||
unattended_mail="${YNH_CONFIG_MAIN_UNATTENDED_CONFIGURATION_UNATTENDED_MAIL:-$old_unattended_mail}"
|
||||
|
||||
|
||||
# previous_apticron
|
||||
old_previous_apticron="$(ynh_app_setting_get --app=$app --key=previous_apticron)"
|
||||
previous_apticron="${YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_PREVIOUS_APTICRON:-$old_previous_apticron}"
|
||||
|
||||
# previous_apticron_hour
|
||||
old_previous_apticron_hour="$(cat /etc/cron.d/apticron | grep --max-count=1 "^#*0.*root if.*" | cut -d' ' -f2)"
|
||||
previous_apticron_hour="${YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_PREVIOUS_APTICRON_HOUR:-$old_previous_apticron_hour}"
|
||||
|
||||
# after_apticron
|
||||
old_after_apticron="$(ynh_app_setting_get --app=$app --key=after_apticron)"
|
||||
after_apticron="${YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_AFTER_APTICRON:-$old_after_apticron}"
|
||||
|
||||
# after_apticron_hour
|
||||
old_after_apticron_hour="$(tac /etc/cron.d/apticron | grep --max-count=1 "^#*0.*root if.*" | cut -d' ' -f2)"
|
||||
after_apticron_hour="${YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_AFTER_APTICRON_HOUR:-$old_after_apticron_hour}"
|
||||
|
||||
|
||||
# unattended_verbosity
|
||||
old_unattended_verbosity="$(ynh_app_setting_get --app=$app --key=unattended_verbosity)"
|
||||
unattended_verbosity="${YNH_CONFIG_MAIN_PERIODIC_CONFIGURATION_UNATTENDED_VERBOSITY:-$old_unattended_verbosity}"
|
||||
|
||||
|
||||
# Overwrite 02periodic config file
|
||||
old_overwrite_periodic="$(ynh_app_setting_get --app=$app --key=overwrite_periodic)"
|
||||
overwrite_periodic="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PERIODIC:-$old_overwrite_periodic}"
|
||||
|
||||
|
||||
# Type of admin mail configuration
|
||||
old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
|
||||
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
|
||||
|
||||
#=================================================
|
||||
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
|
||||
#=================================================
|
||||
|
||||
show_config() {
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_UNATTENDED_CONFIGURATION_UPGRADE_LEVEL=$upgrade_level"
|
||||
ynh_return "YNH_CONFIG_MAIN_UNATTENDED_CONFIGURATION_YNH_UPDATE=$ynh_update"
|
||||
ynh_return "YNH_CONFIG_MAIN_UNATTENDED_CONFIGURATION_UNATTENDED_MAIL=$unattended_mail"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_PREVIOUS_APTICRON=$previous_apticron"
|
||||
ynh_return "YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_PREVIOUS_APTICRON_HOUR=$previous_apticron_hour"
|
||||
ynh_return "YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_AFTER_APTICRON=$after_apticron"
|
||||
ynh_return "YNH_CONFIG_MAIN_APTICRON_CONFIGURATION_AFTER_APTICRON_HOUR=$after_apticron_hour"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_PERIODIC_CONFIGURATION_UNATTENDED_VERBOSITY=$unattended_verbosity"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PERIODIC=$overwrite_periodic"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# MODIFY THE CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
apply_config() {
|
||||
|
||||
#=================================================
|
||||
# MODIFY 50UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
unattended_upgrades_config="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
# upgrade_level
|
||||
if [ "$upgrade_level" != "$old_upgrade_level" ]
|
||||
then
|
||||
if [ "$upgrade_level" = "Security and updates" ]
|
||||
then
|
||||
# Uncomment lines in the config
|
||||
ynh_replace_string --match_string="//\( *\"o=Debian,a=stable\)" --replace_string=" \1" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace_string --match_string="//\( *\"o=Debian,a=stable-updates\)" --replace_string=" \1" --target_file="$unattended_upgrades_config"
|
||||
else
|
||||
# Comment lines in the config
|
||||
ynh_replace_string --match_string="^ \( *\"o=Debian,a=stable\)" --replace_string="//\1" --target_file="$unattended_upgrades_config"
|
||||
ynh_replace_string --match_string="^ \( *\"o=Debian,a=stable-updates\)" --replace_string="//\1" --target_file="$unattended_upgrades_config"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=upgrade_level --value="$upgrade_level"
|
||||
fi
|
||||
# ynh_update
|
||||
if [ "$ynh_update" != "$old_ynh_update" ]
|
||||
then
|
||||
if [ "$ynh_update" -eq 1 ]
|
||||
then
|
||||
# Add YunoHost upgrade source
|
||||
ynh_replace_string --match_string="origin=Debian,codename=\${distro_codename},label=Debian-Security\";" \
|
||||
--replace_string="&\n\n //YunoHost upgrade\n \"o=YunoHost,a=stable\";" --target_file="$unattended_upgrades_config"
|
||||
else
|
||||
# Remove lines about YunoHost
|
||||
sed --in-place '/YunoHost upgrade/d' "$unattended_upgrades_config"
|
||||
sed --in-place '/o=YunoHost/d' "$unattended_upgrades_config"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=ynh_update --value="$ynh_update"
|
||||
fi
|
||||
# unattended_mail
|
||||
if [ "$unattended_mail" != "$old_unattended_mail" ]
|
||||
then
|
||||
if [ "$unattended_mail" = "If an upgrade has been done" ]
|
||||
then
|
||||
# Allow mail to root
|
||||
ynh_replace_string --match_string="/*\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_config"
|
||||
|
||||
# Send mail even if there's no errors
|
||||
ynh_replace_string --match_string="/*\(Unattended-Upgrade::MailOnlyOnError \).*" --replace_string="\1\"false\";" --target_file="$unattended_upgrades_config"
|
||||
|
||||
elif [ "$unattended_mail" = "Only if there was an error" ]
|
||||
then
|
||||
# Allow mail to root
|
||||
ynh_replace_string --match_string="/*\(Unattended-Upgrade::Mail \)" --replace_string="\1" --target_file="$unattended_upgrades_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"
|
||||
# Comment "Unattended-Upgrade::Mail"
|
||||
ynh_replace_string --match_string="^\(Unattended-Upgrade::Mail \)" --replace_string="//\1" --target_file="$unattended_upgrades_config"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=unattended_mail --value="$unattended_mail"
|
||||
fi
|
||||
|
||||
# previous_apticron
|
||||
apticron_cron="/etc/cron.d/apticron"
|
||||
if [ "$previous_apticron" != "$old_previous_apticron" ]
|
||||
then
|
||||
if [ "$previous_apticron" = "1" ]
|
||||
then
|
||||
# Uncomment the first cron line
|
||||
ynh_replace_string --match_string="^#\(0 $old_previous_apticron_hour .*\)" --replace_string="\1" --target_file="$apticron_cron"
|
||||
else
|
||||
# Comment the first cron line
|
||||
ynh_replace_string --match_string="^0 $old_previous_apticron_hour .*" --replace_string="#&" --target_file="$apticron_cron"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=previous_apticron --value="$previous_apticron"
|
||||
fi
|
||||
# previous_apticron_hour
|
||||
if [ "$previous_apticron_hour" != "$old_previous_apticron_hour" ]
|
||||
then
|
||||
# Use sed instead of ynh_replace_string to avoid the 'global' argument
|
||||
sed --in-place "s/0 $old_previous_apticron_hour\( \* \* \* root if\)/0 $previous_apticron_hour\1/" "$apticron_cron"
|
||||
ynh_app_setting_set --app=$app --key=previous_apticron_hour --value="$previous_apticron_hour"
|
||||
fi
|
||||
# after_apticron
|
||||
if [ "$after_apticron" != "$old_after_apticron" ]
|
||||
then
|
||||
if [ "$after_apticron" = "1" ]
|
||||
then
|
||||
# Uncomment the second cron line
|
||||
ynh_replace_string --match_string="^#\(0 $old_after_apticron_hour .*\)" --replace_string="\1" --target_file="$apticron_cron"
|
||||
else
|
||||
# Comment the second cron line
|
||||
ynh_replace_string --match_string="^0 $old_after_apticron_hour .*" --replace_string="#&" --target_file="$apticron_cron"
|
||||
fi
|
||||
ynh_app_setting_set --app=$app --key=after_apticron --value="$after_apticron"
|
||||
fi
|
||||
# after_apticron_hour
|
||||
if [ "$after_apticron_hour" != "$old_after_apticron_hour" ]
|
||||
then
|
||||
# Use sed instead of ynh_replace_string to avoid the 'global' argument
|
||||
sed --in-place "s/0 $old_after_apticron_hour\( \* \* \* root if\)/0 $after_apticron_hour\1/" "$apticron_cron"
|
||||
ynh_app_setting_set --app=$app --key=after_apticron_hour --value="$after_apticron_hour"
|
||||
fi
|
||||
|
||||
# unattended_verbosity
|
||||
if [ "$unattended_verbosity" != "$old_unattended_verbosity" ]
|
||||
then
|
||||
ynh_backup_if_checksum_is_different --file="/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
ynh_replace_string --match_string="^APT::Periodic::Verbose \".*" --replace_string="APT::Periodic::Verbose \"$unattended_verbosity\";" --target_file="/etc/apt/apt.conf.d/02periodic"
|
||||
ynh_app_setting_set --app=$app --key=unattended_verbosity --value="$unattended_verbosity"
|
||||
|
||||
ynh_store_file_checksum --file="/etc/apt/apt.conf.d/02periodic"
|
||||
fi
|
||||
|
||||
# Set overwrite_periodic
|
||||
ynh_app_setting_set --app=$app --key=overwrite_periodic --value="$overwrite_periodic"
|
||||
|
||||
# Set admin_mail_html
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
ynh_app_config_run $1
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -15,29 +9,29 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
# 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"
|
||||
ynh_app_setting_set --app="$app" --key=admin_panel --value="$admin_panel"
|
||||
ynh_app_setting_set --key=admin_panel --value="$admin_panel"
|
||||
|
||||
# ynh_app_setting_set --app=$app --key=overwrite_periodic --value=1
|
||||
# ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
|
||||
# ynh_app_setting_set --key=overwrite_periodic --value=1
|
||||
# ynh_app_setting_set --key=admin_mail_html --value=1
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE APTICRON
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Apticron..."
|
||||
ynh_script_progression "Configuring Apticron..."
|
||||
|
||||
_apticron_set_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Unattended-Upgrades..."
|
||||
ynh_script_progression "Configuring Unattended-Upgrades..."
|
||||
|
||||
_unattended_upgrades_set_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE APT PERIODIC FOR UNATTENDED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configure APT Periodic for Unattended" --weight=2
|
||||
ynh_script_progression "Configure APT Periodic for Unattended"
|
||||
|
||||
_02periodic_set_config
|
||||
|
||||
|
@ -45,4 +39,4 @@ _02periodic_set_config
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
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..."
|
||||
|
||||
_apticron_restore_config
|
||||
_unattended_upgrades_restore_config
|
||||
|
@ -22,4 +16,4 @@ _02periodic_remove
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -13,16 +7,16 @@ source /usr/share/yunohost/helpers
|
|||
# RESTORE UNATTENDED-UPGRADES CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file --origin_path="$apticron_config"
|
||||
ynh_restore "$apticron_config"
|
||||
|
||||
ynh_restore_file --origin_path="$apticron_cron"
|
||||
ynh_restore "$apticron_cron"
|
||||
|
||||
ynh_restore_file --origin_path="$unattended_upgrades_config"
|
||||
ynh_restore "$unattended_upgrades_config"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/apt/apt.conf.d/02periodic"
|
||||
ynh_restore "/etc/apt/apt.conf.d/02periodic"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -1,25 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# If overwrite_periodic doesn't exist, create it
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=overwrite_periodic --value=1
|
||||
if [ -z "${overwrite_periodic:-}" ]; then
|
||||
overwrite_periodic=1
|
||||
ynh_app_setting_set --app=$app --key=overwrite_periodic --value=$overwrite_periodic
|
||||
ynh_app_setting_set --key=overwrite_periodic --value=$overwrite_periodic
|
||||
fi
|
||||
|
||||
# Make a non perfect backup for apticron.conf if non existent
|
||||
|
@ -35,7 +28,7 @@ if [ ! -e "$apticron_cron" ]; then
|
|||
# Create a backup of the config file for the reset action
|
||||
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"
|
||||
ynh_replace --match="^#\([[:digit:]].*\)" --replace="\1" --file="$apticron_cron"
|
||||
fi
|
||||
|
||||
# Make a non perfect backup for apticron cron file if non existent
|
||||
|
@ -46,14 +39,14 @@ fi
|
|||
#=================================================
|
||||
# CONFIGURE APTICRON
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Apticron..."
|
||||
ynh_script_progression "Configuring Apticron..."
|
||||
|
||||
_apticron_set_config
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE UNATTENDED-UPGRADES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Unattended-Upgrades..."
|
||||
ynh_script_progression "Configuring Unattended-Upgrades..."
|
||||
|
||||
_unattended_upgrades_set_config
|
||||
|
||||
|
@ -62,7 +55,7 @@ _unattended_upgrades_set_config
|
|||
#=================================================
|
||||
# Overwrite 02periodic config file only if it's allowed
|
||||
if [ "$overwrite_periodic" -eq 1 ]; then
|
||||
ynh_script_progression --message="Upgrading APT Periodic for Unattended..."
|
||||
ynh_script_progression "Upgrading APT Periodic for Unattended..."
|
||||
|
||||
_02periodic_set_config
|
||||
fi
|
||||
|
@ -71,4 +64,4 @@ fi
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue