Maniack Crudelis 5 年 前
コミット
c27d048561
8 ファイル変更299 行追加299 行削除
  1. 30 30
      check_process
  2. 73 73
      manifest.json
  3. 5 5
      scripts/actions/clean_backups
  4. 37 37
      scripts/actions/reset_default_config
  5. 77 77
      scripts/config
  6. 30 30
      scripts/install
  7. 1 1
      scripts/restore
  8. 46 46
      scripts/upgrade

+ 30 - 30
check_process

@@ -1,10 +1,10 @@
 ;; Test complet
-	; Manifest
-		encrypt=1
-		encryption_pwd="password"
-		core_backup=1
-		apps_backup=1
-		frequency="Weekly"
+    ; 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
@@ -14,36 +14,36 @@
         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
+    ; 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=1
 ;; 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
+    ; Manifest
+        encrypt=0
+        encryption_pwd=""
+        core_backup=1
+        apps_backup=1
+    ; Checks
+        setup_nourl=1
         actions=1
 ;;; Levels
-	Level 5=auto
+    Level 5=auto
 ;;; 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"&

+ 73 - 73
manifest.json

@@ -1,75 +1,75 @@
 {
-	"name": "Archivist",
-	"id": "archivist",
-	"packaging_format": 1,
-	"description": {
-		"en": "Automatic backups.",
-		"fr": "Sauvegardes automatiques."
-	},
-	"version": "1.0.1~ynh3",
-	"url": "https://github.com/maniackcrudelis/archivist",
-	"license": "GPL-3.0",
-	"maintainer": {
-		"name": "Maniack Crudelis",
-		"email": "maniackc_dev@crudelis.fr"
-	},
-	"requirements": {
-		"yunohost": ">= 3.6.0"
-	},
-	"multi_instance": true,
-	"services": [],
-	"arguments": {
-		"install" : [
-			{
-				"name": "encrypt",
-				"type": "boolean",
-				"ask": {
-					"en": "Do you want to encrypt your backups ?",
-					"fr": "Voulez-vous chiffrer vos sauvegardes ?"
-				},
-				"default": true
-			},
-			{
-				"name": "encryption_pwd",
-				"type": "password",
-				"ask": {
-					"en": "Set the password for encryption.",
-					"fr": "Définissez le mot de passe de chiffrement."
-				},
-				"help": {
-					"en": "It's needed if you use backup encryption.",
-					"fr": "C'est nécessaire si vous utilisez le chiffrement."
-				},
-				"optional": true
-			},
-			{
-				"name": "core_backup",
-				"type": "boolean",
-				"ask": {
-					"en": "Would you like to backup your YunoHost core ?",
-					"fr": "Souhaitez-vous effectuer des sauvegardes du système YunoHost ?"
-				},
-				"default": true
-			},
-			{
-				"name": "apps_backup",
-				"type": "boolean",
-				"ask": {
-					"en": "Would you like to backup your apps ?",
-					"fr": "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
-				},
-				"default": true
-			},
-			{
-				"name": "frequency",
-				"type": "string",
-				"ask": {
-					"en": "Choose the frequency of your backups ?",
-					"fr": "Choississez la fréquence de votre backup ?"
-				},
-				"choices" : ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"],
-				"default" : "Weekly"
-			}
-		]
-	}
+    "name": "Archivist",
+    "id": "archivist",
+    "packaging_format": 1,
+    "description": {
+        "en": "Automatic backups.",
+        "fr": "Sauvegardes automatiques."
+    },
+    "version": "1.0.1~ynh3",
+    "url": "https://github.com/maniackcrudelis/archivist",
+    "license": "GPL-3.0",
+    "maintainer": {
+        "name": "Maniack Crudelis",
+        "email": "maniackc_dev@crudelis.fr"
+    },
+    "requirements": {
+        "yunohost": ">= 3.6.0"
+    },
+    "multi_instance": true,
+    "services": [],
+    "arguments": {
+        "install" : [
+            {
+                "name": "encrypt",
+                "type": "boolean",
+                "ask": {
+                    "en": "Do you want to encrypt your backups ?",
+                    "fr": "Voulez-vous chiffrer vos sauvegardes ?"
+                },
+                "default": true
+            },
+            {
+                "name": "encryption_pwd",
+                "type": "password",
+                "ask": {
+                    "en": "Set the password for encryption.",
+                    "fr": "Définissez le mot de passe de chiffrement."
+                },
+                "help": {
+                    "en": "It's needed if you use backup encryption.",
+                    "fr": "C'est nécessaire si vous utilisez le chiffrement."
+                },
+                "optional": true
+            },
+            {
+                "name": "core_backup",
+                "type": "boolean",
+                "ask": {
+                    "en": "Would you like to backup your YunoHost core ?",
+                    "fr": "Souhaitez-vous effectuer des sauvegardes du système YunoHost ?"
+                },
+                "default": true
+            },
+            {
+                "name": "apps_backup",
+                "type": "boolean",
+                "ask": {
+                    "en": "Would you like to backup your apps ?",
+                    "fr": "Souhaitez-vous effectuer des sauvegardes de vos applications ?"
+                },
+                "default": true
+            },
+            {
+                "name": "frequency",
+                "type": "string",
+                "ask": {
+                    "en": "Choose the frequency of your backups ?",
+                    "fr": "Choississez la fréquence de votre backup ?"
+                },
+                "choices" : ["Daily", "Each 3 days", "Weekly", "Biweekly", "Monthly"],
+                "default" : "Weekly"
+            }
+        ]
+    }
 }

