mirror of
https://github.com/YunoHost-Apps/archivist_ynh.git
synced 2024-09-03 18:15:55 +02:00
Indentation
This commit is contained in:
parent
4cba6ae014
commit
c27d048561
8 changed files with 290 additions and 290 deletions
|
@ -1,10 +1,10 @@
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
encrypt=1
|
encrypt=1
|
||||||
encryption_pwd="password"
|
encryption_pwd="password"
|
||||||
core_backup=1
|
core_backup=1
|
||||||
apps_backup=1
|
apps_backup=1
|
||||||
frequency="Weekly"
|
frequency="Weekly"
|
||||||
; Config_panel
|
; Config_panel
|
||||||
main.encryption.encrypt=1|0
|
main.encryption.encrypt=1|0
|
||||||
main.encryption.encryption_pwd=password1|password2
|
main.encryption.encryption_pwd=password1|password2
|
||||||
|
@ -14,36 +14,36 @@
|
||||||
main.backup_options.max_size=1000
|
main.backup_options.max_size=1000
|
||||||
main.overwrite_files.overwrite_cron=1|0
|
main.overwrite_files.overwrite_cron=1|0
|
||||||
main.global_config.email_type=1|0
|
main.global_config.email_type=1|0
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
setup_root=0
|
setup_root=0
|
||||||
setup_nourl=1
|
setup_nourl=1
|
||||||
setup_private=0
|
setup_private=0
|
||||||
setup_public=0
|
setup_public=0
|
||||||
upgrade=1
|
upgrade=1
|
||||||
upgrade=1 from_commit=2b2793737d5e1374659cbb74838d10162a2147e6
|
upgrade=1 from_commit=2b2793737d5e1374659cbb74838d10162a2147e6
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
port_already_use=0
|
port_already_use=0
|
||||||
change_url=0
|
change_url=0
|
||||||
config_panel=1
|
config_panel=1
|
||||||
;; Test actions without encryption
|
;; Test actions without encryption
|
||||||
# Actions can't be tested with the encryption on, because LXC does not support fuse.
|
# Actions can't be tested with the encryption on, because LXC does not support fuse.
|
||||||
; Manifest
|
; Manifest
|
||||||
encrypt=0
|
encrypt=0
|
||||||
encryption_pwd=""
|
encryption_pwd=""
|
||||||
core_backup=1
|
core_backup=1
|
||||||
apps_backup=1
|
apps_backup=1
|
||||||
; Checks
|
; Checks
|
||||||
setup_nourl=1
|
setup_nourl=1
|
||||||
actions=1
|
actions=1
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 5=auto
|
Level 5=auto
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=change
|
Notification=change
|
||||||
;;; Upgrade options
|
;;; Upgrade options
|
||||||
; commit=2b2793737d5e1374659cbb74838d10162a2147e6
|
; commit=2b2793737d5e1374659cbb74838d10162a2147e6
|
||||||
name=03 Nov 2017 2b2793737d5e1374659cbb74838d10162a2147e6
|
name=03 Nov 2017 2b2793737d5e1374659cbb74838d10162a2147e6
|
||||||
manifest_arg=encrypt=1&encryption_pwd="password"&core_backup=1&apps_backup=1&frequency="Weekly"&
|
manifest_arg=encrypt=1&encryption_pwd="password"&core_backup=1&apps_backup=1&frequency="Weekly"&
|
||||||
|
|
146
manifest.json
146
manifest.json
|
@ -1,75 +1,75 @@
|
||||||
{
|
{
|
||||||
"name": "Archivist",
|
"name": "Archivist",
|
||||||
"id": "archivist",
|
"id": "archivist",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Automatic backups.",
|
"en": "Automatic backups.",
|
||||||
"fr": "Sauvegardes automatiques."
|
"fr": "Sauvegardes automatiques."
|
||||||
},
|
},
|
||||||
"version": "1.0.1~ynh3",
|
"version": "1.0.1~ynh3",
|
||||||
"url": "https://github.com/maniackcrudelis/archivist",
|
"url": "https://github.com/maniackcrudelis/archivist",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "Maniack Crudelis",
|
"name": "Maniack Crudelis",
|
||||||
"email": "maniackc_dev@crudelis.fr"
|
"email": "maniackc_dev@crudelis.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 3.6.0"
|
"yunohost": ">= 3.6.0"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [],
|
"services": [],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install" : [
|
"install" : [
|
||||||
{
|
{
|
||||||
"name": "encrypt",
|
"name": "encrypt",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Do you want to encrypt your backups ?",
|
"en": "Do you want to encrypt your backups ?",
|
||||||
"fr": "Voulez-vous chiffrer vos sauvegardes ?"
|
"fr": "Voulez-vous chiffrer vos sauvegardes ?"
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "encryption_pwd",
|
"name": "encryption_pwd",
|
||||||
"type": "password",
|
"type": "password",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Set the password for encryption.",
|
"en": "Set the password for encryption.",
|
||||||
"fr": "Définissez le mot de passe de chiffrement."
|
"fr": "Définissez le mot de passe de chiffrement."
|
||||||
},
|
},
|
||||||
"help": {
|
"help": {
|
||||||
"en": "It's needed if you use backup encryption.",
|
"en": "It's needed if you use backup encryption.",
|
||||||
"fr": "C'est nécessaire si vous utilisez le chiffrement."
|
"fr": "C'est nécessaire si vous utilisez le chiffrement."
|
||||||
},
|
},
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "core_backup",
|
"name": "core_backup",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Would you like to backup your YunoHost core ?",
|
"en": "Would you like to backup your YunoHost core ?",
|
||||||
"fr": "Souhaitez-vous effectuer des sauvegardes du système YunoHost ?"
|
"fr": "Souhaitez-vous effectuer des sauvegardes du système YunoHost ?"
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "apps_backup",
|
"name": "apps_backup",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Would you like to backup your apps ?",
|
"en": "Would you like to backup your apps ?",
|
||||||
"fr": "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
|
"fr": "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
|
||||||
},
|
},
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "frequency",
|
"name": "frequency",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose the frequency of your backups ?",
|
"en": "Choose the frequency of your backups ?",
|
||||||
"fr": "Choississez la fréquence de votre backup ?"
|
"fr": "Choississez la fréquence de votre backup ?"
|
||||||
},
|
},
|
||||||
"choices" : ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"],
|
"choices" : ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"],
|
||||||
"default" : "Weekly"
|
"default" : "Weekly"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
|
||||||
|
|
||||||
while read directory <&3
|
while read directory <&3
|
||||||
do
|
do
|
||||||
if [ -n "$directory" ]
|
if [ -n "$directory" ]
|
||||||
then
|
then
|
||||||
ynh_print_info --message="Clean backup directory $directory"
|
ynh_print_info --message="Clean backup directory $directory"
|
||||||
ynh_secure_remove --file="$directory"
|
ynh_secure_remove --file="$directory"
|
||||||
fi
|
fi
|
||||||
done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)
|
done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -34,7 +34,7 @@ apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
|
||||||
file="$1"
|
file="$1"
|
||||||
|
|
||||||
if [ "$file" = "Backup_list.conf" ]; then
|
if [ "$file" = "Backup_list.conf" ]; then
|
||||||
config_file="$final_path/Backup_list.conf"
|
config_file="$final_path/Backup_list.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -49,42 +49,42 @@ ynh_backup_if_checksum_is_different --file="$config_file"
|
||||||
|
|
||||||
if [ "$file" = "Backup_list.conf" ]
|
if [ "$file" = "Backup_list.conf" ]
|
||||||
then
|
then
|
||||||
# Get the default file and overwrite the current config
|
# Get the default file and overwrite the current config
|
||||||
cp "$final_path/Backup_list.conf.default" "$config_file"
|
cp "$final_path/Backup_list.conf.default" "$config_file"
|
||||||
|
|
||||||
# Recreate the default config
|
# Recreate the default config
|
||||||
backup_dir="/home/yunohost.app/${app}/backup"
|
backup_dir="/home/yunohost.app/${app}/backup"
|
||||||
enc_backup_dir="/home/yunohost.app/${app}/encrypted_backup"
|
enc_backup_dir="/home/yunohost.app/${app}/encrypted_backup"
|
||||||
ynh_replace_string --match_string="^backup_dir=.*" --replace_string="backup_dir=$backup_dir" --target_file="$config_file"
|
ynh_replace_string --match_string="^backup_dir=.*" --replace_string="backup_dir=$backup_dir" --target_file="$config_file"
|
||||||
ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
|
ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
|
||||||
|
|
||||||
if [ $encrypt -eq 1 ]
|
if [ $encrypt -eq 1 ]
|
||||||
then
|
then
|
||||||
encrypt=true
|
encrypt=true
|
||||||
passkey="$final_path/passkey"
|
passkey="$final_path/passkey"
|
||||||
else
|
else
|
||||||
encrypt=false
|
encrypt=false
|
||||||
passkey=na
|
passkey=na
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
||||||
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
||||||
|
|
||||||
if [ $core_backup -eq 1 ]
|
if [ $core_backup -eq 1 ]
|
||||||
then
|
then
|
||||||
core_backup=true
|
core_backup=true
|
||||||
else
|
else
|
||||||
core_backup=false
|
core_backup=false
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
|
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
|
||||||
|
|
||||||
if [ $apps_backup -eq 1 ]
|
if [ $apps_backup -eq 1 ]
|
||||||
then
|
then
|
||||||
# Add all current applications to the backup
|
# Add all current applications to the backup
|
||||||
while read backup_app
|
while read backup_app
|
||||||
do
|
do
|
||||||
ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
|
ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
|
||||||
done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
|
done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
|
|
148
scripts/config
148
scripts/config
|
@ -27,9 +27,9 @@ config_file="$final_path/Backup_list.conf"
|
||||||
passkey="$final_path/passkey"
|
passkey="$final_path/passkey"
|
||||||
|
|
||||||
get_config_value() {
|
get_config_value() {
|
||||||
option_name="$1"
|
option_name="$1"
|
||||||
# Get the value of this option in the config file
|
# Get the value of this option in the config file
|
||||||
grep "^$option_name=" "$config_file" | cut -d= -f2
|
grep "^$option_name=" "$config_file" | cut -d= -f2
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,9 +58,9 @@ ynh_core_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_CORE_BACKUP:-$old_ynh_core_backu
|
||||||
# ynh_app_backup
|
# ynh_app_backup
|
||||||
if [ -n "$(get_config_value ynh_app_backup)" ]
|
if [ -n "$(get_config_value ynh_app_backup)" ]
|
||||||
then
|
then
|
||||||
old_ynh_app_backup="1"
|
old_ynh_app_backup="1"
|
||||||
else
|
else
|
||||||
old_ynh_app_backup="0"
|
old_ynh_app_backup="0"
|
||||||
fi
|
fi
|
||||||
ynh_app_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_APPS_BACKUP:-$old_ynh_app_backup}"
|
ynh_app_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_APPS_BACKUP:-$old_ynh_app_backup}"
|
||||||
|
|
||||||
|
@ -85,21 +85,21 @@ admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_htm
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
show_config() {
|
show_config() {
|
||||||
# here you are supposed to read some config file/database/other then print the values
|
# 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_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT=$encrypt"
|
ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT=$encrypt"
|
||||||
ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD="
|
ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD="
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_BACKUP_TYPES_CORE_BACKUP=$ynh_core_backup"
|
ynh_return "YNH_CONFIG_MAIN_BACKUP_TYPES_CORE_BACKUP=$ynh_core_backup"
|
||||||
ynh_return "YNH_CONFIG_MAIN_BACKUP_TYPES_APPS_BACKUP=$ynh_app_backup"
|
ynh_return "YNH_CONFIG_MAIN_BACKUP_TYPES_APPS_BACKUP=$ynh_app_backup"
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_BACKUP_OPTIONS_FREQUENCY=$frequency"
|
ynh_return "YNH_CONFIG_MAIN_BACKUP_OPTIONS_FREQUENCY=$frequency"
|
||||||
ynh_return "YNH_CONFIG_MAIN_BACKUP_OPTIONS_MAX_SIZE=$max_size"
|
ynh_return "YNH_CONFIG_MAIN_BACKUP_OPTIONS_MAX_SIZE=$max_size"
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CRON=$overwrite_cron"
|
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CRON=$overwrite_cron"
|
||||||
|
|
||||||
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -112,86 +112,86 @@ apply_config() {
|
||||||
# MODIFY THE PASSWORD
|
# MODIFY THE PASSWORD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Change the password if needed
|
# Change the password if needed
|
||||||
if [ "$encrypt" = "1" ]
|
if [ "$encrypt" = "1" ]
|
||||||
then
|
then
|
||||||
ynh_print_OFF
|
ynh_print_OFF
|
||||||
test -n "$encrypt_password" || ynh_die --message="The password for encryption can't be empty if you choose to enable encryption."
|
test -n "$encrypt_password" || ynh_die --message="The password for encryption can't be empty if you choose to enable encryption."
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
# Replace the password by the previous one
|
# Replace the password by the previous one
|
||||||
passkey="$final_path/passkey"
|
passkey="$final_path/passkey"
|
||||||
ynh_print_OFF; echo "$encrypt_password" > "$passkey"; ynh_print_ON
|
ynh_print_OFF; echo "$encrypt_password" > "$passkey"; ynh_print_ON
|
||||||
chmod 400 "$passkey"
|
chmod 400 "$passkey"
|
||||||
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY ENCRYPT SETTING
|
# MODIFY ENCRYPT SETTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Change encrypt in the config file
|
# Change encrypt in the config file
|
||||||
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY SETTINGS
|
# MODIFY SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Change ynh_core_backup in the config file
|
# Change ynh_core_backup in the config file
|
||||||
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$ynh_core_backup" --target_file="$config_file"
|
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$ynh_core_backup" --target_file="$config_file"
|
||||||
|
|
||||||
# Change ynh_app_backup in the config file
|
# Change ynh_app_backup in the config file
|
||||||
if [ "$ynh_app_backup" = "1" ] && [ "$old_ynh_app_backup" = "0" ]
|
if [ "$ynh_app_backup" = "1" ] && [ "$old_ynh_app_backup" = "0" ]
|
||||||
then
|
then
|
||||||
# If ynh_app_backup changed from false to true.
|
# If ynh_app_backup changed from false to true.
|
||||||
# Add all current applications to the backup
|
# Add all current applications to the backup
|
||||||
while read backup_app
|
while read backup_app
|
||||||
do
|
do
|
||||||
ynh_print_info --message="Add a backup for the app $backup_app."
|
ynh_print_info --message="Add a backup for the app $backup_app."
|
||||||
ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
|
ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
|
||||||
done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
|
done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
|
||||||
elif [ "$ynh_app_backup" = "0" ] && [ "$old_ynh_app_backup" = "1" ]
|
elif [ "$ynh_app_backup" = "0" ] && [ "$old_ynh_app_backup" = "1" ]
|
||||||
then
|
then
|
||||||
# Remove all app currently backup
|
# Remove all app currently backup
|
||||||
# By deleting all line starting by 'ynh_app_backup=' and having something after '='
|
# By deleting all line starting by 'ynh_app_backup=' and having something after '='
|
||||||
sed -i "/^ynh_app_backup=.\+$/d" "$config_file"
|
sed -i "/^ynh_app_backup=.\+$/d" "$config_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change frequency in the cron file and store the value into the settings
|
# Change frequency in the cron file and store the value into the settings
|
||||||
ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
|
ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
|
||||||
if [ "$frequency" = "Daily" ]; then
|
if [ "$frequency" = "Daily" ]; then
|
||||||
cron_freq="0 2 * * *"
|
cron_freq="0 2 * * *"
|
||||||
run_freq="every day"
|
run_freq="every day"
|
||||||
elif [ "$frequency" = "Each 3 days" ]; then
|
elif [ "$frequency" = "Each 3 days" ]; then
|
||||||
cron_freq="0 2 */3 * *"
|
cron_freq="0 2 */3 * *"
|
||||||
run_freq="each 3 days"
|
run_freq="each 3 days"
|
||||||
elif [ "$frequency" = "Weekly" ]; then
|
elif [ "$frequency" = "Weekly" ]; then
|
||||||
cron_freq="0 2 * * 0"
|
cron_freq="0 2 * * 0"
|
||||||
run_freq="once a week on sunday"
|
run_freq="once a week on sunday"
|
||||||
elif [ "$frequency" = "Biweekly" ]; then
|
elif [ "$frequency" = "Biweekly" ]; then
|
||||||
cron_freq="0 2 * * 0/2"
|
cron_freq="0 2 * * 0/2"
|
||||||
run_freq="one sunday out of two"
|
run_freq="one sunday out of two"
|
||||||
else # Monthly
|
else # Monthly
|
||||||
cron_freq="0 2 1 * *"
|
cron_freq="0 2 1 * *"
|
||||||
run_freq="once a month on the first sunday"
|
run_freq="once a month on the first sunday"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string=".* root" --replace_string="$cron_freq root" --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string=".* root" --replace_string="$cron_freq root" --target_file=/etc/cron.d/$app
|
||||||
|
|
||||||
# Change max_size in the config file
|
# Change max_size in the config file
|
||||||
ynh_replace_string --match_string="^max_size=.*" --replace_string="max_size=$max_size" --target_file="$config_file"
|
ynh_replace_string --match_string="^max_size=.*" --replace_string="max_size=$max_size" --target_file="$config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY OVERWRITTING SETTINGS
|
# MODIFY OVERWRITTING SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set overwrite_cron
|
# Set overwrite_cron
|
||||||
ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron"
|
ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY EMAIL SETTING
|
# MODIFY EMAIL SETTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set admin_mail_html
|
# Set admin_mail_html
|
||||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -201,6 +201,6 @@ apply_config() {
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
show) show_config;;
|
show) show_config;;
|
||||||
apply) apply_config;;
|
apply) apply_config;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -40,9 +40,9 @@ final_path=/opt/yunohost/$app
|
||||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
if [ $encrypt -eq 1 ]; then
|
if [ $encrypt -eq 1 ]; then
|
||||||
ynh_print_OFF
|
ynh_print_OFF
|
||||||
test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
|
test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -103,33 +103,33 @@ ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_bac
|
||||||
|
|
||||||
if [ $encrypt -eq 1 ]
|
if [ $encrypt -eq 1 ]
|
||||||
then
|
then
|
||||||
encrypt=true
|
encrypt=true
|
||||||
|
|
||||||
passkey="$final_path/passkey"
|
passkey="$final_path/passkey"
|
||||||
ynh_print_OFF; echo "$encryption_pwd" > "$passkey"; ynh_print_ON
|
ynh_print_OFF; echo "$encryption_pwd" > "$passkey"; ynh_print_ON
|
||||||
chmod 400 "$passkey"
|
chmod 400 "$passkey"
|
||||||
else
|
else
|
||||||
encrypt=false
|
encrypt=false
|
||||||
passkey=na
|
passkey=na
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
||||||
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
||||||
|
|
||||||
if [ $core_backup -eq 1 ]
|
if [ $core_backup -eq 1 ]
|
||||||
then
|
then
|
||||||
core_backup=true
|
core_backup=true
|
||||||
else
|
else
|
||||||
core_backup=false
|
core_backup=false
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
|
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
|
||||||
|
|
||||||
if [ $apps_backup -eq 1 ]
|
if [ $apps_backup -eq 1 ]
|
||||||
then
|
then
|
||||||
# Add all current applications to the backup
|
# Add all current applications to the backup
|
||||||
while read backup_app
|
while read backup_app
|
||||||
do
|
do
|
||||||
ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
|
ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
|
||||||
done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
|
done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
|
@ -154,20 +154,20 @@ cp ../conf/cron /etc/cron.d/$app
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
|
||||||
if [ "$frequency" = "Daily" ]; then
|
if [ "$frequency" = "Daily" ]; then
|
||||||
cron_freq="0 2 * * *"
|
cron_freq="0 2 * * *"
|
||||||
run_freq="every day"
|
run_freq="every day"
|
||||||
elif [ "$frequency" = "Each 3 days" ]; then
|
elif [ "$frequency" = "Each 3 days" ]; then
|
||||||
cron_freq="0 2 */3 * *"
|
cron_freq="0 2 */3 * *"
|
||||||
run_freq="each 3 days"
|
run_freq="each 3 days"
|
||||||
elif [ "$frequency" = "Weekly" ]; then
|
elif [ "$frequency" = "Weekly" ]; then
|
||||||
cron_freq="0 2 * * 0"
|
cron_freq="0 2 * * 0"
|
||||||
run_freq="once a week on sunday"
|
run_freq="once a week on sunday"
|
||||||
elif [ "$frequency" = "Biweekly" ]; then
|
elif [ "$frequency" = "Biweekly" ]; then
|
||||||
cron_freq="0 2 * * 0/2"
|
cron_freq="0 2 * * 0/2"
|
||||||
run_freq="one sunday out of two"
|
run_freq="one sunday out of two"
|
||||||
else # Monthly
|
else # Monthly
|
||||||
cron_freq="0 2 1 * *"
|
cron_freq="0 2 1 * *"
|
||||||
run_freq="once a month on the first sunday"
|
run_freq="once a month on the first sunday"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
|
||||||
|
|
||||||
|
@ -207,13 +207,13 @@ ynh_print_info --message="$Informations"
|
||||||
|
|
||||||
if [ "$encrypt" = "true" ]
|
if [ "$encrypt" = "true" ]
|
||||||
then
|
then
|
||||||
ynh_print_OFF
|
ynh_print_OFF
|
||||||
encrypt_message="Your password for encryption is '$encryption_pwd'
|
encrypt_message="Your password for encryption is '$encryption_pwd'
|
||||||
|
|
||||||
"
|
"
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
else
|
else
|
||||||
encrypt_message=""
|
encrypt_message=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get main domain and buid the url of the admin panel of the app.
|
# Get main domain and buid the url of the admin panel of the app.
|
||||||
|
|
|
@ -34,7 +34,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
ynh_script_progression --message="Validating restoration parameters..."
|
ynh_script_progression --message="Validating restoration parameters..."
|
||||||
|
|
||||||
test ! -d $final_path \
|
test ! -d $final_path \
|
||||||
|| ynh_die --message="There is already a directory: $final_path "
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORATION STEPS
|
# STANDARD RESTORATION STEPS
|
||||||
|
|
|
@ -39,38 +39,38 @@ ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
# If encrypt doesn't exist, create it
|
# If encrypt doesn't exist, create it
|
||||||
if [ -z "$encrypt" ]; then
|
if [ -z "$encrypt" ]; then
|
||||||
encrypt="$(grep "^encrypt=" "$final_path/Backup_list.conf" | cut -d= -f2)"
|
encrypt="$(grep "^encrypt=" "$final_path/Backup_list.conf" | cut -d= -f2)"
|
||||||
if [ "$encrypt" = true ]; then
|
if [ "$encrypt" = true ]; then
|
||||||
encrypt=1
|
encrypt=1
|
||||||
else
|
else
|
||||||
encrypt=0
|
encrypt=0
|
||||||
fi
|
fi
|
||||||
ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
|
ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If core_backup doesn't exist, create it
|
# If core_backup doesn't exist, create it
|
||||||
if [ -z "$core_backup" ]; then
|
if [ -z "$core_backup" ]; then
|
||||||
core_backup="$(grep "^ynh_core_backup=" "$final_path/Backup_list.conf" | cut -d= -f2)"
|
core_backup="$(grep "^ynh_core_backup=" "$final_path/Backup_list.conf" | cut -d= -f2)"
|
||||||
ynh_app_setting_set --app=$app --key=core_backup --value=$core_backup
|
ynh_app_setting_set --app=$app --key=core_backup --value=$core_backup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If apps_backup doesn't exist, create it
|
# If apps_backup doesn't exist, create it
|
||||||
if [ -z "$apps_backup" ]; then
|
if [ -z "$apps_backup" ]; then
|
||||||
apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$final_path/Backup_list.conf")"
|
apps_backup="$(grep --count --max-count=1 "^ynh_app_backup=" "$final_path/Backup_list.conf")"
|
||||||
ynh_app_setting_set --app=$app --key=apps_backup --value=$apps_backup
|
ynh_app_setting_set --app=$app --key=apps_backup --value=$apps_backup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If overwrite_cron doesn't exist, create it
|
# If overwrite_cron doesn't exist, create it
|
||||||
if [ -z "$overwrite_cron" ]; then
|
if [ -z "$overwrite_cron" ]; then
|
||||||
overwrite_cron=1
|
overwrite_cron=1
|
||||||
ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
|
ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
|
||||||
fi
|
fi
|
||||||
|
|
||||||
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
||||||
# If admin_mail_html doesn't exist, create it
|
# If admin_mail_html doesn't exist, create it
|
||||||
if [ -z "$admin_mail_html" ]; then
|
if [ -z "$admin_mail_html" ]; then
|
||||||
admin_mail_html=1
|
admin_mail_html=1
|
||||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -81,8 +81,8 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# restore it if the upgrade fails
|
# restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
@ -95,9 +95,9 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=2
|
ynh_script_progression --message="Upgrading source files..." --weight=2
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source --dest_dir="$final_path"
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -127,32 +127,32 @@ ynh_script_progression --message="Updating the cron file..."
|
||||||
# Overwrite the cron file only if it's allowed
|
# Overwrite the cron file only if it's allowed
|
||||||
if [ $overwrite_cron -eq 1 ]
|
if [ $overwrite_cron -eq 1 ]
|
||||||
then
|
then
|
||||||
# Verify the checksum and backup the file if it's different
|
# Verify the checksum and backup the file if it's different
|
||||||
ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
|
ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
|
||||||
|
|
||||||
cp ../conf/cron /etc/cron.d/$app
|
cp ../conf/cron /etc/cron.d/$app
|
||||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/cron.d/$app
|
||||||
ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
|
||||||
if [ "$frequency" = "Daily" ]; then
|
if [ "$frequency" = "Daily" ]; then
|
||||||
cron_freq="0 2 * * *"
|
cron_freq="0 2 * * *"
|
||||||
run_freq="every day"
|
run_freq="every day"
|
||||||
elif [ "$frequency" = "Each 3 days" ]; then
|
elif [ "$frequency" = "Each 3 days" ]; then
|
||||||
cron_freq="0 2 */3 * *"
|
cron_freq="0 2 */3 * *"
|
||||||
run_freq="each 3 days"
|
run_freq="each 3 days"
|
||||||
elif [ "$frequency" = "Weekly" ]; then
|
elif [ "$frequency" = "Weekly" ]; then
|
||||||
cron_freq="0 2 * * 0"
|
cron_freq="0 2 * * 0"
|
||||||
run_freq="once a week on sunday"
|
run_freq="once a week on sunday"
|
||||||
elif [ "$frequency" = "Biweekly" ]; then
|
elif [ "$frequency" = "Biweekly" ]; then
|
||||||
cron_freq="0 2 * * 0/2"
|
cron_freq="0 2 * * 0/2"
|
||||||
run_freq="one sunday out of two"
|
run_freq="one sunday out of two"
|
||||||
else # Monthly
|
else # Monthly
|
||||||
cron_freq="0 2 1 * *"
|
cron_freq="0 2 1 * *"
|
||||||
run_freq="once a month on the first sunday"
|
run_freq="once a month on the first sunday"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
|
ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
|
||||||
|
|
||||||
# Recalculate and store the config file checksum into the app settings
|
# Recalculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum --file="/etc/cron.d/$app"
|
ynh_store_file_checksum --file="/etc/cron.d/$app"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue