Advertisement
zemf4you

Generate .env (bash)

Jul 16th, 2023 (edited)
1,136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. read -rp "registry: " registry
  4. read -rp "tg bot token: " bot_token
  5. read -rp "jwt key [generated]: " jwt_key
  6. jwt_key=${jwt_key:-$(openssl rand -hex 32)}
  7. read -rp "admin chat id: " admin_chat_id
  8. read -rp "service chat id: " service_chat_id
  9. read -rp "cloudpayments public key: " pay_public
  10. read -rp "cloudpayments secret key: " pay_api_key
  11. read -rp "domain: " domain
  12. read -rp "nginx port [80]: " nginx_port
  13. nginx_port=${nginx_port:-80}
  14. read -rp "backend port [5000]: " backend_port
  15. backend_port=${backend_port:-5000}
  16. read -rp "frontend port [3000]: " frontend_port
  17. frontend_port=${frontend_port:-3000}
  18. read -rp "default time zone: " timezone
  19. read -rp "db user [user]: " postgres_user
  20. postgres_user=${postgres_user:-user}
  21. read -rp "db password [generated]: " postgres_password
  22. postgres_password=${postgres_password:-$(openssl rand -hex 16)}
  23. read -rp "db name [postgres]: " postgres_db
  24. postgres_db=${postgres_db:-postgres}
  25. read -rp "db port [5432]: " postgres_port
  26. postgres_port=${postgres_port:-5432}
  27.  
  28. env_file=".env"
  29. if [ -f "$env_file" ]; then
  30.   env_file="generated.env"
  31. fi
  32.  
  33. cat << EOF > $env_file
  34. REGISTRY=$registry
  35. BOT_TOKEN=$bot_token
  36. JWT_KEY=$jwt_key
  37. ADMIN_CHAT_ID=$admin_chat_id
  38. SERVICE_CHAT_ID=$service_chat_id
  39. PAY_PUBLIC=$pay_public
  40. PAY_API_KEY=$pay_api_key
  41. DOMAIN=$domain
  42. NGINX_PORT=$nginx_port
  43. BACKEND_PORT=$backend_port
  44. FRONTEND_PORT=$frontend_port
  45. TIMEZONE=$timezone
  46. POSTGRES_USER=$postgres_user
  47. POSTGRES_PASSWORD=$postgres_password
  48. POSTGRES_DB=$postgres_db
  49. POSTGRES_PORT=$postgres_port
  50. EOF
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement