install 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # causes the shell to exit if any subcommand or pipeline returns a non-zero status
  3. set -e
  4. # This is a multi-instance app, meaning it can be installed several times independently
  5. # The id of the app as stated in the manifest is available as $YNH_APP_ID
  6. # The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
  7. # The app instance name is available as $YNH_APP_INSTANCE_NAME
  8. # - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
  9. # - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
  10. # - ynhexample__{N} for the subsequent installations, with N=3,4, ...
  11. # The app instance name is probably what you are interested the most, since this is
  12. # guaranteed to be unique. This is a good unique identifier to define installation path,
  13. # db names, ...
  14. app=$YNH_APP_INSTANCE_NAME
  15. # Retrieve arguments
  16. domain=$YNH_APP_ARG_DOMAIN
  17. path=$YNH_APP_ARG_PATH
  18. admin=$YNH_APP_ARG_ADMIN
  19. is_public=$YNH_APP_ARG_IS_PUBLIC
  20. language=$YNH_APP_ARG_LANGUAGE
  21. # Save app settings
  22. sudo yunohost app setting $app admin -v "$admin"
  23. sudo yunohost app setting $app is_public -v "$is_public"
  24. sudo yunohost app setting $app language -v "$language"
  25. # Check domain/path availability
  26. sudo yunohost app checkurl $domain$path -a $app \
  27. || (echo "Path not available: $domain$path" && exit 1)
  28. # Copy source files
  29. final_path=/var/www/$app
  30. sudo mkdir -p $final_path
  31. sudo cp -a ../sources/. $final_path
  32. # Set permissions to app files
  33. # you may need to make some file and/or directory writeable by www-data (nginx user)
  34. sudo chown -R root:root $final_path
  35. # If your app use a MySQL database you can use these lines to bootstrap
  36. # a database, an associated user and save the password in app settings
  37. # db_pwd=$(openssl rand -hex 15)
  38. # sudo yunohost app initdb $app -p $db_pwd
  39. # sudo yunohost app setting $app mysqlpwd -v $db_pwd
  40. # Modify Nginx configuration file and copy it to Nginx conf directory
  41. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  42. sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
  43. # If a dedicated php-fpm process is used:
  44. # Don't forget to modify ../conf/nginx.conf accordingly or your app will not work!
  45. #
  46. #sudo sed -i "s@YNH_WWW_APP@$app@g" ../conf/nginx.conf
  47. sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
  48. # If a dedicated php-fpm process is used:
  49. # Adjustment and copy dedicated php-fpm conf file
  50. # Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work!
  51. #
  52. #sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
  53. #sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/php-fpm.conf
  54. #finalphpconf=/etc/php5/fpm/pool.d/$app.conf
  55. #sudo cp ../conf/php-fpm.conf $finalphpconf
  56. #sudo chown root: $finalphpconf
  57. #sudo chmod 644 $finalphpconf
  58. # If app is public, add url to SSOWat conf as skipped_uris
  59. if [[ $is_public -eq 1 ]];
  60. then
  61. # unprotected_uris allows SSO credentials to be passed anyway.
  62. sudo yunohost app setting $app unprotected_uris -v "/"
  63. fi
  64. # If dedicated php-fpm process:
  65. #
  66. #sudo service php5-fpm reload
  67. # Restart services
  68. sudo service nginx reload