Fix linter warnings

This commit is contained in:
ericgaspar 2021-07-17 17:07:13 +02:00
parent ec47b2d17b
commit 60a1ca469c
No known key found for this signature in database
GPG key ID: 574F281483054D44
10 changed files with 37 additions and 326 deletions

View file

@ -26,12 +26,12 @@
setup_private=0
setup_public=0
upgrade=1
upgrade=1 from_commit=5a359c6833a5415932ab427a80dbbdc6ca3c8e23
upgrade=1 from_commit=4e342d41ea448c4a9de2bbbc6b6cffe92320ef71
backup_restore=1
multi_instance=0
port_already_use=0
change_url=0
actions=1
actions=0
config_panel=1
;; Test complet 2/3
; Manifest
@ -61,11 +61,9 @@
setup_nourl=1
upgrade=1
backup_restore=1
;;; Levels
Level 5=auto
;;; Options
Email=
Notification=change
;;; Upgrade options
; commit=b86b9d09ed97bf04b7e1afad72376d8d695b418b
name=Mar 14, 2018 Update helpers
; commit=4e342d41ea448c4a9de2bbbc6b6cffe92320ef71
name=Merge pull request #16 from YunoHost-Apps/testing

View file

@ -23,4 +23,4 @@ APT::Periodic::AutocleanInterval "30";
// 1: progress report (actually any string)
// 2: + command outputs (remove -qq, remove 2>/dev/null, add -d)
// 3: + trace on
APT::Periodic::Verbose "__VERBOSITY__";
APT::Periodic::Verbose "__UNATTENDED_VERBOSITY__";

View file

@ -14,12 +14,12 @@ name = "Unattended-upgrades configuration"
default = "Security only"
[main.unattended_configuration.ynh_update]
ask = "Would you like to update YunoHost packages automatically ?"
ask = "Would you like to update YunoHost packages automatically?"
type = "boolean"
default = true
[main.unattended_configuration.unattended_mail]
ask = "Would you like to receive an email from Unattended-Upgrades ?"
ask = "Would you like to receive an email from Unattended-Upgrades?"
choices = ["If an upgrade has been done", "Only if there was an error", "Never"]
default = "If an upgrade has been done"
@ -28,7 +28,7 @@ name = "Unattended-upgrades configuration"
name = "apticron cron file"
[main.apticron_configuration.previous_apticron]
ask = "Would you like to receive an email to inform which upgrades need to be done ?"
ask = "Would you like to receive an email to inform which upgrades need to be done?"
type = "boolean"
default = true
@ -39,12 +39,12 @@ name = "Unattended-upgrades configuration"
help = "Choose an hour between 12 and 23."
[main.apticron_configuration.after_apticron]
ask = "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?"
ask = "Would you like to receive an email to verify if there any upgrades left after each auto upgrade?"
type = "boolean"
default = true
[main.apticron_configuration.after_apticron_hour]
ask = "When do you want to receive this email ?"
ask = "When do you want to receive this email?"
type = "number"
default = "2"
help = "Choose an hour between 0 and 10."
@ -64,7 +64,7 @@ name = "Unattended-upgrades configuration"
name = "Overwriting config files"
[main.overwrite_files.overwrite_periodic]
ask = "Overwrite the config file 02periodic ?"
ask = "Overwrite the config file 02periodic?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
@ -74,7 +74,7 @@ name = "Unattended-upgrades configuration"
name = "Global configuration"
[main.global_config.email_type]
ask = "Send HTML email to admin ?"
ask = "Send HTML email to admin?"
type = "boolean"
default = true
help = "Allow app scripts to send HTML mails instead of plain text."

View file

