mirror of
https://github.com/YunoHost-Apps/archivist_ynh.git
synced 2024-09-03 18:15:55 +02:00
Merge pull request #21 from YunoHost-Apps/testing
Use toml for config-panel and actions
This commit is contained in:
commit
fadbc4e64f
10 changed files with 183 additions and 120 deletions
58
CHANGELOG.md
Normal file
58
CHANGELOG.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
## Unreleased
|
||||
- Nothing for now...
|
||||
|
||||
## [1.0~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/21) - 2019-12-03
|
||||
|
||||
#### Changed
|
||||
- [Use toml for config-panel and actions](https://github.com/YunoHost-Apps/archivist_ynh/pull/21/commits/21b7e746095a9dccf9dda9a58cc8ec5afdd87736)
|
||||
* [Update to v1.0 (Add support of BACKUP_CORE_ONLY)](https://github.com/YunoHost-Apps/archivist_ynh/pull/21/commits/9b3cfeab5b1260ce0d277f81bfd32e5326a2118d)
|
||||
|
||||
## [0.9~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/18) - 2019-08-12
|
||||
|
||||
#### Changed
|
||||
* [Update to v0.9 (Recreate enc_backup_dir)](https://github.com/YunoHost-Apps/archivist_ynh/pull/19/commits/536e472adac15e9b6064cac5df5bf7656bc82437)
|
||||
|
||||
## [0.8~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/18) - 2019-06-30
|
||||
|
||||
#### Changed
|
||||
* [Update to v0.8 (Add b2 sender)](https://github.com/YunoHost-Apps/archivist_ynh/pull/18/commits/3a52c10afeb129fb62779e9370bb27a052375d02)
|
||||
|
||||
|
||||
## [0.7~ynh3](https://github.com/YunoHost-Apps/archivist_ynh/pull/16) - 2019-02-03
|
||||
|
||||
#### Added
|
||||
- [Add progression bar](https://github.com/YunoHost-Apps/archivist_ynh/pull/16/commits/c626cb05d0f28d570f0eabbf6dbd13ca42ba58e4)
|
||||
* [Changelog & html email](https://github.com/YunoHost-Apps/archivist_ynh/pull/16/commits/0b5345ba355c0ea0ebd86a1c5f076097d83c9118)
|
||||
|
||||
|
||||
## [0.7~ynh2](https://github.com/YunoHost-Apps/archivist_ynh/pull/15) - 2019-01-21
|
||||
|
||||
#### Changed
|
||||
- [Update to last standart](https://github.com/YunoHost-Apps/archivist_ynh/pull/15/commits/1c783c7376ed5a1013e4a88b3a4056bddb679b8c)
|
||||
|
||||
|
||||
## [0.7~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/14) - 2018-11-24
|
||||
|
||||
#### Changed
|
||||
* [Update to v0.7 (Fix backup --ignore arguments)](https://github.com/YunoHost-Apps/archivist_ynh/pull/14/commits/8c23cb555883676e80f1110b197ce821f5c66e1c)
|
||||
|
||||
|
||||
## [0.6~ynh2](https://github.com/YunoHost-Apps/archivist_ynh/pull/13) - 2018-09-30
|
||||
|
||||
#### Added
|
||||
* [Add actions and config-panel](https://github.com/YunoHost-Apps/archivist_ynh/pull/13/commits/ee8fd678273ca38df12b826f765544b8a00e1e39)
|
||||
|
||||
|
||||
## [0.6~ynh2](https://github.com/YunoHost-Apps/archivist_ynh/pull/11) - 2018-07-16
|
||||
|
||||
#### Changed
|
||||
- [Upgrade helpers](https://github.com/YunoHost-Apps/archivist_ynh/pull/11/commits/d3b202985184d475725cff72d75d79dc922926cb)
|
||||
|
||||
|
||||
## [0.6~ynh1](https://github.com/YunoHost-Apps/archivist_ynh/pull/5) - 2018-01-04
|
||||
|
||||
#### Changed
|
||||
* [Update to 0.6 (Pre and post backup)](https://github.com/YunoHost-Apps/archivist_ynh/pull/5/commits/11a5747a450745801acd6a47e609c054759d1224)
|
|
@ -15,7 +15,7 @@ It can also makes backups of specified directories.
|
|||
Your backups can be send to many other places, local or distant.
|
||||
Archivist is automatically launched periodicaly to update your backups and send the modifications to the other places.
|
||||
|
||||
**Shipped version:** 0.9
|
||||
**Shipped version:** 1.0
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Il peut également faire des sauvegardes de répertoires spécifiques.
|
|||
Vos sauvegardes peuvent être envoyées à de nombreux autres endroits, locaux ou distants.
|
||||
Archivist est automatiquement lancé périodiquement pour mettre à jour vos sauvegardes et envoyer les modifications aux autres emplacements.
|
||||
|
||||
**Version embarquée:** 0.9
|
||||
**Version embarquée:** 1.0
|
||||
|
||||
## Captures d'écran
|
||||
|
||||
|
|
33
actions.json
33
actions.json
|
@ -1,33 +0,0 @@
|
|||
[{
|
||||
"id": "force_backup",
|
||||
"name": "Create a new backup",
|
||||
"command": "/bin/bash scripts/actions/force_backup",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Run Archivist to create a new backup.",
|
||||
"fr": "Lance Archivist pour créer un nouveau backup."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "clean_backups",
|
||||
"name": "Clean all previous backup files",
|
||||
"command": "/bin/bash scripts/actions/clean_backups",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Remove all previous backup files made by Archivist.",
|
||||
"fr": "Supprime tout les précédents backups créés par Archivist."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "reset_default_config",
|
||||
"name": "Reset the config file and restore a default one.",
|
||||
"command": "/bin/bash scripts/actions/reset_default_config \"Backup_list.conf\"",
|
||||
"user": "root",
|
||||
"accepted_return_codes": [0],
|
||||
"description": {
|
||||
"en": "Reset the config file Backup_list.conf.",
|
||||
"fr": "Réinitialise le fichier de configuration Backup_list.conf."
|
||||
}
|
||||
}]
|
26
actions.toml
Normal file
26
actions.toml
Normal file
|
@ -0,0 +1,26 @@
|
|||
[force_backup]
|
||||
name = "Create a new backup"
|
||||
command = "/bin/bash scripts/actions/force_backup"
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Run Archivist to create a new backup."
|
||||
|
||||
[clean_backups]
|
||||
name = "Clean all previous backup files"
|
||||
command = "/bin/bash scripts/actions/clean_backups"
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Remove all previous backup files made by Archivist."
|
||||
|
||||
[reset_default_config]
|
||||
name = "Reset the config file and restore a default one."
|
||||
command = "/bin/bash scripts/actions/reset_default_config \"Backup_list.conf\""
|
||||
# user = "root" # optional
|
||||
# cwd = "/" # optional
|
||||
# accepted_return_codes = [0, 1, 2, 3] # optional
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the config file Backup_list.conf."
|
|
@ -1,5 +1,5 @@
|
|||
SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/v0.9.tar.gz
|
||||
SOURCE_SUM=d67285ff66909faa31f696fc552015a4
|
||||
SOURCE_URL=https://github.com/maniackcrudelis/archivist/archive/v1.0.tar.gz
|
||||
SOURCE_SUM=1f98a67aae8b5c4f76e43cb027f4f3bf
|
||||
SOURCE_SUM_PRG=md5sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
{
|
||||
"name": "Archivist configuration panel",
|
||||
"version": "0.1",
|
||||
"panel": [{
|
||||
"name": "Archivist configuration",
|
||||
"id": "main",
|
||||
"sections": [{
|
||||
"name": "Encryption",
|
||||
"id": "encryption",
|
||||
"options": [{
|
||||
"name": "Do you want to encrypt your backups ?",
|
||||
"id": "encrypt",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}, {
|
||||
"name": "Set the password for encryption",
|
||||
"help": "A password is needed if encryption is activated.",
|
||||
"id": "encryption_pwd",
|
||||
"type": "password",
|
||||
"optional": true
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "Backup",
|
||||
"id": "backup_types",
|
||||
"options": [{
|
||||
"name": "Would you like to backup your YunoHost core ?",
|
||||
"id": "core_backup",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}, {
|
||||
"name": "Would you like to backup your apps ?",
|
||||
"help": "WARNING: Changing this value will either remove backup for all apps or add all current apps to the backup.",
|
||||
"id": "apps_backup",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "Backup options",
|
||||
"id": "backup_options",
|
||||
"options": [{
|
||||
"name": "Choose the frequency of your backups ?",
|
||||
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>Daily, Each 3 days, Weekly, Biweekly, Monthly.",
|
||||
"id": "frequency",
|
||||
"type": "text",
|
||||
"//": "\"choices\" : [\"Daily\", \"Each 3 days\", \"Weekly\", \"Biweekly\", \"Monthly\"]",
|
||||
"default" : "Weekly"
|
||||
}, {
|
||||
"name": "Max size for each backup in Mb",
|
||||
"help": "Specify the max size of each backup for the following option file_to_backup.</br>This option is a soft limit, that means the script will try to limit each backup to this max size if it can.</br>But there's 2 limitations, for a single directory, it can't makes more than one backup file, even if the files in this directory exceed this maximum size.</br>And, if there's some files in a directory, next to subdirectories, it'll make only one backup for this files.</br>So this limit will be applied to split the backup by its subdirectories to avoid to have only one big backup.",
|
||||
"id": "max_size",
|
||||
"type": "number",
|
||||
"default": 500
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "Overwriting config files",
|
||||
"id": "overwrite_files",
|
||||
"options": [{
|
||||
"name": "Overwrite the cron file during the upgrade ?",
|
||||
"help": "If the file is overwritten, a backup will be created.",
|
||||
"id": "overwrite_cron",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "Global configuration",
|
||||
"id": "global_config",
|
||||
"options": [{
|
||||
"name": "Send HTML email to admin ?",
|
||||
"help": "Allow app scripts to send HTML mails instead of plain text.",
|
||||
"id": "email_type",
|
||||
"type": "bool",
|
||||
"default": true
|
||||
}]
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
65
config_panel.toml
Normal file
65
config_panel.toml
Normal file
|
@ -0,0 +1,65 @@
|
|||
version = "0.1"
|
||||
name = "Archivist configuration panel"
|
||||
|
||||
[main]
|
||||
name = "Archivist configuration"
|
||||
|
||||
[main.encryption]
|
||||
name = "Encryption"
|
||||
|
||||
[main.encryption.encrypt]
|
||||
ask = "Do you want to encrypt your backups ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[main.encryption.encryption_pwd]
|
||||
ask = "Set the password for encryption"
|
||||
type = "password"
|
||||
optional = true
|
||||
help = "A password is needed if encryption is activated."
|
||||
|
||||
[main.backup_types]
|
||||
name = "Backup"
|
||||
|
||||
[main.backup_types.core_backup]
|
||||
ask = "Would you like to backup your YunoHost core ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[main.backup_types.apps_backup]
|
||||
ask = "Would you like to backup your apps ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "WARNING: Changing this value will either remove backup for all apps or add all current apps to the backup."
|
||||
|
||||
[main.backup_options]
|
||||
name = "Backup options"
|
||||
|
||||
[main.backup_options.frequency]
|
||||
ask = "Choose the frequency of your backups ?"
|
||||
choices = ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"]
|
||||
default = "Weekly"
|
||||
|
||||
[main.backup_options.max_size]
|
||||
ask = "Max size for each backup in Mb"
|
||||
type = "number"
|
||||
default = 500
|
||||
help = "Specify the max size of each backup for the following option file_to_backup.</br>This option is a soft limit, that means the script will try to limit each backup to this max size if it can.</br>But there's 2 limitations, for a single directory, it can't makes more than one backup file, even if the files in this directory exceed this maximum size.</br>And, if there's some files in a directory, next to subdirectories, it'll make only one backup for this files.</br>So this limit will be applied to split the backup by its subdirectories to avoid to have only one big backup."
|
||||
|
||||
[main.overwrite_files]
|
||||
name = "Overwriting config files"
|
||||
|
||||
[main.overwrite_files.overwrite_cron]
|
||||
ask = "Overwrite the cron file during the upgrade ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "If the file is overwritten, a backup will be created."
|
||||
|
||||
[main.global_config]
|
||||
name = "Global configuration"
|
||||
|
||||
[main.global_config.email_type]
|
||||
ask = "Send HTML email to admin ?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
help = "Allow app scripts to send HTML mails instead of plain text."
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Automatic backups.",
|
||||
"fr": "Sauvegardes automatiques."
|
||||
},
|
||||
"version": "0.9~ynh1",
|
||||
"version": "1.0~ynh1",
|
||||
"url": "https://github.com/maniackcrudelis/archivist",
|
||||
"license": "GPL-3.0",
|
||||
"maintainer": {
|
||||
|
|
|
@ -44,14 +44,17 @@ get_config_value() {
|
|||
# Encryption
|
||||
old_encrypt="$(get_config_value encrypt)"
|
||||
encrypt="${YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT:-$old_encrypt}"
|
||||
|
||||
# Encryption password
|
||||
ynh_print_OFF
|
||||
old_encrypt_password="$(cat $passkey)"
|
||||
encrypt_password="${YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD:-$old_encrypt_password}"
|
||||
ynh_print_ON
|
||||
|
||||
# ynh_core_backup
|
||||
old_ynh_core_backup="$(get_config_value ynh_core_backup)"
|
||||
ynh_core_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_CORE_BACKUP:-$old_ynh_core_backup}"
|
||||
|
||||
# ynh_app_backup
|
||||
if [ -n "$(get_config_value ynh_app_backup)" ]
|
||||
then
|
||||
|
@ -60,9 +63,11 @@ else
|
|||
old_ynh_app_backup="false"
|
||||
fi
|
||||
ynh_app_backup="${YNH_CONFIG_MAIN_BACKUP_TYPES_APPS_BACKUP:-$old_ynh_app_backup}"
|
||||
|
||||
# Frequency
|
||||
old_frequency="$(grep "^frequency: " "/etc/yunohost/apps/$app/settings.yml" | cut -d' ' -f2)"
|
||||
frequency="${YNH_CONFIG_MAIN_BACKUP_OPTIONS_FREQUENCY:-$old_frequency}"
|
||||
|
||||
# Max size
|
||||
old_max_size="$(get_config_value max_size)"
|
||||
max_size="${YNH_CONFIG_MAIN_BACKUP_OPTIONS_MAX_SIZE:-$old_max_size}"
|
||||
|
@ -84,6 +89,7 @@ admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_htm
|
|||
show_config() {
|
||||
# here you are supposed to read some config file/database/other then print the values
|
||||
# echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
|
||||
|
||||
echo "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT=$encrypt"
|
||||
echo "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD="
|
||||
|
||||
|
@ -103,8 +109,14 @@ show_config() {
|
|||
#=================================================
|
||||
|
||||
apply_config() {
|
||||
|
||||
#=================================================
|
||||
# MODIFY THE PASSWORD
|
||||
#=================================================
|
||||
|
||||
# Change the password if needed
|
||||
if [ "$encrypt" = "true" ]; then
|
||||
if [ "$encrypt" = "true" ]
|
||||
then
|
||||
ynh_print_OFF
|
||||
test -n "$encrypt_password" || ynh_die --message="The password for encryption can't be empty if you choose to enable encryption."
|
||||
ynh_print_ON
|
||||
|
@ -115,9 +127,17 @@ apply_config() {
|
|||
ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# MODIFY ENCRYPT SETTING
|
||||
#=================================================
|
||||
|
||||
# Change encrypt in the config file
|
||||
ynh_replace_string --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt" --target_file="$config_file"
|
||||
|
||||
#=================================================
|
||||
# MODIFY SETTINGS
|
||||
#=================================================
|
||||
|
||||
# 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"
|
||||
|
||||
|
@ -161,10 +181,18 @@ apply_config() {
|
|||
# Change max_size in the config file
|
||||
ynh_replace_string --match_string="^max_size=.*" --replace_string="max_size=$max_size" --target_file="$config_file"
|
||||
|
||||
#=================================================
|
||||
# MODIFY OVERWRITTING SETTINGS
|
||||
#=================================================
|
||||
|
||||
# Set overwrite_cron
|
||||
overwrite_cron=$(bool_to_01 $overwrite_cron)
|
||||
ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron"
|
||||
|
||||
#=================================================
|
||||
# MODIFY EMAIL SETTING
|
||||
#=================================================
|
||||
|
||||
# Set admin_mail_html
|
||||
admin_mail_html=$(bool_to_01 $admin_mail_html)
|
||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
|
||||
|
|
Loading…
Add table
Reference in a new issue