install 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. # Save app settings
  21. sudo yunohost app setting $app admin -v "$admin"
  22. sudo yunohost app setting $app is_public -v "$is_public"
  23. # Check domain/path availability
  24. sudo yunohost app checkurl $domain$path -a $app \
  25. || (echo "Path not available: $domain$path" && exit 1)
  26. # Copy source files
  27. final_path=/var/www/$app
  28. sudo mkdir -p $final_path
  29. sudo cp -a ../sources/. $final_path
  30. # Set permissions to app files
  31. # you may need to make some file and/or directory writeable by www-data (nginx user)
  32. sudo chown -R root:root $final_path
  33. # If your app use a MySQL database you can use these lines to bootstrap
  34. # a database, an associated user and save the password in app settings
  35. # db_pwd=$(openssl rand -hex 15)
  36. # sudo yunohost app initdb $app -p $db_pwd
  37. # sudo yunohost app setting $app mysqlpwd -v $db_pwd
  38. # Modify Nginx configuration file and copy it to Nginx conf directory
  39. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  40. sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
  41. # If a dedicated php-fpm process is used:
  42. # Don't forget to modify ../conf/nginx.conf accordingly or your app will not work!
  43. #
  44. #sudo sed -i "s@YNH_WWW_APP@$app@g" ../conf/nginx.conf
  45. sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
  46. # If a dedicated php-fpm process is used:
  47. # Adjustment and copy dedicated php-fpm conf file
  48. # Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work!
  49. #
  50. #sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
  51. #sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/php-fpm.conf
  52. #finalphpconf=/etc/php5/fpm/pool.d/$app.conf
  53. #sudo cp ../conf/php-fpm.conf $finalphpconf
  54. #sudo chown root: $finalphpconf
  55. #sudo chmod 644 $finalphpconf
  56. # If app is public, add url to SSOWat conf as skipped_uris
  57. if [ "$is_public" = "Yes" ];
  58. then
  59. # unprotected_uris allows SSO credentials to be passed anyway.
  60. sudo yunohost app setting $app unprotected_uris -v "/"
  61. fi
  62. # If dedicated php-fpm process:
  63. #
  64. #sudo service php5-fpm reload
  65. # Restart services
  66. sudo service nginx reload
  67. sudo yunohost app ssowatconf