@ -4,7 +4,7 @@
"packaging_format": 1,
"description": {
"en": "Daily automatic upgrades",
"fr": "Mise à jour automatique quotidienne."
"fr": "Mise à jour automatique quotidienne"
},
"version": "1.0~ynh5",
"url": "https://wiki.debian.org/UnattendedUpgrades",
@ -18,7 +18,7 @@
"email": "maniackc_dev@crudelis.fr"
}],
"requirements": {
"yunohost": ">= 3.6.0"
"yunohost": ">= 4.2.0"
},
"multi_instance": false,
"services": [],
@ -38,7 +38,7 @@
"name": "ynh_update",
"type": "boolean",
"ask": {
"en": "Would you like to update YunoHost packages automatically ?",
"en": "Would you like to update YunoHost packages automatically?",
"fr": "Souhaitez-vous mettre à jour les paquets YunoHost automatiquement ?"
},
"default": true
@ -47,7 +47,7 @@
"name": "previous_apticron",
"type": "boolean",
"ask": {
"en": "Would you like to receive an email to inform which upgrades need to be done ?",
"en": "Would you like to receive an email to inform which upgrades need to be done?",
"fr": "Souhaitez-vous recevoir un email pour vous informer des mises à jour nécessaires ?"
},
"default": true
@ -56,7 +56,7 @@
"name": "after_apticron",
"type": "boolean",
"ask": {
"en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade ?",
"en": "Would you like to receive an email to verify if there any upgrades left after each auto upgrade?",
"fr": "Souhaitez-vous recevoir un email pour vérifier s'il reste des mises à jour après chaque mise à niveau automatique ?"
},
"default": true
@ -65,7 +65,7 @@
"name": "unattended_mail",
"type": "string",
"ask": {
"en": "Would you like to receive an email from Unattended-Upgrades ?",
"en": "Would you like to receive an email from Unattended-Upgrades?",
"fr": "Souhaitez-vous recevoir un email de Unattended-Upgrades ?"
},
"choices": ["If an upgrade has been done", "Only if there was an error", "Never"],

View file

