diff --git a/check_process b/check_process
index 71bc6ae..78dfba2 100644
--- a/check_process
+++ b/check_process
@@ -1,47 +1,47 @@
;; Test complet
- ; Manifest
- encrypt=1
- encryption_pwd="password"
- core_backup=1
- apps_backup=1
- frequency="Weekly"
- ; Config_panel
- main.encryption.encrypt=1|0
- main.encryption.encryption_pwd=password1|password2
- main.backup_types.core_backup=1|0
- main.backup_types.apps_backup=1|0
- main.backup_options.frequency=Daily|Each 3 days|Weekly|Biweekly|Monthly
- main.backup_options.max_size=1000
- main.overwrite_files.overwrite_cron=1|0
- main.global_config.email_type=1|0
- ; Checks
- pkg_linter=1
- setup_sub_dir=0
- setup_root=0
- setup_nourl=1
- setup_private=0
- setup_public=0
- upgrade=1
- upgrade=1 from_commit=2b2793737d5e1374659cbb74838d10162a2147e6
- backup_restore=1
- multi_instance=1
- port_already_use=0
- change_url=0
- config_panel=0
+ ; Manifest
+ encrypt=1
+ encryption_pwd="password"
+ core_backup=1
+ apps_backup=1
+ frequency="Weekly"
+ ; Config_panel
+ main.encryption.encrypt=1|0
+ main.encryption.encryption_pwd=password1|password2
+ main.backup_types.core_backup=1|0
+ main.backup_types.apps_backup=1|0
+ main.backup_options.frequency=Daily|Each 3 days|Weekly|Biweekly|Monthly
+ main.backup_options.max_size=1000
+ main.overwrite_files.overwrite_cron=1|0
+ main.global_config.email_type=1|0
+ ; Checks
+ pkg_linter=1
+ setup_sub_dir=0
+ setup_root=0
+ setup_nourl=1
+ setup_private=0
+ setup_public=0
+ upgrade=1
+ upgrade=1 from_commit=2b2793737d5e1374659cbb74838d10162a2147e6
+ backup_restore=1
+ multi_instance=1
+ port_already_use=0
+ change_url=0
+ config_panel=0
;; Test actions without encryption
# Actions can't be tested with the encryption on, because LXC does not support fuse.
- ; Manifest
- encrypt=0
- encryption_pwd=""
- core_backup=1
- apps_backup=1
- ; Checks
- setup_nourl=1
- actions=1
+ ; Manifest
+ encrypt=0
+ encryption_pwd=""
+ core_backup=1
+ apps_backup=1
+ ; Checks
+ setup_nourl=1
+ actions=1
;;; Options
Email=
Notification=change
;;; Upgrade options
- ; commit=2b2793737d5e1374659cbb74838d10162a2147e6
- name=03 Nov 2017 2b2793737d5e1374659cbb74838d10162a2147e6
- manifest_arg=encrypt=1&encryption_pwd="password"&core_backup=1&apps_backup=1&frequency="Weekly"&
+ ; commit=2b2793737d5e1374659cbb74838d10162a2147e6
+ name=03 Nov 2017 2b2793737d5e1374659cbb74838d10162a2147e6
+ manifest_arg=encrypt=1&encryption_pwd="password"&core_backup=1&apps_backup=1&frequency="Weekly"&
diff --git a/doc/.gitkeep b/doc/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md
new file mode 100644
index 0000000..97ac7bd
--- /dev/null
+++ b/doc/DESCRIPTION.md
@@ -0,0 +1,6 @@
+Archivist is an automatic backup system for your server.
+It able to makes backups of your YunoHost core and your apps by using the YunoHost backup command.
+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.
+
diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md
new file mode 100644
index 0000000..3620dca
--- /dev/null
+++ b/doc/DESCRIPTION_fr.md
@@ -0,0 +1,5 @@
+Archivist est un système de sauvegarde automatique pour votre serveur.
+Il est capable de faire des sauvegardes de votre noyau YunoHost et de vos applications en utilisant la commande de backup de YunoHost.
+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.
diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md
new file mode 100644
index 0000000..77bc777
--- /dev/null
+++ b/doc/DISCLAIMER.md
@@ -0,0 +1,10 @@
+## Configuration
+
+The configuration of archivist can be changed in the file /opt/yunohost/archivist/Backup_list.conf
+Please read the [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration.md) about the configuration of archivist for more informations.
+
+## Limitations
+
+* Encfs, which be used to encrypt the data, is not fully secured.
+Have a look to the [security audit](https://defuse.ca/audits/encfs.htm) to have more informations.
+
diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md
new file mode 100644
index 0000000..c60bfb2
--- /dev/null
+++ b/doc/DISCLAIMER_fr.md
@@ -0,0 +1,10 @@
+## Configuration
+
+La configuration d'archivist peut être modifiée dans le fichier /opt/yunohost/archivist/Backup_list.conf
+Veuillez lire la [documentation](https://github.com/maniackcrudelis/archivist/blob/master/Configuration_fr.md) sur la configuration d'archivist pour plus d'informations.
+
+## Limitations
+
+* Encfs, qui est utilisé pour chiffrer les données, n'est pas parfaitement sécurisé.
+Consultez l'[audit de sécurité](https://defuse.ca/audits/encfs.htm) pour avoir plus d'informations.
+
diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/manifest.json b/manifest.json
index 59e9e91..dc71ccb 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,8 +6,13 @@
"en": "Automatic backups",
"fr": "Sauvegardes automatiques"
},
- "version": "1.3.2~ynh1",
+ "version": "1.3.2~ynh2",
"url": "https://github.com/maniackcrudelis/archivist",
+ "upstream": {
+ "license": "GPL-3.0",
+ "website": "https://github.com/maniackcrudelis/archivist",
+ "code": "https://github.com/maniackcrudelis/archivist"
+ },
"license": "GPL-3.0",
"maintainer": {
"name": "",
@@ -23,7 +28,7 @@
"multi_instance": true,
"services": [],
"arguments": {
- "install" : [
+ "install": [
{
"name": "encrypt",
"type": "boolean",
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 28561af..cb75eab 100755
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -4,8 +4,12 @@
# COMMON VARIABLES
#=================================================
-# Dependencies
-app_depencencies="rsync encfs sshpass ccrypt lzop zstd lzip"
+# dependencies used by the app
+pkg_dependencies="rsync encfs sshpass ccrypt lzop zstd lzip"
+
+#=================================================
+# PERSONAL HELPERS
+#=================================================
#=================================================
# EXPERIMENTAL HELPERS
@@ -99,8 +103,8 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
echo "$mail_message" > mail_to_send
# If a html email is required. Apply html tags to the message.
- if [ "$admin_mail_html" -eq 1 ]
- then
+ if [ "$admin_mail_html" -eq 1 ]
+ then
# Insert 'br' tags at each ending of lines.
ynh_replace_string "$" "
" mail_to_send
@@ -199,7 +203,7 @@ include conf.d/yunohost_panel.conf.inc;
# The current config file will redirect all requests to the root of the app.
# To keep the full path, we can use the following rewrite rule:
- # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
+ # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
# The difference will be in the $1 at the end, which keep the following queries.
# But, if it works perfectly for a html request, there's an issue with any php files.
# This files are treated as simple files, and will be downloaded by the browser.
@@ -237,134 +241,134 @@ ynh_maintenance_mode_OFF () {
#
# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
# | arg: -f --format= - Format in which the changelog will be printed
-# markdown: Default format.
-# html: Turn urls into html format.
-# plain: Plain text changelog
+# markdown: Default format.
+# html: Turn urls into html format.
+# plain: Plain text changelog
# | arg: -o --output= - Output file for the changelog file (Default ./changelog)
# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
#
# 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
- declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
- local format
- local output
- local changelog
- # Manage arguments with getopts
- ynh_handle_getopts_args "$@"
- format=${format:-markdown}
- output=${output:-changelog}
- changelog=${changelog:-../CHANGELOG.md}
+ # Declare an array to define the options of this helper.
+ local legacy_args=foc
+ declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
+ local format
+ local output
+ local changelog
+ # Manage arguments with getopts
+ ynh_handle_getopts_args "$@"
+ format=${format:-markdown}
+ output=${output:-changelog}
+ changelog=${changelog:-../CHANGELOG.md}
- local original_changelog="$changelog"
- local temp_changelog="changelog_temp"
- local final_changelog="$output"
+ local original_changelog="$changelog"
+ local temp_changelog="changelog_temp"
+ local final_changelog="$output"
- if [ ! -n "$original_changelog" ]
- then
- echo "No changelog available..." > "$final_changelog"
- echo "No changelog available..." > "${final_changelog}_lite"
- return 0
- fi
+ if [ ! -n "$original_changelog" ]
+ then
+ echo "No changelog available..." > "$final_changelog"
+ echo "No changelog available..." > "${final_changelog}_lite"
+ return 0
+ fi
- 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")
+ 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")
- # 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)
- # If there's no entry for this version yet into the changelog
- # Get the first available version
- if [ -z "$update_version_line" ]
- then
- update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
- fi
+ # 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)
+ # If there's no entry for this version yet into the changelog
+ # Get the first available version
+ if [ -z "$update_version_line" ]
+ then
+ update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
+ fi
- # Get the length of the complete changelog.
- local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
- # Cut the file before the version to update to.
- tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
+ # Get the length of the complete changelog.
+ local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
+ # Cut the file before the version to update to.
+ tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
- # Get the length of the troncated changelog.
- changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
- # Get the line of the current version into the changelog
- # Keep only the last line found
- local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
- # If there's no entry for this version into the changelog
- # Get the last available version
- if [ -z "$current_version_line" ]
- then
- current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
- fi
- # Cut the file before the current version.
- # Then grep the previous version into the changelog to get the line number of the previous version
- local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
- "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
- # If there's no previous version into the changelog
- # Go until the end of the changelog
- if [ -z "$previous_version_line" ]
- then
- previous_version_line=$changelog_length
- fi
+ # Get the length of the troncated changelog.
+ changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
+ # Get the line of the current version into the changelog
+ # Keep only the last line found
+ local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
+ # If there's no entry for this version into the changelog
+ # Get the last available version
+ if [ -z "$current_version_line" ]
+ then
+ current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
+ fi
+ # Cut the file before the current version.
+ # Then grep the previous version into the changelog to get the line number of the previous version
+ local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
+ "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
+ # If there's no previous version into the changelog
+ # Go until the end of the changelog
+ if [ -z "$previous_version_line" ]
+ then
+ previous_version_line=$changelog_length
+ fi
- # Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
- head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
+ # Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
+ head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
- if [ "$format" = "html" ]
- then
- # Replace markdown links by html links
- ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="\1)" --target_file="$final_changelog"
- ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --target_file="$final_changelog"
- elif [ "$format" = "plain" ]
- then
- # Change title format.
- ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
- # Change modifications lines format.
- ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
- fi
- # else markdown. As the file is already in markdown, nothing to do.
+ if [ "$format" = "html" ]
+ then
+ # Replace markdown links by html links
+ ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="\1)" --target_file="$final_changelog"
+ ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --target_file="$final_changelog"
+ elif [ "$format" = "plain" ]
+ then
+ # Change title format.
+ ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
+ # Change modifications lines format.
+ ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
+ fi
+ # else markdown. As the file is already in markdown, nothing to do.
- # Keep only important changes into the changelog
- # Remove all minor changes
- sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
- # Remove all blank lines (to keep a clear workspace)
- sed --in-place '/^$/d' "${final_changelog}_lite"
- # Add a blank line at the end
- echo "" >> "${final_changelog}_lite"
+ # Keep only important changes into the changelog
+ # Remove all minor changes
+ sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
+ # Remove all blank lines (to keep a clear workspace)
+ sed --in-place '/^$/d' "${final_changelog}_lite"
+ # Add a blank line at the end
+ echo "" >> "${final_changelog}_lite"
- # Clean titles if there's no significative changes
- local line
- local previous_line=""
- while read line <&3
- do
- if [ -n "$previous_line" ]
- then
- # 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"
- fi
- fi
- previous_line="$line"
- done 3< "${final_changelog}_lite"
+ # Clean titles if there's no significative changes
+ local line
+ local previous_line=""
+ while read line <&3
+ do
+ if [ -n "$previous_line" ]
+ then
+ # 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"
+ fi
+ fi
+ previous_line="$line"
+ done 3< "${final_changelog}_lite"
- # Remove all blank lines again
- sed --in-place '/^$/d' "${final_changelog}_lite"
+ # Remove all blank lines again
+ 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"
- # Remove the 2 first blank lines
- sed --in-place '1,2d' "${final_changelog}_lite"
- # Add a blank line at the end
- echo "" >> "${final_changelog}_lite"
+ # Restore changelog format with blank lines
+ ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_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
+ echo "" >> "${final_changelog}_lite"
- # If changelog are empty, add an info
- if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
- then
- echo "No changes from the changelog..." > "$final_changelog"
- fi
- if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
- then
- echo "No significative changes from the changelog..." > "${final_changelog}_lite"
- fi
+ # If changelog are empty, add an info
+ if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
+ then
+ echo "No changes from the changelog..." > "$final_changelog"
+ fi
+ if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
+ then
+ echo "No significative changes from the changelog..." > "${final_changelog}_lite"
+ fi
}
diff --git a/scripts/backup b/scripts/backup
index 26f541c..c923a19 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -26,7 +27,10 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
-# STANDARD BACKUP STEPS
+# DECLARE DATA AND CONF FILES TO BACKUP
+#=================================================
+ynh_print_info --message="Declaring files to be backed up..."
+
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
@@ -42,7 +46,7 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
-# BACKUP THE CRON FILE
+# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
diff --git a/scripts/install b/scripts/install
index 321a061..5d822cd 100755
--- a/scripts/install
+++ b/scripts/install
@@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
-# Load common variables for all scripts.
source _common.sh
source /usr/share/yunohost/helpers
@@ -38,7 +37,7 @@ final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
if [ $encrypt -eq 1 ]; then
- 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."
fi
#=================================================
@@ -65,7 +64,7 @@ ynh_script_progression --message="Installing dependencies..." --weight=15
# To find this, install the package, install also debconf-utils
# Then use `debconf-get-selections | grep package`
echo "encfs encfs/security-information boolean true" | debconf-set-selections
-ynh_install_app_dependencies $app_depencencies
+ynh_install_app_dependencies $pkg_dependencies
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@@ -99,33 +98,33 @@ ynh_replace_string --match_string="^enc_backup_dir=.*" --replace_string="enc_bac
if [ $encrypt -eq 1 ]
then
- encrypt=true
+ encrypt=true
- passkey="$final_path/passkey"
- echo "$encryption_pwd" > "$passkey"
- chmod 400 "$passkey"
+ passkey="$final_path/passkey"
+ echo "$encryption_pwd" > "$passkey"
+ chmod 400 "$passkey"
else
- encrypt=false
- passkey=na
+ encrypt=false
+ passkey=na
fi
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"
if [ $core_backup -eq 1 ]
then
- core_backup=true
+ core_backup=true
else
- core_backup=false
+ core_backup=false
fi
ynh_replace_string --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup" --target_file="$config_file"
if [ $apps_backup -eq 1 ]
then
- # Add all current applications to the backup
- while read backup_app
- do
- ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
- done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
+ # Add all current applications to the backup
+ while read backup_app
+ do
+ ynh_replace_string --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&" --target_file="$config_file"
+ done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
fi
# Calculate and store the config file checksum into the app settings
@@ -140,28 +139,26 @@ 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="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
if [ "$frequency" = "Daily" ]; then
- cron_freq="0 2 * * *"
- run_freq="every day"
+ cron_freq="0 2 * * *"
+ run_freq="every day"
elif [ "$frequency" = "Each 3 days" ]; then
- cron_freq="0 2 */3 * *"
- run_freq="each 3 days"
+ cron_freq="0 2 */3 * *"
+ run_freq="each 3 days"
elif [ "$frequency" = "Weekly" ]; then
- cron_freq="0 2 * * 0"
- run_freq="once a week on sunday"
+ cron_freq="0 2 * * 0"
+ run_freq="once a week on sunday"
elif [ "$frequency" = "Biweekly" ]; then
- cron_freq="0 2 * * 0/2"
- run_freq="one sunday out of two"
+ cron_freq="0 2 * * 0/2"
+ run_freq="one sunday out of two"
else # Monthly
- cron_freq="0 2 1 * *"
- run_freq="once a month on the first sunday"
+ cron_freq="0 2 1 * *"
+ run_freq="once a month on the first sunday"
fi
ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/etc/cron.d/$app
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="/etc/cron.d/$app"
-#=================================================
-# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@@ -169,6 +166,8 @@ ynh_store_file_checksum --file="/etc/cron.d/$app"
# Set permissions to app files
chown -R root: $final_path
+#=================================================
+# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
@@ -193,12 +192,12 @@ ynh_print_info --message="$Informations"
if [ "$encrypt" = "true" ]
then
- encrypt_message="Your password for encryption is '$encryption_pwd'
+ encrypt_message="Your password for encryption is '$encryption_pwd'
"
else
- encrypt_message=""
+ encrypt_message=""
fi
# Get main domain and buid the url of the admin panel of the app.
diff --git a/scripts/remove b/scripts/remove
index c645b3e..6a8b653 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -21,12 +21,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
-# REMOVE DEPENDENCIES
+# REMOVE LOGROTATE CONFIGURATION
#=================================================
-ynh_script_progression --message="Removing dependencies..." --weight=7
+ynh_script_progression --message="Removing logrotate configuration..."
-# Remove metapackage and its dependencies
-ynh_remove_app_dependencies
+# Remove the app-specific logrotate config
+ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
@@ -37,18 +37,19 @@ ynh_script_progression --message="Removing app main directory..."
ynh_secure_remove --file="$final_path"
#=================================================
-# REMOVE LOGROTATE CONFIGURATION
+# REMOVE DEPENDENCIES
#=================================================
-ynh_script_progression --message="Removing logrotate configuration..."
+ynh_script_progression --message="Removing dependencies..." --weight=7
-# Remove the app-specific logrotate config
-ynh_remove_logrotate
+# Remove metapackage and its dependencies
+ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
-# REMOVE THE CRON FILE
+# REMOVE VARIOUS FILES
#=================================================
+ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
diff --git a/scripts/restore b/scripts/restore
index 91c1851..9022477 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
-# Load common variables for all scripts.
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@@ -20,7 +20,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
-ynh_script_progression --message="Loading settings..."
+ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@@ -31,7 +31,8 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
-test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
+test ! -d $final_path \
+ || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
@@ -53,27 +54,25 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=17
# To find this, install the package, install also debconf-utils
# Then use `debconf-get-selections | grep package`
echo "encfs encfs/security-information boolean true" | debconf-set-selections
-ynh_install_app_dependencies $app_depencencies
+ynh_install_app_dependencies $pkg_dependencies
+
+#=================================================
+# RESTORE VARIOUS FILES
+#=================================================
+ynh_script_progression --message="Restoring various files..."
+
+ynh_restore_file --origin_path="/etc/cron.d/$app"
+
+mkdir -p "/home/yunohost.app/${app}/backup"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
+ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/$app
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
-#=================================================
-# RESTORE THE CRON FILE
-#=================================================
-
-ynh_restore_file --origin_path="/etc/cron.d/$app"
-
-#=================================================
-# RECREATE DIRECTORIES
-#=================================================
-
-mkdir -p "/home/yunohost.app/${app}/backup"
-
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index 59a8c24..55db47e 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS
#=================================================
-# Load common variables for all scripts.
source _common.sh
source /usr/share/yunohost/helpers
@@ -27,6 +26,7 @@ overwrite_cron=$(ynh_app_setting_get --app=$app --key=overwrite_cron)
#=================================================
# CHECK VERSION
#=================================================
+ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@@ -38,12 +38,14 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
- # restore it if the upgrade fails
- ynh_restore_upgradebackup
+ # Restore it if the upgrade fails
+ ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
+#=================================================
+# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@@ -51,51 +53,50 @@ ynh_script_progression --message="Ensuring downward compatibility..."
# If encrypt doesn't exist, create it
if [ -z "$encrypt" ]; then
- encrypt="$(grep "^encrypt=" "$final_path/Backup_list.conf" | cut -d= -f2)"
- if [ "$encrypt" = true ]; then
- encrypt=1
- else
- encrypt=0
- fi
- ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
+ encrypt="$(grep "^encrypt=" "$final_path/Backup_list.conf" | cut -d= -f2)"
+ if [ "$encrypt" = true ]; then
+ encrypt=1
+ else
+ encrypt=0
+ fi
+ ynh_app_setting_set --app=$app --key=encrypt --value=$encrypt
fi
# If core_backup doesn't exist, create it
if [ -z "$core_backup" ]; then
- 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
+ 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
fi
# If apps_backup doesn't exist, create it
if [ -z "$apps_backup" ]; then
- 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
+ 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
fi
# If overwrite_cron doesn't exist, create it
if [ -z "$overwrite_cron" ]; then
- overwrite_cron=1
- ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
+ overwrite_cron=1
+ ynh_app_setting_set --app=$app --key=overwrite_cron --value=$overwrite_cron
fi
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
# If admin_mail_html doesn't exist, create it
if [ -z "$admin_mail_html" ]; then
- admin_mail_html=1
- ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
+ admin_mail_html=1
+ ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
fi
-#=================================================
-# STANDARD UPGRADE STEPS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
- ynh_script_progression --message="Upgrading source files..." --weight=2
- # Download, check integrity, uncompress and patch the source from app.src
- ynh_setup_source --dest_dir="$final_path"
+ ynh_script_progression --message="Upgrading source files..." --weight=2
+
+ # Download, check integrity, uncompress and patch the source from app.src
+ ynh_setup_source --dest_dir="$final_path"
fi
#=================================================
@@ -103,7 +104,7 @@ fi
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=8
-ynh_install_app_dependencies $app_depencencies
+ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
@@ -115,34 +116,43 @@ ynh_script_progression --message="Updating the cron file..."
# Overwrite the cron file only if it's allowed
if [ $overwrite_cron -eq 1 ]
then
- # Verify the checksum and backup the file if it's different
- ynh_backup_if_checksum_is_different --file="/etc/cron.d/$app"
+ # Verify the checksum and backup the file if it's different
+ ynh_backup_if_checksum_is_different --file="/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="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
- if [ "$frequency" = "Daily" ]; then
- cron_freq="0 2 * * *"
- run_freq="every day"
- elif [ "$frequency" = "Each 3 days" ]; then
- cron_freq="0 2 */3 * *"
- run_freq="each 3 days"
- elif [ "$frequency" = "Weekly" ]; then
- cron_freq="0 2 * * 0"
- run_freq="once a week on sunday"
- elif [ "$frequency" = "Biweekly" ]; then
- cron_freq="0 2 * * 0/2"
- run_freq="one sunday out of two"
- else # Monthly
- cron_freq="0 2 1 * *"
- run_freq="once a month on the first sunday"
- fi
- ynh_replace_string --match_string="__FREQUENCY__" --replace_string="$cron_freq" --target_file=/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="__APP__" --replace_string=$app --target_file=/etc/cron.d/$app
+ if [ "$frequency" = "Daily" ]; then
+ cron_freq="0 2 * * *"
+ run_freq="every day"
+ elif [ "$frequency" = "Each 3 days" ]; then
+ cron_freq="0 2 */3 * *"
+ run_freq="each 3 days"
+ elif [ "$frequency" = "Weekly" ]; then
+ cron_freq="0 2 * * 0"
+ run_freq="once a week on sunday"
+ elif [ "$frequency" = "Biweekly" ]; then
+ cron_freq="0 2 * * 0/2"
+ run_freq="one sunday out of two"
+ else # Monthly
+ cron_freq="0 2 1 * *"
+ run_freq="once a month on the first sunday"
+ fi
+ 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
- ynh_store_file_checksum --file="/etc/cron.d/$app"
+ # Recalculate and store the config file checksum into the app settings
+ ynh_store_file_checksum --file="/etc/cron.d/$app"
fi
+#=================================================
+# SECURE FILES AND DIRECTORIES
+#=================================================
+
+# Set permissions on app files
+chown -R root: $final_path
+
+#=================================================
+# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
@@ -151,15 +161,6 @@ ynh_script_progression --message="Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SECURE FILES AND DIRECTORIES
-#=================================================
-
-# Set permissions on app files
-chown -R root: $final_path
-
#=================================================
# SEND A README FOR THE ADMIN
#=================================================