install 3.3 KB

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