@ -1,5 +1,12 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies="apticron unattended-upgrades apt-listchanges"
#=================================================
# PERSONAL HELPERS
#=================================================
@ -43,83 +50,6 @@ IS_PACKAGE_CHECK () {
# FUTUR OFFICIAL HELPERS
#=================================================
# Install or update the main directory yunohost.multimedia
#
# usage: ynh_multimedia_build_main_dir
ynh_multimedia_build_main_dir () {
local ynh_media_release="v1.2"
local checksum="806a827ba1902d6911095602a9221181"
# Download yunohost.multimedia scripts
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
# Check the control sum
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
|| ynh_die "Corrupt source"
# Check if the package acl is installed. Or install it.
ynh_package_is_installed 'acl' \
|| ynh_package_install acl
# Extract
mkdir yunohost.multimedia-master
tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1
./yunohost.multimedia-master/script/ynh_media_build.sh
}
# Add a directory in yunohost.multimedia
# This "directory" will be a symbolic link to a existing directory.
#
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
#
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
ynh_multimedia_addfolder () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
local source_dir
local dest_dir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
}
# Move a directory in yunohost.multimedia, and replace by a symbolic link
#
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
#
# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
# It will be moved to "Destination directory"
# A symbolic link will replace it.
# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
ynh_multimedia_movefolder () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
local source_dir
local dest_dir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
}
# Allow an user to have an write authorisation in multimedia directories
#
# usage: ynh_multimedia_addaccess user_name
#
# | arg: -u, --user_name= - The name of the user which gain this access.
ynh_multimedia_addaccess () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [u]=user_name=)
local user_name
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
groupadd -f multimedia
usermod -a -G multimedia $user_name
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
@ -265,30 +195,6 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
#=================================================
ynh_debian_release () {
lsb_release --codename --short
}
is_stretch () {
if [ "$(ynh_debian_release)" == "stretch" ]
then
return 0
else
return 1
fi
}
is_jessie () {
if [ "$(ynh_debian_release)" == "jessie" ]
then
return 0
else
return 1
fi
}
#=================================================
ynh_maintenance_mode_ON () {
# Load value of $path_url and $domain from the config if their not set
if [ -z $path_url ]; then
@ -578,173 +484,3 @@ ynh_check_ram () {
echo $ram
fi
}
#=================================================
# Define the values to configure php-fpm
#
# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print]
# | arg: -f, --footprint - Memory footprint of the service (low/medium/high).
# low - Less than 20Mb of ram by pool.
# medium - Between 20Mb and 40Mb of ram by pool.
# high - More than 40Mb of ram by pool.
# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value.
# To have this value, use the following command and stress the service.
# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP
#
# | arg: -u, --usage - Expected usage of the service (low/medium/high).
# low - Personal usage, behind the sso.
# medium - Low usage, few people or/and publicly accessible.
# high - High usage, frequently visited website.
#
# | arg: -p, --print - Print the result
#
#
#
# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM.
# So it will be used to defined 'pm.max_children'
# A lower value for the footprint will allow more children for 'pm.max_children'. And so for
# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the
# value of 'pm.max_children'
# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores.
#
# The usage value will defined the way php will handle the children for the pool.
# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the
# service is used, otherwise no child will stay alive. This config gives the lower footprint when the
# service is idle. But will use more proc since it has to start a child as soon it's used.
# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children
# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request.
# The number of children can grow if needed. The footprint can stay low if the service is idle, but
# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few
# children already available.
# Set as 'high', the process manager will be set at 'static'. There will be always as many children as
# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum
# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many
# children ready to answer.
ynh_get_scalable_phpfpm () {
local legacy_args=ufp
# Declare an array to define the options of this helper.
declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print )
local usage
local footprint
local print
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Set all characters as lowercase
footprint=${footprint,,}
usage=${usage,,}
print=${print:-0}
if [ "$footprint" = "low" ]
then
footprint=20
elif [ "$footprint" = "medium" ]
then
footprint=35
elif [ "$footprint" = "high" ]
then
footprint=50
fi
# Define the way the process manager handle child processes.
if [ "$usage" = "low" ]
then
php_pm=ondemand
elif [ "$usage" = "medium" ]
then
php_pm=dynamic
elif [ "$usage" = "high" ]
then
php_pm=static
else
ynh_die --message="Does not recognize '$usage' as an usage value."
fi
# Get the total of RAM available, except swap.
local max_ram=$(ynh_check_ram --no_swap)
less0() {
# Do not allow value below 1
if [ $1 -le 0 ]
then
echo 1
else
echo $1
fi
}
# Define pm.max_children
# The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app.
# So if php-fpm start the maximum of children, it won't exceed half of the ram.
php_max_children=$(( $max_ram / 2 / $footprint ))
# If process manager is set as static, use half less children.
# Used as static, there's always as many children as the value of pm.max_children
if [ "$php_pm" = "static" ]
then
php_max_children=$(( $php_max_children / 2 ))
fi
php_max_children=$(less0 $php_max_children)
# To not overload the proc, limit the number of children to 4 times the number of cores.
local core_number=$(nproc)
local max_proc=$(( $core_number * 4 ))
if [ $php_max_children -gt $max_proc ]
then
php_max_children=$max_proc
fi
if [ "$php_pm" = "dynamic" ]
then
# Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager
php_min_spare_servers=$(( $php_max_children / 8 ))
php_min_spare_servers=$(less0 $php_min_spare_servers)
php_max_spare_servers=$(( $php_max_children / 2 ))
php_max_spare_servers=$(less0 $php_max_spare_servers)
php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 ))
php_start_servers=$(less0 $php_start_servers)
else
php_min_spare_servers=0
php_max_spare_servers=0
php_start_servers=0
fi
if [ $print -eq 1 ]
then
ynh_debug --message="Footprint=${footprint}Mb by pool."
ynh_debug --message="Process manager=$php_pm"
ynh_debug --message="Max RAM=${max_ram}Mb"
if [ "$php_pm" != "static" ]; then
ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))"
ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))"
fi
if [ "$php_pm" = "dynamic" ]; then
ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))"
elif [ "$php_pm" = "static" ]; then
ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))"
fi
ynh_debug --message="\nRaw php-fpm values:"
ynh_debug --message="pm.max_children = $php_max_children"
if [ "$php_pm" = "dynamic" ]; then
ynh_debug --message="pm.start_servers = $php_start_servers"
ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers"
ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers"
fi
fi
}
#=================================================
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}

