_common.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. #=================================================
  3. # COMMON VARIABLES
  4. #=================================================
  5. ## new filenames starting 0.00~ynh5
  6. # make a filename/service name from domain/path
  7. if [[ "$path" == /* ]]; then
  8. url_path="${path:1}"
  9. fi
  10. if [[ "__${url_path}__" == '____' ]]; then
  11. flohmarkt_filename="$domain"
  12. else
  13. flohmarkt_filename="$domain-${url_path}"
  14. fi
  15. # just in case we append $app to make it really unique
  16. # this filename is used for logfile name and systemd.service name
  17. flohmarkt_filename="${flohmarkt_filename//[^A-Za-z0-9._-]/_}_${app}"
  18. #
  19. # directory flohmarkts software is installed to
  20. # contains ./venv and ./src as sub-directories
  21. flohmarkt_install="/opt/${id}/${domain}/${url_path}"
  22. flohmarkt_venv_dir="${flohmarkt_install}/venv"
  23. flohmarkt_app_dir="${flohmarkt_install}/app"
  24. # directory containing logfiles
  25. flohmarkt_log_dir="/var/log/${id}/${flohmarkt_filename}"
  26. # filename for logfiles - ¡ojo! if not ends with .log will be interpreted
  27. # as a directory by ynh_use_logrotate
  28. # https://github.com/YunoHost/issues/issues/2383
  29. flohmarkt_logfile="${flohmarkt_log_dir}/${app}.log"
  30. # flohmarkt data_dir follows the naming convention above
  31. # its saved to settings during install
  32. flohmarkt_data_dir="/home/yunohost.app/${flohmarkt_filename}"
  33. ## old filenames before 0.00~ynh5 - for reference and needed to
  34. # migrate (see below)
  35. flohmarkt_old_install="$install_dir/$app/"
  36. flohmarkt_old_venv_dir="$install_dir/venv"
  37. flohmarkt_old_log_dir="/var/log/$app/"
  38. flohmarkt_old_logfile="$app"
  39. flohmarkt_old_service="$app"
  40. #=================================================
  41. # PERSONAL HELPERS
  42. #=================================================
  43. # move files and directories to their new places
  44. flohmarkt_ynh_upgrade_path_ynh5() {
  45. # flohmarkt and couchdb are already stopped in upgrade script
  46. # move install_dir
  47. # move venv_dir
  48. # move data_dir
  49. # move systemd.service
  50. # move logfiles
  51. # update settings for above
  52. false
  53. # there's still some work open - see above
  54. }
  55. # to follow the naming convention including information about domain
  56. # and path we do create the data_dir here and save it during install
  57. # to the settings of this flohmarkt instance
  58. flohmarkt_ynh_create_data_dir() {
  59. mkdir -p $data_dir
  60. chown $app: $data_dir
  61. chmod 750 $data_dir
  62. }
  63. #=================================================
  64. # EXPERIMENTAL HELPERS
  65. #=================================================
  66. #=================================================
  67. # FUTURE OFFICIAL HELPERS
  68. #=================================================