install 2.1 KB

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