View file

@ -1,4 +0,0 @@
#!/bin/bash
# Dependencies
app_depencencies="apticron unattended-upgrades apt-listchanges"

View file

@ -19,16 +19,18 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
#=================================================
# SPECIFIC BACKUP
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP UNATTENDED-UPGRADES CONFIG
#=================================================
ynh_script_progression --message="Backing up unattended-upgrades config..."
ynh_backup --src_path="/etc/apt/apt.conf.d/50unattended-upgrades"
# Backup also the backup of the config file
@ -37,21 +39,18 @@ ynh_backup --src_path="/etc/apt/50unattended-upgrades.backup"
#=================================================
# BACKUP APT PERIODIC
#=================================================
ynh_script_progression --message="Backing up APT periodic..."
ynh_backup --src_path="/etc/apt/apt.conf.d/02periodic"
#=================================================
# BACKUP APTICRON CONFIG
#=================================================
ynh_script_progression --message="Backing up Apticron config..."
ynh_backup --src_path="/etc/apticron/apticron.conf"
#=================================================
# BACKUP THE CRON FILE
#=================================================
ynh_script_progression --message="Backing up cron file..."
ynh_backup --src_path="/etc/cron.d/apticron"
@ -59,4 +58,4 @@ ynh_backup --src_path="/etc/cron.d/apticron"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -6,9 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source _variables
source _common.sh
source /usr/share/yunohost/helpers
@ -54,7 +51,7 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=10
ynh_install_app_dependencies $app_depencencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC SETUP
@ -132,11 +129,7 @@ fi
#=================================================
ynh_script_progression --message="Configure APT Periodic for Unattended" --weight=2
cp "../conf/02periodic" "/etc/apt/apt.conf.d/02periodic"
ynh_replace_string --match_string="__VERBOSITY__" --replace_string="$unattended_verbosity" --target_file="/etc/apt/apt.conf.d/02periodic"
# This config file is used by /etc/cron.daily/apt
ynh_store_file_checksum "/etc/apt/apt.conf.d/02periodic"
ynh_add_config --template="../conf/02periodic" --destination="/etc/apt/apt.conf.d/02periodic"
#=================================================
# MODIFY ORIGINAL APTICRON CRON FILE

View file

@ -6,9 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source ../settings/scripts/_variables
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -33,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=10
ynh_install_app_dependencies $app_depencencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE UNATTENDED-UPGRADES CONFIG

View file

@ -6,9 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
# Load common variables for all scripts.
source _variables
source _common.sh
source /usr/share/yunohost/helpers
@ -82,7 +79,7 @@ ynh_abort_if_errors
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5
ynh_install_app_dependencies $app_depencencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
@ -106,13 +103,8 @@ ynh_install_app_dependencies $app_depencencies
if [ $overwrite_periodic -eq 1 ]
then
ynh_script_progression --message="Upgrading APT Periodic for Unattended..." --weight=3
ynh_backup_if_checksum_is_different --file="/etc/apt/apt.conf.d/02periodic"
cp "../conf/02periodic" "/etc/apt/apt.conf.d/02periodic"
ynh_replace_string --match_string="__VERBOSITY__" --replace_string="$unattended_verbosity" --target_file="/etc/apt/apt.conf.d/02periodic"
# This config file is used by /etc/cron.daily/apt
ynh_store_file_checksum --file="/etc/apt/apt.conf.d/02periodic"
ynh_add_config --template="../conf/02periodic" --destination="/etc/apt/apt.conf.d/02periodic"
fi
#=================================================