dev-build.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # Define the execution arguments.
  3. ports=(-p 1618:1618)
  4. case ${1} in
  5. http)
  6. sudo sysctl net.ipv4.ip_unprivileged_port_start=80
  7. ports+=(-p 80:80 -p 443:443)
  8. ;;
  9. http-unpriv)
  10. ports+=(-p 8080:80 -p 8443:443)
  11. ;;
  12. ols)
  13. ports+=(-p 7080:7080)
  14. ;;
  15. ssh)
  16. ports+=(-p 2222:22)
  17. ;;
  18. no-cache)
  19. podman image prune -a
  20. podman rmi localhost/os -f
  21. ;;
  22. esac
  23. echo "=> Building the container..."
  24. make build
  25. podman build -t os:latest .
  26. # TODO: Re-add --env 'DEV_MODE=true' after Echo v4.13.0 release.
  27. podman run --name os -d \
  28. --env 'LOG_LEVEL=debug' --env 'PRIMARY_VHOST=goinfinite.local' \
  29. --hostname=goinfinite.local --cpus=2 --memory=2g --rm \
  30. --volume "$(pwd)/bin:/infinite/bin:Z,ro,bind,slave" \
  31. "${ports[@]}" -it os:latest
  32. echo "=> Waiting for the container to start..."
  33. sleep 5
  34. echo "=> Replacing the standard binary with the development binary..."
  35. podman exec os /bin/bash -c 'rm -f os && ln -s bin/os os && supervisorctl restart os-api'
  36. echo "=> Creating a development account..."
  37. podman exec os /bin/bash -c 'os account create -u dev -p 123456 --is-super-admin false'
  38. if [[ ${1} == "ssh" ]]; then
  39. echo "=> Installing OpenSSH..."
  40. podman exec os /bin/bash -c 'os services create-installable -n openssh'
  41. fi
  42. echo
  43. echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>"
  44. echo
  45. echo "=> Starting the development build..."
  46. echo "Any changes to the code will trigger a rebuild automatically."
  47. echo "Ignore the 'InfiniteOsMustBeRunAsRoot' message or enable DEV_MODE."
  48. echo
  49. echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>"
  50. echo
  51. sleep 3
  52. stopDevBuild() {
  53. kill $airPid
  54. kill $podmanPid
  55. podman stop os &>/dev/null
  56. podman rm os &>/dev/null
  57. echo
  58. echo "=> Development build stopped."
  59. echo
  60. clear
  61. exit
  62. }
  63. trap stopDevBuild SIGINT
  64. air &
  65. airPid=$!
  66. podman attach os &
  67. podmanPid=$!
  68. wait $airPid
  69. wait $podmanPid