2
0

install 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. #=================================================
  3. # IMPORT GENERIC HELPERS
  4. #=================================================
  5. source _common.sh
  6. source /usr/share/yunohost/helpers
  7. #=================================================
  8. # INITIALIZE AND STORE SETTINGS
  9. #=================================================
  10. if [ "$encrypt" -eq 1 ] && [ -z "$encryption_pwd" ]; then
  11. ynh_die --message="encryption_pwd can't be empty if you choose to enable encryption."
  12. fi
  13. # Not saved as settings by default
  14. ynh_app_setting_set --app="$app" --key="encryption_pwd" --value="$encryption_pwd"
  15. _set_frequencies
  16. ynh_app_setting_set --app="$app" --key=overwrite_cron --value=1
  17. # echo "encfs encfs/security-information boolean true" | debconf-set-selections
  18. #REMOVEME? ynh_install_app_dependencies $pkg_dependencies
  19. #=================================================
  20. # DOWNLOAD, CHECK AND UNPACK SOURCE
  21. #=================================================
  22. ynh_script_progression --message="Setting up source files..." --weight=3
  23. # Download, check integrity, uncompress and patch the source from app.src
  24. ynh_setup_source --dest_dir="$install_dir"
  25. chown -R "root:root" "$install_dir"
  26. chown -R "root:root" "$data_dir"
  27. #=================================================
  28. # CONFIGURE ARCHIVIST
  29. #=================================================
  30. ynh_script_progression --message="Configuring Archivist..." --weight=2
  31. if [ "$encrypt" -eq 1 ]; then
  32. encrypt=true
  33. passkey="$install_dir/passkey"
  34. echo "$encryption_pwd" > "$passkey"
  35. chmod 400 "$passkey"
  36. else
  37. encrypt=false
  38. passkey=na
  39. fi
  40. if [ "$core_backup" -eq 1 ]; then
  41. core_backup=true
  42. else
  43. core_backup=false
  44. fi
  45. config_file="$install_dir/Backup_list.conf"
  46. cp "$install_dir/Backup_list.conf.default" "$config_file"
  47. ynh_replace_string --target_file="$config_file" --match_string="^backup_dir=.*" --replace_string="backup_dir=$data_dir/backup"
  48. ynh_replace_string --target_file="$config_file" --match_string="^enc_backup_dir=.*" --replace_string="enc_backup_dir=$data_dir/encrypted_backup"
  49. ynh_replace_string --target_file="$config_file" --match_string="^encrypt=.*" --replace_string="encrypt=$encrypt"
  50. ynh_replace_string --target_file="$config_file" --match_string="^cryptpass=.*" --replace_string="cryptpass=$passkey"
  51. ynh_replace_string --target_file="$config_file" --match_string="^ynh_core_backup=.*" --replace_string="ynh_core_backup=$core_backup"
  52. if [ $apps_backup -eq 1 ]; then
  53. # Add all current applications to the backup
  54. while read -r backup_app; do
  55. ynh_replace_string --target_file="$config_file" --match_string="^ynh_app_backup=$" --replace_string="ynh_app_backup=$backup_app\n&"
  56. done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
  57. fi
  58. # Calculate and store the config file checksum into the app settings
  59. ynh_store_file_checksum --file="$config_file"
  60. #=================================================
  61. # SYSTEM CONFIGURATION
  62. #=================================================
  63. ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
  64. # Use logrotate to manage application logfile(s)
  65. ynh_use_logrotate
  66. # Add Cron configuration file
  67. ynh_add_config --template="archivist.cron" --destination="/etc/cron.d/$app"
  68. #=================================================
  69. # END OF SCRIPT
  70. #=================================================
  71. ynh_script_progression --message="Installation of $app completed" --last