+ 5 - 5
scripts/actions/clean_backups

@@ -44,11 +44,11 @@ backup_dir="$(grep "^backup_dir=" "$final_path/Backup_list.conf" | cut -d= -f2)"
 
 while read directory <&3
 do
-	if [ -n "$directory" ]
-	then
-		ynh_print_info --message="Clean backup directory $directory"
-		ynh_secure_remove --file="$directory"
-	fi
+    if [ -n "$directory" ]
+    then
+        ynh_print_info --message="Clean backup directory $directory"
+        ynh_secure_remove --file="$directory"
+    fi
 done 3<<< $(find "$backup_dir" -maxdepth 1 -mindepth 1 -type d)
 
 #=================================================

+ 37 - 37
scripts/actions/reset_default_config

@@ -34,7 +34,7 @@ apps_backup=$(ynh_app_setting_get --app=$app --key=apps_backup)
 file="$1"
 
 if [ "$file" = "Backup_list.conf" ]; then
-	config_file="$final_path/Backup_list.conf"
+    config_file="$final_path/Backup_list.conf"
 fi
 
 #=================================================
@@ -49,42 +49,42 @@ ynh_backup_if_checksum_is_different --file="$config_file"
 
 if [ "$file" = "Backup_list.conf" ]
 then
-	# Get the default file and overwrite the current config
-	cp "$final_path/Backup_list.conf.default" "$config_file"
-
-	# Recreate the default config
-	backup_dir="/home/yunohost.app/${app}/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="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
-
-	if [ $encrypt -eq 1 ]
-	then
-		encrypt=true
-		passkey="$final_path/passkey"
-	else
-		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
-	else
-		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 -i | grep id: | sed 's/.*id: //')"
-	fi
+    # Get the default file and overwrite the current config
+    cp "$final_path/Backup_list.conf.default" "$config_file"
+
+    # Recreate the default config
+    backup_dir="/home/yunohost.app/${app}/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="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$enc_backup_dir" --target_file="$config_file"
+
+    if [ $encrypt -eq 1 ]
+    then
+        encrypt=true
+        passkey="$final_path/passkey"
+    else
+        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
+    else
+        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 -i | grep id: | sed 's/.*id: //')"
+    fi
 fi
 
 # Calculate and store the config file checksum into the app settings

+ 77 - 77
scripts/config

