diff --git a/Add Wiki.cmd b/Add Wiki.cmd deleted file mode 100644 index 8974ace..0000000 --- a/Add Wiki.cmd +++ /dev/null @@ -1,13 +0,0 @@ -@echo off - -cls -echo Downloading a copy of the Wiki repository -echo: -Windows\make clone-windows-wiki - -cls -echo Importing the databases. -echo: -Windows\make import-windows-wiki - -pause diff --git a/backup-game-databases-linux.sh b/Backup_Game_Databases_Linux.sh similarity index 100% rename from backup-game-databases-linux.sh rename to Backup_Game_Databases_Linux.sh diff --git a/Backup Game Databases.cmd b/Backup_Game_Databases_Windows.cmd similarity index 62% rename from Backup Game Databases.cmd rename to Backup_Game_Databases_Windows.cmd index e721477..43174b9 100644 --- a/Backup Game Databases.cmd +++ b/Backup_Game_Databases_Windows.cmd @@ -1,3 +1,5 @@ @echo off +echo: Windows\make backup-windows -pause \ No newline at end of file +echo: +pause diff --git a/Delete_Local_Repos_Linux.sh b/Delete_Local_Repos_Linux.sh new file mode 100644 index 0000000..fd68560 --- /dev/null +++ b/Delete_Local_Repos_Linux.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo make flush diff --git a/Delete Local Repositories.cmd b/Delete_Local_Repos_Windows.cmd similarity index 68% rename from Delete Local Repositories.cmd rename to Delete_Local_Repos_Windows.cmd index a2462bf..f3e101f 100644 --- a/Delete Local Repositories.cmd +++ b/Delete_Local_Repos_Windows.cmd @@ -1,5 +1,8 @@ @echo off +echo: Windows\make flush-windows -cls +echo: +echo: echo Local repositories have been deleted. -pause \ No newline at end of file +echo: +pause diff --git a/Makefile b/Makefile index 4afc523..e00ce2f 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,14 @@ restart: init @docker-compose down -v docker-compose up -d -clone-game-website: +clone-game: @$(shell git clone https://github.com/Open-RSC/Website.git) @$(shell git clone https://github.com/Open-RSC/Game.git) - #@$(shell sudo chmod -R 777 Website && sudo chmod -R 777 Game && sudo chmod 644 Website/board/config.php) + #@$(&& sudo chmod -R 777 Game) + +clone-website: + @$(shell git clone https://github.com/Open-RSC/Website.git) + #@$(shell sudo chmod -R 777 Website && sudo chmod 644 Website/board/config.php) clone-wiki: @$(shell cd Website && git clone https://github.com/Open-RSC/Wiki.git) @@ -30,14 +34,22 @@ clone-windows-game: clone-windows-wiki: @git clone https://github.com/Open-RSC/Wiki.git Website/Wiki -pull: - @$(shell cd Website && git pull) +pull-game: @$(shell cd Game && git pull) + +pull-website: + @$(shell cd Website && git pull) + +pull-wiki: @$(shell cd Website/Wiki && git pull) -pull-windows: - @cd Website && git pull +pull-game-windows: @cd Game && git pull + +pull-website-windows: + @cd Website && git pull + +pull-wiki-windows: @cd Website/Wiki && git pull logs: diff --git a/README.md b/README.md index 336d982..e72203d 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,19 @@ # Open RSC Docker Home -An easy to run RSC private server environment using Docker. +An easy to run RSC private server environment using Docker that works in Windows, Mac, and Linux. + +Choices: + + 1. Single player RSC game + basic database editing (PHPMyAdmin) + 2. Game + Website + PHPMyAdmin + 3. Game + Website + PHPMyAdmin + RSC Preservation Wiki ___ -## Install prerequisites - -This is compatible with `(Windows, Ubuntu Linux, and macOS)`. - -Prerequisites: - -* [Git](https://git-scm.com/downloads) -* [Docker](https://docs.docker.com/engine/installation/) - -If your running Ubuntu 18.04, execute the following script and skip the rest of this section: - - ```sh - ./install-docker-linux.sh - ``` - -To manually set up the prerequisites in Ubuntu 18.04 (bionic) Linux (modify where it reads "bionic" below as needed for your Ubuntu distro): - - ```sh - sudo apt update && install build-essential apt-transport-https ca-certificates curl software-properties-common -y - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" - sudo apt update && install docker-ce docker-compose -y - ``` -___ - -## Choice 1 (easy): Download the project zip, extract it, and open the "Docker-Home" folder +## Choice 1: Download the zip, extract it, and open the "Docker-Home" folder https://github.com/Open-RSC/Docker-Home/archive/master.zip -## Choice 2 (advanced): Clone the project with git +## Choice 2: Clone the project with git Install [Git](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git), then clone the project: @@ -40,12 +21,6 @@ Install [Git](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git), the git clone https://github.com/Open-RSC/Docker-Home.git ``` -Go to the project directory: - - ```sh - cd Docker-Home - ``` - ___ ## Important for Windows users! @@ -58,72 +33,69 @@ ___ ## Run the scripts -1. Perform first time setup and start the Docker application: +1. Perform the first time setup: ```sh - macOS/Ubuntu: ./first-time-setup-linux.sh + macOS/Ubuntu: ./Setup_Linux.sh ``` ```sh - Windows: "First Time Setup.cmd" + Windows: "Setup_Windows.cmd" ``` - **Please wait this might take a several minutes...** - 2. Open your favorite browser: - * [http://localhost](http://localhost/) + * [http://localhost](http://localhost/) (username: Marwolf, password: malware) * [http://localhost:8080](http://localhost:8080/) PHPMyAdmin (username: root, password: root) - + * [http://localhost/wiki](http://localhost/wiki) (username: Marwolf, password: openrscpassword) 3. Start the game's Docker containers, then run the game server and client: ```sh - macOS/Ubuntu: ./start-game-linux.sh + macOS/Ubuntu: ./Start_Single_Player_Game_Linux.sh ``` ```sh - Windows: "Start Game.cmd" + Windows: "Start_Single_Player_Game_Windows.cmd" ``` 4. Backup game databases: ```sh - macOS/Ubuntu: ./backup-game-databases-linux.sh + macOS/Ubuntu: ./Backup_Game_Databases_Linux.sh ``` ```sh - Windows: "Backup Game Databases.cmd" + Windows: "Backup_Game_Databases_Windows.cmd" ``` 5. Restore game databases: ```sh - macOS/Ubuntu: ./restore-game-databases-linux.sh + macOS/Ubuntu: ./Restore_Game_Database_Backup_Linux.sh ``` ```sh - Windows: "Restore Game Databases.cmd" + Windows: "Restore_Game_Database_Backup_Windows.cmd" ``` - -6. Stop the game's Docker containers and shut down the game server: +6. View the game's Docker container logs: ```sh - macOS/Ubuntu: ./stop-game-linux.sh + ./View_Docker_Container_Logs_Linux.sh ``` ```sh - Windows: "Stop Game.cmd" + Windows: "View_Docker_Container_Logs_Windows.cmd" ``` -7. View the game's Docker container logs: +7. Stop the game's Docker containers and shut down the game server: ```sh - ./view-docker-container-logs-linux.sh + macOS/Ubuntu: ./Stop-Game-Linux.sh ``` ```sh - Windows: "View Docker Container Logs.cmd" + Windows: "Stop_Game_Windows.cmd" ``` ___ diff --git a/restore-database.sh b/Restore_Game_Database_Backup_Linux.sh similarity index 100% rename from restore-database.sh rename to Restore_Game_Database_Backup_Linux.sh diff --git a/Restore Databases.cmd b/Restore_Game_Database_Backup_Windows.cmd similarity index 63% rename from Restore Databases.cmd rename to Restore_Game_Database_Backup_Windows.cmd index c361fda..c30ef5b 100644 --- a/Restore Databases.cmd +++ b/Restore_Game_Database_Backup_Windows.cmd @@ -1,3 +1,5 @@ @echo off +echo: Windows\make restore-windows -pause \ No newline at end of file +echo: +pause diff --git a/Setup_Linux.sh b/Setup_Linux.sh new file mode 100755 index 0000000..121bdcf --- /dev/null +++ b/Setup_Linux.sh @@ -0,0 +1,246 @@ +#!/bin/sh +clear +choice="" +RED=`tput setaf 1` +GREEN=`tput setaf 2` +NC=`tput sgr0` # No Color + +echo "${RED}Open RSC Installer:${NC} +An easy to run RSC private server environment using Docker magic. + +Before continuing, Open RSC needs to know if you have Docker and git installed. +This installer can install one or both for you if needed. + +Choices: + ${RED}1${NC} - Install for me! + ${RED}2${NC} - I'm all set, continue! (default)" +echo "" +read install + +if [ "$install" == "1" ]; then + clear + echo "Which operating system are you running?" + echo "" + echo "${RED}1${NC} - Ubuntu Linux" + echo "${RED}2${NC} - Fedora Linux" + echo "${RED}3${NC} - Mac OS" + echo "${RED}4${NC} - Other" + echo "" + read os + + if [ "$os" == "1" ]; then + sudo apt-get install git -y + #build-essential apt-transport-https ca-certificates curl software-properties-common + elif [ "$os" == "2" ]; then + su -c 'yum install git' + elif [ "$os" == "3" ]; then + clear + echo "Do you have brew installed?" + echo "" + echo "${RED}1${NC} - No, install it for me!" + echo "${RED}2${NC} - Yes" + echo "" + read brew + + if [ "$brew" == "1" ]; then + /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + brew install git + else + continue + fi + elif [ "$os" == "4" ]; then + echo "" + echo "You will have to install git manually then. Press enter to continue." + echo "" + read + else + continue + fi + + + echo "Attempting to install Docker now" + curl -fsSL get.docker.com -o get-docker.sh + sudo sh get-docker.sh + else + continue + fi + +clear +echo "Checking the Docker Home git repo for any recent updates." +echo "" +git pull +echo "" +clear +echo "${RED}Open RSC Installer:${NC} +An easy to run RSC private server environment using Docker magic. + +Choices: + ${RED}1${NC} - Single player RSC game + basic database editing (using PHPMyAdmin) + ${RED}2${NC} - Game + Website + PHPMyAdmin + ${RED}3${NC} - Game + Website + PHPMyAdmin + RSC Preservation Wiki + +Which of the above do you want? Type 1, 2, or 3, and press enter." +echo "" +read choice + +if [ "$choice" == "1" ]; then + clear + echo "You have picked ${GREEN}single player RSC + PHPMyAdmin!${NC}" + echo "" + echo "" + echo "Checking the git repos for any recent updates." + echo "" + echo "You may now be prompted for your password so the installer has sudo access." + echo "" + sudo make pull-game + echo "" + echo "" + echo "Logging into Docker Hub to get the required images." + echo "You may first need to register an account at ${RED}dockerhub.com${NC}" + echo "" + docker login + echo "" + echo "" + echo "Starting up the Docker containers and stopping any existing ones." + echo "" + sudo make stop + echo "" + sudo make start + echo "" + echo "" + echo "Fetching the Website and Game from the Open RSC git repo." + echo "" + sudo make clone-game + echo "" + echo "" + echo "Importing the databases." + echo "" + sudo make import + echo "" + echo "" + echo "Creating the client cache in your home folder." + echo "" + mkdir ~/OpenRSC + unzip -o Game/client/cache.zip -d ~/OpenRSC + echo "" + echo "" + echo "Open RSC setup complete!" + echo "" + exit + +elif [ "$choice" == "2" ]; then + clear + echo "You have picked ${GREEN}Game + Website + PHPMyAdmin!${NC}" + echo "" + echo "" + echo "Checking the git repos for any recent updates." + echo "" + echo "You may now be prompted for your password so the installer has sudo access." + echo "" + sudo make pull-game + echo "" + sudo make pull-website + echo "" + echo "" + echo "Logging into Docker Hub to get the required images." + echo "You may first need to register an account at ${RED}dockerhub.com${NC}" + echo "" + docker login + echo "" + echo "" + echo "Starting up the Docker containers and stopping any existing ones." + echo "" + sudo make stop + echo "" + sudo make start + echo "" + echo "" + echo "Fetching the Website and Game from the Open RSC git repo." + echo "" + sudo make clone-game + echo "" + sudo make clone-website + echo "" + echo "" + echo "Importing the databases." + echo "" + sudo make import + echo "" + echo "" + echo "Creating the client cache in your home folder." + echo "" + mkdir ~/OpenRSC + unzip -o Game/client/cache.zip -d ~/OpenRSC + echo "" + echo "" + echo "Open RSC setup complete!" + echo "" + exit + +elif [ "$choice" == "3" ]; then + clear + echo "You have picked ${GREEN}Game + Website + PHPMyAdmin + RSC Preservation Wiki!${NC}" + echo "" + echo "" + echo "Checking the git repos for any recent updates." + echo "" + echo "You may now be prompted for your password so the installer has sudo access." + echo "" + sudo make pull-game + echo "" + sudo make pull-website + echo "" + sudo make pull-wiki + echo "" + echo "" + echo "Logging into Docker Hub to get the required images." + echo "You may first need to register an account at ${RED}dockerhub.com${NC}" + echo "" + docker login + echo "" + echo "" + echo "Starting up the Docker containers and stopping any existing ones." + echo "" + sudo make stop + echo "" + sudo make start + echo "" + echo "" + echo "Fetching the Website, Game, and Wiki from the Open RSC git repo." + echo "" + sudo make clone-game + echo "" + sudo make clone-website + echo "" + sudo make clone-wiki + echo "" + echo "" + echo "Extracting the Wiki database." + echo "" + unzip -o Website/Wiki/openrsc_wiki.sql.zip -d Website/Wiki + echo "" + echo "" + echo "Importing the game, forum, and wiki databases." + echo "" + sudo make import + echo "" + sudo make import-wiki + echo "" + echo "" + echo "Creating the client cache in your home folder." + echo "" + mkdir ~/OpenRSC + unzip -o Game/client/cache.zip -d ~/OpenRSC + echo "" + echo "" + echo "Open RSC setup complete!" + echo "" + exit + +else + echo "" + echo "Error! ${RED}$choice${NC} is not a valid option. Press enter to try again." + echo "" + read + ./Setup_Linux.sh +fi diff --git a/First time setup.cmd b/Setup_Windows.cmd similarity index 82% rename from First time setup.cmd rename to Setup_Windows.cmd index 4f1d205..9476cf1 100644 --- a/First time setup.cmd +++ b/Setup_Windows.cmd @@ -1,43 +1,44 @@ @echo off -cls +echo: git pull - -cls +echo: +echo: docker login - -cls +echo: +echo: echo Attempting to stop any running Docker containers. echo: Windows\make stop - -cls +echo: +echo: echo Starting Docker containers and downloading what is needed. This may take a while the first time. echo: Windows\make start - -cls +echo: +echo: echo Downloading a copy of the Website repository echo: Windows\make clone-windows-website - -cls +echo: +echo: echo Downloading a copy of the Game repository echo: Windows\make clone-windows-game - -cls +echo: +echo: echo Importing the databases. echo: Windows\make import-windows - -cls +echo: +echo: echo Extracting client cache echo: md "%HOMEPATH%/OpenRSC" "Windows/7z.exe" x "Game/client/cache.zip" -o"%HOMEPATH%/OpenRSC" -r - -cls +echo: +echo: echo First time setup is now complete. Go ahead and open "Start Game.cmd" now. +echo: pause diff --git a/start-game-linux.sh b/Start_Single_Player_Game_Linux.sh similarity index 100% rename from start-game-linux.sh rename to Start_Single_Player_Game_Linux.sh diff --git a/Start Game.cmd b/Start_Single_Player_Game_Windows.cmd similarity index 71% rename from Start Game.cmd rename to Start_Single_Player_Game_Windows.cmd index 8ce7003..2db5182 100644 --- a/Start Game.cmd +++ b/Start_Single_Player_Game_Windows.cmd @@ -1,8 +1,20 @@ @echo off +echo: Windows\make pull +echo: +echo: set PATH=Ant/bin +echo: +echo: call ant -f Game/client/build.xml compile +echo: +echo: call ant -f Game/server/build.xml compile +echo: +echo: call START "" ant -f Game/client/build.xml runclient +echo: +echo: call ant -f Game/server/build.xml runserver +echo: pause diff --git a/stop-game-linux.sh b/Stop_Game_Linux.sh similarity index 100% rename from stop-game-linux.sh rename to Stop_Game_Linux.sh diff --git a/Stop Game.cmd b/Stop_Game_Windows.cmd similarity index 60% rename from Stop Game.cmd rename to Stop_Game_Windows.cmd index 5bb5f3a..410a94a 100644 --- a/Stop Game.cmd +++ b/Stop_Game_Windows.cmd @@ -1,4 +1,8 @@ @echo off +echo: Windows\make stop +echo: +echo: tskill java /a +echo: pause diff --git a/view-docker-container-logs-linux.sh b/View_Docker_Container_Logs_Linux.sh similarity index 100% rename from view-docker-container-logs-linux.sh rename to View_Docker_Container_Logs_Linux.sh diff --git a/View Docker Container Logs.cmd b/View_Docker_Container_Logs_Windows.cmd similarity index 55% rename from View Docker Container Logs.cmd rename to View_Docker_Container_Logs_Windows.cmd index ee48f8d..1dbba45 100644 --- a/View Docker Container Logs.cmd +++ b/View_Docker_Container_Logs_Windows.cmd @@ -1,3 +1,5 @@ @echo off +echo: Windows\make logs -pause \ No newline at end of file +echo: +pause diff --git a/add-wiki.sh b/add-wiki.sh deleted file mode 100755 index fa3c3ac..0000000 --- a/add-wiki.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -clear -sudo make clone-wiki -sudo make import-wiki diff --git a/first-time-setup-linux.sh b/first-time-setup-linux.sh deleted file mode 100755 index 604a1bf..0000000 --- a/first-time-setup-linux.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -clear -git pull -docker login -sudo make stop -sudo make start -sudo make clone-game-website -sudo make import -mkdir ~/OpenRSC -unzip Game/client/cache.zip -d ~/OpenRSC diff --git a/get-docker.sh b/get-docker.sh new file mode 100644 index 0000000..376de82 --- /dev/null +++ b/get-docker.sh @@ -0,0 +1,525 @@ +#!/bin/sh +set -e + +# This script is meant for quick & easy install via: +# $ curl -fsSL get.docker.com -o get-docker.sh +# $ sh get-docker.sh +# +# For test builds (ie. release candidates): +# $ curl -fsSL test.docker.com -o test-docker.sh +# $ sh test-docker.sh +# +# NOTE: Make sure to verify the contents of the script +# you downloaded matches the contents of install.sh +# located at https://github.com/docker/docker-install +# before executing. +# +# Git commit from https://github.com/docker/docker-install when +# the script was uploaded (Should only be modified by upload job): +SCRIPT_COMMIT_SHA=36b78b2 + + +# This value will automatically get changed for: +# * edge +# * test +# * experimental +DEFAULT_CHANNEL_VALUE="edge" +if [ -z "$CHANNEL" ]; then + CHANNEL=$DEFAULT_CHANNEL_VALUE +fi + +DEFAULT_DOWNLOAD_URL="https://download.docker.com" +if [ -z "$DOWNLOAD_URL" ]; then + DOWNLOAD_URL=$DEFAULT_DOWNLOAD_URL +fi + +DEFAULT_REPO_FILE="docker-ce.repo" +if [ -z "$REPO_FILE" ]; then + REPO_FILE="$DEFAULT_REPO_FILE" +fi + +SUPPORT_MAP=" +x86_64-centos-7 +x86_64-fedora-26 +x86_64-fedora-27 +x86_64-fedora-28 +x86_64-debian-wheezy +x86_64-debian-jessie +x86_64-debian-stretch +x86_64-debian-buster +x86_64-ubuntu-trusty +x86_64-ubuntu-xenial +x86_64-ubuntu-bionic +x86_64-ubuntu-artful +s390x-ubuntu-xenial +s390x-ubuntu-bionic +s390x-ubuntu-artful +ppc64le-ubuntu-xenial +ppc64le-ubuntu-bionic +ppc64le-ubuntu-artful +aarch64-ubuntu-xenial +aarch64-ubuntu-bionic +aarch64-debian-jessie +aarch64-debian-stretch +aarch64-debian-buster +aarch64-fedora-26 +aarch64-fedora-27 +aarch64-fedora-28 +aarch64-centos-7 +armv6l-raspbian-jessie +armv7l-raspbian-jessie +armv6l-raspbian-stretch +armv7l-raspbian-stretch +armv7l-debian-jessie +armv7l-debian-stretch +armv7l-debian-buster +armv7l-ubuntu-trusty +armv7l-ubuntu-xenial +armv7l-ubuntu-bionic +armv7l-ubuntu-artful +" + +mirror='' +DRY_RUN=${DRY_RUN:-} +while [ $# -gt 0 ]; do + case "$1" in + --mirror) + mirror="$2" + shift + ;; + --dry-run) + DRY_RUN=1 + ;; + --*) + echo "Illegal option $1" + ;; + esac + shift $(( $# > 0 ? 1 : 0 )) +done + +case "$mirror" in + Aliyun) + DOWNLOAD_URL="https://mirrors.aliyun.com/docker-ce" + ;; + AzureChinaCloud) + DOWNLOAD_URL="https://mirror.azure.cn/docker-ce" + ;; +esac + +command_exists() { + command -v "$@" > /dev/null 2>&1 +} + +is_dry_run() { + if [ -z "$DRY_RUN" ]; then + return 1 + else + return 0 + fi +} + +deprecation_notice() { + distro=$1 + date=$2 + echo + echo "DEPRECATION WARNING:" + echo " The distribution, $distro, will no longer be supported in this script as of $date." + echo " If you feel this is a mistake please submit an issue at https://github.com/docker/docker-install/issues/new" + echo + sleep 10 +} + +get_distribution() { + lsb_dist="" + # Every system that we officially support has /etc/os-release + if [ -r /etc/os-release ]; then + lsb_dist="$(. /etc/os-release && echo "$ID")" + fi + # Returning an empty string here should be alright since the + # case statements don't act unless you provide an actual value + echo "$lsb_dist" +} + +add_debian_backport_repo() { + debian_version="$1" + backports="deb http://ftp.debian.org/debian $debian_version-backports main" + if ! grep -Fxq "$backports" /etc/apt/sources.list; then + (set -x; $sh_c "echo \"$backports\" >> /etc/apt/sources.list") + fi +} + +echo_docker_as_nonroot() { + if is_dry_run; then + return + fi + if command_exists docker && [ -e /var/run/docker.sock ]; then + ( + set -x + $sh_c 'docker version' + ) || true + fi + your_user=your-user + [ "$user" != 'root' ] && your_user="$user" + # intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output + echo "If you would like to use Docker as a non-root user, you should now consider" + echo "adding your user to the \"docker\" group with something like:" + echo + echo " sudo usermod -aG docker $your_user" + echo + echo "Remember that you will have to log out and back in for this to take effect!" + echo + echo "WARNING: Adding a user to the \"docker\" group will grant the ability to run" + echo " containers which can be used to obtain root privileges on the" + echo " docker host." + echo " Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface" + echo " for more information." + +} + +# Check if this is a forked Linux distro +check_forked() { + + # Check for lsb_release command existence, it usually exists in forked distros + if command_exists lsb_release; then + # Check if the `-u` option is supported + set +e + lsb_release -a -u > /dev/null 2>&1 + lsb_release_exit_code=$? + set -e + + # Check if the command has exited successfully, it means we're in a forked distro + if [ "$lsb_release_exit_code" = "0" ]; then + # Print info about current distro + cat <<-EOF + You're using '$lsb_dist' version '$dist_version'. + EOF + + # Get the upstream release info + lsb_dist=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'id' | cut -d ':' -f 2 | tr -d '[:space:]') + dist_version=$(lsb_release -a -u 2>&1 | tr '[:upper:]' '[:lower:]' | grep -E 'codename' | cut -d ':' -f 2 | tr -d '[:space:]') + + # Print info about upstream distro + cat <<-EOF + Upstream release is '$lsb_dist' version '$dist_version'. + EOF + else + if [ -r /etc/debian_version ] && [ "$lsb_dist" != "ubuntu" ] && [ "$lsb_dist" != "raspbian" ]; then + if [ "$lsb_dist" = "osmc" ]; then + # OSMC runs Raspbian + lsb_dist=raspbian + else + # We're Debian and don't even know it! + lsb_dist=debian + fi + dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')" + case "$dist_version" in + 9) + dist_version="stretch" + ;; + 8|'Kali Linux 2') + dist_version="jessie" + ;; + 7) + dist_version="wheezy" + ;; + esac + fi + fi + fi +} + +semverParse() { + major="${1%%.*}" + minor="${1#$major.}" + minor="${minor%%.*}" + patch="${1#$major.$minor.}" + patch="${patch%%[-.]*}" +} + +ee_notice() { + echo + echo + echo " WARNING: $1 is now only supported by Docker EE" + echo " Check https://store.docker.com for information on Docker EE" + echo + echo +} + +do_install() { + echo "# Executing docker install script, commit: $SCRIPT_COMMIT_SHA" + + if command_exists docker; then + docker_version="$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1)" + MAJOR_W=1 + MINOR_W=10 + + semverParse "$docker_version" + + shouldWarn=0 + if [ "$major" -lt "$MAJOR_W" ]; then + shouldWarn=1 + fi + + if [ "$major" -le "$MAJOR_W" ] && [ "$minor" -lt "$MINOR_W" ]; then + shouldWarn=1 + fi + + cat >&2 <<-'EOF' + Warning: the "docker" command appears to already exist on this system. + + If you already have Docker installed, this script can cause trouble, which is + why we're displaying this warning and provide the opportunity to cancel the + installation. + + If you installed the current Docker package using this script and are using it + EOF + + if [ $shouldWarn -eq 1 ]; then + cat >&2 <<-'EOF' + again to update Docker, we urge you to migrate your image store before upgrading + to v1.10+. + + You can find instructions for this here: + https://github.com/docker/docker/wiki/Engine-v1.10.0-content-addressability-migration + EOF + else + cat >&2 <<-'EOF' + again to update Docker, you can safely ignore this message. + EOF + fi + + cat >&2 <<-'EOF' + + You may press Ctrl+C now to abort this script. + EOF + ( set -x; sleep 20 ) + fi + + user="$(id -un 2>/dev/null || true)" + + sh_c='sh -c' + if [ "$user" != 'root' ]; then + if command_exists sudo; then + sh_c='sudo -E sh -c' + elif command_exists su; then + sh_c='su -c' + else + cat >&2 <<-'EOF' + Error: this installer needs the ability to run commands as root. + We are unable to find either "sudo" or "su" available to make this happen. + EOF + exit 1 + fi + fi + + if is_dry_run; then + sh_c="echo" + fi + + # perform some very rudimentary platform detection + lsb_dist=$( get_distribution ) + lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')" + + case "$lsb_dist" in + + ubuntu) + if command_exists lsb_release; then + dist_version="$(lsb_release --codename | cut -f2)" + fi + if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then + dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")" + fi + ;; + + debian|raspbian) + dist_version="$(sed 's/\/.*//' /etc/debian_version | sed 's/\..*//')" + case "$dist_version" in + 9) + dist_version="stretch" + ;; + 8) + dist_version="jessie" + ;; + 7) + dist_version="wheezy" + ;; + esac + ;; + + centos) + if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then + dist_version="$(. /etc/os-release && echo "$VERSION_ID")" + fi + ;; + + rhel|ol|sles) + ee_notice "$lsb_dist" + exit 1 + ;; + + *) + if command_exists lsb_release; then + dist_version="$(lsb_release --release | cut -f2)" + fi + if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then + dist_version="$(. /etc/os-release && echo "$VERSION_ID")" + fi + ;; + + esac + + # Check if this is a forked Linux distro + check_forked + + # Check if we actually support this configuration + if ! echo "$SUPPORT_MAP" | grep "$(uname -m)-$lsb_dist-$dist_version" >/dev/null; then + cat >&2 <<-'EOF' + + Either your platform is not easily detectable or is not supported by this + installer script. + Please visit the following URL for more detailed installation instructions: + + https://docs.docker.com/engine/installation/ + + EOF + exit 1 + fi + + # Run setup for each distro accordingly + case "$lsb_dist" in + ubuntu|debian|raspbian) + pre_reqs="apt-transport-https ca-certificates curl" + if [ "$lsb_dist" = "debian" ]; then + if [ "$dist_version" = "wheezy" ]; then + add_debian_backport_repo "$dist_version" + fi + # libseccomp2 does not exist for debian jessie main repos for aarch64 + if [ "$(uname -m)" = "aarch64" ] && [ "$dist_version" = "jessie" ]; then + add_debian_backport_repo "$dist_version" + fi + fi + + # TODO: August 31, 2018 delete from here, + if [ "$lsb_dist" = "ubuntu" ] && [ "$dist_version" = "artful" ]; then + deprecation_notice "$lsb_dist $dist_version" "August 31, 2018" + fi + # TODO: August 31, 2018 delete to here, + + if ! command -v gpg > /dev/null; then + pre_reqs="$pre_reqs gnupg" + fi + apt_repo="deb [arch=$(dpkg --print-architecture)] $DOWNLOAD_URL/linux/$lsb_dist $dist_version $CHANNEL" + ( + if ! is_dry_run; then + set -x + fi + $sh_c 'apt-get update -qq >/dev/null' + $sh_c "apt-get install -y -qq $pre_reqs >/dev/null" + $sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" | apt-key add -qq - >/dev/null" + $sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list" + if [ "$lsb_dist" = "debian" ] && [ "$dist_version" = "wheezy" ]; then + $sh_c 'sed -i "/deb-src.*download\.docker/d" /etc/apt/sources.list.d/docker.list' + fi + $sh_c 'apt-get update -qq >/dev/null' + ) + pkg_version="" + if [ ! -z "$VERSION" ]; then + if is_dry_run; then + echo "# WARNING: VERSION pinning is not supported in DRY_RUN" + else + # Will work for incomplete versions IE (17.12), but may not actually grab the "latest" if in the test channel + pkg_pattern="$(echo "$VERSION" | sed "s/-ce-/~ce~.*/g" | sed "s/-/.*/g").*-0~$lsb_dist" + search_command="apt-cache madison 'docker-ce' | grep '$pkg_pattern' | head -1 | cut -d' ' -f 4" + pkg_version="$($sh_c "$search_command")" + echo "INFO: Searching repository for VERSION '$VERSION'" + echo "INFO: $search_command" + if [ -z "$pkg_version" ]; then + echo + echo "ERROR: '$VERSION' not found amongst apt-cache madison results" + echo + exit 1 + fi + pkg_version="=$pkg_version" + fi + fi + ( + if ! is_dry_run; then + set -x + fi + $sh_c "apt-get install -y -qq --no-install-recommends docker-ce$pkg_version >/dev/null" + ) + echo_docker_as_nonroot + exit 0 + ;; + centos|fedora) + yum_repo="$DOWNLOAD_URL/linux/$lsb_dist/$REPO_FILE" + if ! curl -Ifs "$yum_repo" > /dev/null; then + echo "Error: Unable to curl repository file $yum_repo, is it valid?" + exit 1 + fi + if [ "$lsb_dist" = "fedora" ]; then + if [ "$dist_version" -lt "26" ]; then + echo "Error: Only Fedora >=26 are supported" + exit 1 + fi + + pkg_manager="dnf" + config_manager="dnf config-manager" + enable_channel_flag="--set-enabled" + pre_reqs="dnf-plugins-core" + pkg_suffix="fc$dist_version" + else + pkg_manager="yum" + config_manager="yum-config-manager" + enable_channel_flag="--enable" + pre_reqs="yum-utils" + pkg_suffix="el" + fi + ( + if ! is_dry_run; then + set -x + fi + $sh_c "$pkg_manager install -y -q $pre_reqs" + $sh_c "$config_manager --add-repo $yum_repo" + + if [ "$CHANNEL" != "stable" ]; then + $sh_c "$config_manager $enable_channel_flag docker-ce-$CHANNEL" + fi + $sh_c "$pkg_manager makecache" + ) + pkg_version="" + if [ ! -z "$VERSION" ]; then + if is_dry_run; then + echo "# WARNING: VERSION pinning is not supported in DRY_RUN" + else + pkg_pattern="$(echo "$VERSION" | sed "s/-ce-/\\\\.ce.*/g" | sed "s/-/.*/g").*$pkg_suffix" + search_command="$pkg_manager list --showduplicates 'docker-ce' | grep '$pkg_pattern' | tail -1 | awk '{print \$2}'" + pkg_version="$($sh_c "$search_command")" + echo "INFO: Searching repository for VERSION '$VERSION'" + echo "INFO: $search_command" + if [ -z "$pkg_version" ]; then + echo + echo "ERROR: '$VERSION' not found amongst $pkg_manager list results" + echo + exit 1 + fi + # Cut out the epoch and prefix with a '-' + pkg_version="-$(echo "$pkg_version" | cut -d':' -f 2)" + fi + fi + ( + if ! is_dry_run; then + set -x + fi + $sh_c "$pkg_manager install -y -q docker-ce$pkg_version" + ) + echo_docker_as_nonroot + exit 0 + ;; + esac + exit 1 +} + +# wrapped up in a function so that we have some protection against only getting +# half the file during "curl | sh" +do_install diff --git a/install-docker-linux.sh b/install-docker-linux.sh deleted file mode 100755 index 50cbeca..0000000 --- a/install-docker-linux.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -sudo apt update && install build-essential apt-transport-https ca-certificates curl software-properties-common -y -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" -sudo apt update && install docker-ce docker-compose -y