docker.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. PORT=3429 # Port to run the server on
  3. echo "EXTERNAL_PORT=$PORT" >.env
  4. touch hikka-install.log
  5. if ! [ -x "$(command -v docker)" ]; then
  6. printf "\033[0;34mInstalling docker...\e[0m"
  7. if [ -f /etc/debian_version ]; then
  8. sudo apt-get install \
  9. apt-transport-https \
  10. ca-certificates \
  11. curl \
  12. gnupg-agent \
  13. software-properties-common -y 1>hikka-install.log 2>&1
  14. curl -fsSL https://download.docker.com/linux/ubuntu/gpg |
  15. sudo apt-key add - 1>hikka-install.log 2>&1
  16. sudo add-apt-repository \
  17. "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  18. $(lsb_release -cs) \
  19. stable" 1>hikka-install.log 2>&1
  20. sudo apt-get update -y 1>hikka-install.log 2>&1
  21. sudo apt-get install docker-ce docker-ce-cli containerd.io -y 1>hikka-install.log 2>&1
  22. elif [ -f /etc/arch-release ]; then
  23. sudo pacman -Syu docker --noconfirm 1>hikka-install.log 2>&1
  24. elif [ -f /etc/redhat-release ]; then
  25. sudo yum install -y yum-utils 1>hikka-install.log 2>&1
  26. sudo yum-config-manager \
  27. --add-repo \
  28. https://download.docker.com/linux/centos/docker-ce.repo
  29. sudo yum install docker-ce docker-ce-cli containerd.io -y 1>hikka-install.log 2>&1
  30. fi
  31. printf "\033[0;32m - success\e[0m\n"
  32. # Hikka uses docker-compose so we need to install that too
  33. printf "\033[0;34mInstalling docker-compose...\e[0m"
  34. pip install -U docker-compose 1>hikka-install.log 2>&1
  35. chmod +x /usr/local/bin/docker-compose
  36. printf "\033[0;32m - success\e[0m\n"
  37. else
  38. printf "\033[0;32mDocker is already installed\e[0m\n"
  39. fi
  40. printf "\033[0;34mDownloading configuration files...\e[0m"
  41. if [ -f "Dockerfile" ]; then
  42. rm Dockerfile
  43. fi
  44. wget -q https://github.com/hikariatama/Hikka/raw/master/Dockerfile
  45. if [ -f "docker-compose.yml" ]; then
  46. rm docker-compose.yml
  47. fi
  48. wget -q https://github.com/hikariatama/Hikka/raw/master/docker-compose.yml
  49. printf "\033[0;32m - success\e[0m\n"
  50. printf "\033[0;34mBuilding docker image...\e[0m"
  51. sudo docker-compose up -d --build 1>hikka-install.log 2>&1
  52. printf "\033[0;32m - success\e[0m\n"
  53. printf "\033[0;32mFollow this url to continue installation:\e[0m\n"
  54. ssh "-o StrictHostKeyChecking=no" "-R 80:127.0.0.1:$PORT" "nokey@localhost.run" 2>&1 | grep "tunneled"