@@ -27,9 +27,9 @@ config_file="$final_path/Backup_list.conf"
 passkey="$final_path/passkey"
 
 get_config_value() {
-	option_name="$1"
-	# Get the value of this option in the config file
-	grep "^$option_name=" "$config_file" | cut -d= -f2
+    option_name="$1"
+    # Get the value of this option in the config file
+    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
 if [ -n "$(get_config_value ynh_app_backup)" ]
 then
-	old_ynh_app_backup="1"
+    old_ynh_app_backup="1"
 else
-	old_ynh_app_backup="0"
+    old_ynh_app_backup="0"
 fi
 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() {
-	# 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"
+    # here you are supposed to read some config file/database/other then print the values
+    # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
 
-	ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT=$encrypt"
-	ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPTION_PWD="
+    ynh_return "YNH_CONFIG_MAIN_ENCRYPTION_ENCRYPT=$encrypt"
+    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_APPS_BACKUP=$ynh_app_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_OPTIONS_FREQUENCY=$frequency"
-	ynh_return "YNH_CONFIG_MAIN_BACKUP_OPTIONS_MAX_SIZE=$max_size"
+    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_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
     #=================================================
 
-	# Change the password if needed
-	if [ "$encrypt" = "1" ]
-	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
-		# Replace the password by the previous one
-		passkey="$final_path/passkey"
-		ynh_print_OFF; echo "$encrypt_password" > "$passkey"; ynh_print_ON
-		chmod 400 "$passkey"
-		ynh_replace_string --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey" --target_file="$config_file"
-	fi
+    # Change the password if needed
+    if [ "$encrypt" = "1" ]
+    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
+        # Replace the password by the previous one
+        passkey="$final_path/passkey"
+        ynh_print_OFF; echo "$encrypt_password" > "$passkey"; ynh_print_ON
+        chmod 400 "$passkey"
+        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"
+    # 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"
-
-	# Change ynh_app_backup in the config file
-	if [ "$ynh_app_backup" = "1" ] && [ "$old_ynh_app_backup" = "0" ]
-	then
-		# If ynh_app_backup changed from false to true.
-		# Add all current applications to the backup
-		while read backup_app
-		do
-			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"
-		done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
-	elif [ "$ynh_app_backup" = "0" ] && [ "$old_ynh_app_backup" = "1" ]
-	then
-		# Remove all app currently backup
-		# By deleting all line starting by 'ynh_app_backup=' and having something after '='
-		sed -i "/^ynh_app_backup=.\+$/d" "$config_file"
-	fi
-
-	# Change frequency in the cron file and store the value into the settings
-	ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
-	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=".* root" --replace_string="$cron_freq root" --target_file=/etc/cron.d/$app
-
-	# Change max_size in the config file
-	ynh_replace_string --match_string="^max_size=.*" --replace_string="max_size=$max_size" --target_file="$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"
+
+    # Change ynh_app_backup in the config file
+    if [ "$ynh_app_backup" = "1" ] && [ "$old_ynh_app_backup" = "0" ]
+    then
+        # If ynh_app_backup changed from false to true.
+        # Add all current applications to the backup
+        while read backup_app
+        do
+            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"
+        done <<< "$(yunohost app list -i | grep id: | sed 's/.*id: //')"
+    elif [ "$ynh_app_backup" = "0" ] && [ "$old_ynh_app_backup" = "1" ]
+    then
+        # Remove all app currently backup
+        # By deleting all line starting by 'ynh_app_backup=' and having something after '='
+        sed -i "/^ynh_app_backup=.\+$/d" "$config_file"
+    fi
+
+    # Change frequency in the cron file and store the value into the settings
+    ynh_app_setting_set --app=$app --key=frequency --value="$frequency"
+    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=".* root" --replace_string="$cron_freq root" --target_file=/etc/cron.d/$app
+
+    # 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
-	ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron"
+    # Set overwrite_cron
+    ynh_app_setting_set --app=$app --key=overwrite_cron --value="$overwrite_cron"
 
     #=================================================
     # MODIFY EMAIL SETTING
     #=================================================
 
-	# Set admin_mail_html
-	ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
+    # Set 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
-  show) show_config;;
-  apply) apply_config;;
+show) show_config;;
+apply) apply_config;;
 esac

+ 30 - 30
scripts/install

@@ -40,9 +40,9 @@ final_path=/opt/yunohost/$app
 test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
 
 if [ $encrypt -eq 1 ]; then
-	ynh_print_OFF
-	test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
-	ynh_print_ON
+    ynh_print_OFF
+    test -n "$encryption_pwd" || ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
+    ynh_print_ON
 fi
 
 #=================================================
@@ -103,33 +103,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"
-	ynh_print_OFF; echo "$encryption_pwd" > "$passkey"; ynh_print_ON
-	chmod 400 "$passkey"
+    passkey="$final_path/passkey"
+    ynh_print_OFF; echo "$encryption_pwd" > "$passkey"; ynh_print_ON
+    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 -i | 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 -i | grep id: | sed 's/.*id: //')"
 fi
 
 # 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="__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
 
@@ -207,13 +207,13 @@ ynh_print_info --message="$Informations"
 
 if [ "$encrypt" = "true" ]
 then
-	ynh_print_OFF
-	encrypt_message="Your password for encryption is '$encryption_pwd'
+    ynh_print_OFF
+    encrypt_message="Your password for encryption is '$encryption_pwd'
 
 "
-	ynh_print_ON
+    ynh_print_ON
 else
-	encrypt_message=""
+    encrypt_message=""
 fi
 
 # Get main domain and buid the url of the admin panel of the app.

+ 1 - 1
scripts/restore

@@ -34,7 +34,7 @@ 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 "
+    || ynh_die --message="There is already a directory: $final_path "
 
 #=================================================
 # STANDARD RESTORATION STEPS

+ 46 - 46
scripts/upgrade

@@ -39,38 +39,38 @@ 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
 
 #=================================================
@@ -81,8 +81,8 @@ 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
@@ -95,9 +95,9 @@ ynh_abort_if_errors
 
 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
 
 #=================================================
@@ -127,32 +127,32 @@ 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"
-
-	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"
+    # 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
+
+    # Recalculate and store the config file checksum into the app settings
+    ynh_store_file_checksum --file="/etc/cron.d/$app"
 fi
 
 #=================================================