install 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # causes the shell to exit if any subcommand or pipeline returns a non-zero status
  3. set -e
  4. # The last argument is the app instance name
  5. app=${!#}
  6. # Retrieve arguments
  7. domain=$1
  8. path=$2
  9. admin=$3
  10. is_public=$4
  11. language=$5
  12. # Save app settings
  13. sudo yunohost app setting $app admin -v "$admin"
  14. sudo yunohost app setting $app is_public -v "$is_public"
  15. sudo yunohost app setting $app language -v "$language"
  16. # Check domain/path availability
  17. sudo yunohost app checkurl $domain$path -a $app \
  18. || (echo "Path not available: $domain$path" && exit 1)
  19. # Copy source files
  20. final_path=/var/www/$app
  21. sudo mkdir -p $final_path
  22. sudo cp -a ../sources/. $final_path
  23. # Set permissions to app files
  24. # you may need to make some file and/or directory writeable by www-data (nginx user)
  25. sudo chown -R root:root $final_path
  26. # If your app use a MySQL database you can use these lines to bootstrap
  27. # a database, an associated user and save the password in app settings
  28. # db_pwd=$(openssl rand -hex 15)
  29. # sudo yunohost app initdb $app -p $db_pwd
  30. # sudo yunohost app setting $app mysqlpwd -v $db_pwd
  31. # Modify Nginx configuration file and copy it to Nginx conf directory
  32. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  33. sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
  34. # If a dedicated php-fpm process is used:
  35. # Don't forget to modify ../conf/nginx.conf accordingly or your app will not work!
  36. #
  37. #sudo sed -i "s@YNH_WWW_APP@$app@g" ../conf/nginx.conf
  38. sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
  39. # If a dedicated php-fpm process is used:
  40. # Adjustment and copy dedicated php-fpm conf file
  41. # Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work!
  42. #
  43. #sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
  44. #sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/php-fpm.conf
  45. #finalphpconf=/etc/php5/fpm/pool.d/$app.conf
  46. #sudo cp ../conf/php-fpm.conf $finalphpconf
  47. #sudo chown root: $finalphpconf
  48. #sudo chmod 644 $finalphpconf
  49. # If app is public, add url to SSOWat conf as skipped_uris
  50. if [[ $is_public -eq 1 ]];
  51. then
  52. # unprotected_uris allows SSO credentials to be passed anyway.
  53. sudo yunohost app setting $app unprotected_uris -v "/"
  54. fi
  55. # If dedicated php-fpm process:
  56. #
  57. #sudo service php5-fpm reload
  58. # Restart services
  59. sudo service nginx reload