setup_user.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/sh
  2. # Copyright 2022 Felix Freeman <libsys@hacktivista.org>
  3. #
  4. # This script is licensed under the 'MIT No Attribution' license terms. I don't
  5. # want attribution nor exclusive rights over it, but I'd love that you free your
  6. # software too.
  7. if [ "$HAWESE_ENV" = 'development' ]; then
  8. mkdir -p ~/.config/composer
  9. cat <<- EOF > ~/.config/composer/config.json
  10. {
  11. "repositories": [
  12. EOF
  13. for project in $PROJECTS; do
  14. project_dir=${project#hawese-}
  15. if [ ! -d "$project_dir" ]; then
  16. git clone "https://git.hackware.cl/$project" "$project_dir"
  17. fi
  18. if [ "$project" != 'userland' ]; then
  19. cat <<- EOF >> ~/.config/composer/config.json
  20. {
  21. "type": "path",
  22. "url": "/opt/hawese/$project_dir/",
  23. "options": {
  24. "symlink": true
  25. }
  26. },
  27. EOF
  28. fi
  29. done
  30. sed -i -e '$ s/.$//' ~/.config/composer/config.json
  31. printf " ]\n}\n" >> ~/.config/composer/config.json
  32. fi
  33. for project in $PROJECTS; do
  34. if [ ! -d "$project" ]; then
  35. test "$project" != 'userland' && test "$project" != 'hawese-core' \
  36. && composer require --no-install "hackware/$project=*"
  37. fi
  38. done
  39. composer install
  40. composer run collect-public
  41. cat << EOF > .env
  42. APP_NAME='Hackware Web Services'
  43. APP_ENV=$(test "$HAWESE_ENV" = 'development' && echo 'local' || echo "$HAWESE_ENV")
  44. APP_KEY=$(pwgen -sc 36)
  45. APP_DEBUG=true
  46. APP_URL=https://$ENDPOINT
  47. APP_TIMEZONE=America/Santiago
  48. CORS_ALLOW_ORIGINS=https://$CORS_ENDPOINT
  49. LOG_CHANNEL=stack
  50. LOG_SLACK_WEBHOOK_URL=
  51. DB_CONNECTION=mysql
  52. DB_HOST=127.0.0.1
  53. DB_PORT=3306
  54. DB_DATABASE=$DB_NAME
  55. DB_USERNAME=$DB_USER
  56. DB_PASSWORD='$DB_PASS'
  57. MAIL_DRIVER=smtp
  58. MAIL_HOST=smtp.mailtrap.io
  59. MAIL_PORT=2525
  60. MAIL_USERNAME=
  61. MAIL_PASSWORD=
  62. MAIL_ENCRYPTION=tls
  63. MAIL_FROM_ADDRESS=hello@example.com
  64. MAIL_FROM_NAME="Example app"
  65. CACHE_DRIVER=file
  66. QUEUE_CONNECTION=sync
  67. EOF
  68. case "$PROJECTS" in *wallet*) cat <<- EOF >> .env
  69. WALLET_SOURCE_URL=https://git.hackware.cl/hawese-wallet
  70. WALLET_TRANSACTION_TYPES=hawese_payment
  71. WALLET_DUE_AFTER='1 month'
  72. WALLET_ADD_FUNDS_URL=${WALLET_ADD_FUNDS_URL:-https://$CORS_ENDPOINT/add-funds}
  73. WALLET_REMIND_DUE='1 day, 2 days, 3 days, 1 week'
  74. PAYMENT_WALLET_ENDPOINT=https://$ENDPOINT
  75. EOF
  76. esac
  77. case "$PROJECTS" in *payment*) cat <<- EOF >> .env
  78. PAYMENT_SOURCE_URL=https://git.hackware.cl/hawese-payment
  79. PAYMENT_RETURN_URL=${PAYMENT_RETURN_URL:-https://$CORS_ENDPOINT/add-funds/verify}
  80. PAYMENT_CORE_AUTH_TOKEN=
  81. KHIPU_RECEIVER_ID=
  82. KHIPU_SECRET_KEY=
  83. FLOW_API_KEY=
  84. FLOW_SECRET_KEY=
  85. FLOW_TEST_MODE=true
  86. EOF
  87. esac
  88. case "$PROJECTS" in *userland*)
  89. cd userland
  90. npm install
  91. echo VUE_APP_HAWESE_ENDPOINT="https://$ENDPOINT" > .env
  92. npm run build
  93. cd -
  94. esac
  95. php artisan migrate
  96. initial_token=$(composer run seed | sed -ne 's/Initial system token: \(.*\)/\1/p')
  97. sed -i -e "s/PAYMENT_CORE_AUTH_TOKEN=/PAYMENT_CORE_AUTH_TOKEN=$initial_token/" .env