Skip to content

Commit

Permalink
generalized docker install and split apart centos and ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
julienchastang committed Apr 17, 2018
1 parent bea55f0 commit 22e3d6f
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 87 deletions.
77 changes: 18 additions & 59 deletions .org/docker-readme.org → .org/vm-init-readme.org
Expand Up @@ -3,7 +3,7 @@
#+OPTIONS: email:nil f:t inline:t num:t p:nil pri:nil prop:nil stat:t tags:t
#+OPTIONS: tasks:t tex:t timestamp:t title:t toc:t todo:t |:t
#+OPTIONS: auto-id:t
#+TITLE: docker-readme
#+TITLE: VM Init
#+DATE: <2017-03-03 Fri>
#+AUTHOR: Julien Chastang
#+EMAIL: chastang@ucar.edu
Expand All @@ -12,19 +12,19 @@
#+EXCLUDE_TAGS: noexport
#+CREATOR: Emacs 25.1.2 (Org mode 9.0.5)

#+PROPERTY: header-args :noweb yes :tangle ../docker-install.sh :eval no
#+PROPERTY: header-args :noweb yes :eval no

* Org Setup :noexport:
* Org Setup :noexport:
:PROPERTIES:
:CUSTOM_ID: h:ECAA0F5F
:END:

* Docker Installation
* Virtual Machine Initialization
:PROPERTIES:
:CUSTOM_ID: h:BA11A408
:END:

The ~xsede-jetstream~ project is heavily dependent on Docker, and you will have to have access to a recent version of Docker. Herein are some instructions to help you get going with Docker.
The ~xsede-jetstream~ project is heavily dependent on Docker, and you will have to have access to a recent version of Docker. Herein are some instructions to help you get going with Docker and other system maintenance you will need to perform.

** Linux VM or Bare Metal Linux
:PROPERTIES:
Expand All @@ -42,11 +42,11 @@ Quick start instructions for Linux OS can be found here. For a more complete exp
git clone https://github.com/Unidata/xsede-jetstream
#+END_SRC

and run the =docker-install.sh= script collocated with this readme, e.g.,:
and run the =ubuntu-init.sh= or =centos-init.sh= script collocated with this readme, e.g.,:

#+BEGIN_SRC shell :tangle no
cd xsede-jetstream
sudo ./docker-install.sh -u ${USER}
sudo ./<linux-distro>-init.sh -u ${USER}
#+END_SRC

*** System Maintenance
Expand All @@ -60,13 +60,13 @@ Do the usual maintenance via ~apt-get~ or ~yum~. Also install a few ancillary pa

# Set up tangling

#+BEGIN_SRC shell :exports none :shebang "#!/bin/bash"
#+BEGIN_SRC shell :exports none :shebang "#!/bin/bash" :tangle '("../ubuntu-init.sh" "../centos-init.sh")
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi

usage="$(basename "$0") [-h] [-u, --user user name] --
usage="$(basename "$0") [-h] [-u, --user user name] --
script to setup Docker. Run as root. Think before your type:\n
-h show this help text\n
-u, --user User name that will be running Docker containers.\n"
Expand All @@ -88,7 +88,7 @@ Do the usual maintenance via ~apt-get~ or ~yum~. Also install a few ancillary pa
done

if [ -z "$DOCKER_USER" ]; then
echo "Must supply a user:"
echo "Must supply a user:"
echo -e $usage
exit 1
fi
Expand All @@ -99,7 +99,7 @@ Do the usual maintenance via ~apt-get~ or ~yum~. Also install a few ancillary pa
:CUSTOM_ID: h:B7D88FA4
:END:

#+BEGIN_SRC org :noweb-ref apt-get :exports none :tangle no
#+BEGIN_SRC shell :tangle ../ubuntu-init.sh
service docker stop

dpkg --configure -a && apt-get remove -y docker docker-engine docker.io \
Expand All @@ -108,47 +108,27 @@ Do the usual maintenance via ~apt-get~ or ~yum~. Also install a few ancillary pa
nfs-kernel-server nfs-common && apt autoremove -y
#+END_SRC

#+BEGIN_SRC shell :exports none
if [ -n "$(command -v apt-get)" ]; then
<<apt-get>>
fi
#+END_SRC

#+BEGIN_SRC shell :tangle no
<<apt-get>>
#+END_SRC

**** yum
:PROPERTIES:
:CUSTOM_ID: h:C9632B6B
:END:

#+BEGIN_SRC org :noweb-ref yum :exports none :tangle no
#+BEGIN_SRC shell :tangle ../centos-init.sh
systemctl stop docker

yum -y remove docker docker-common docker-selinux docker-engine-selinux \
docker-engine docker-ce && rm -rf /var/lib/docker && yum -y update && yum -y \
install git unzip wget nfs-kernel-server nfs-common
#+END_SRC

#+BEGIN_SRC shell :exports none
if [ -n "$(command -v yum)" ]; then
<<yum>>
fi
#+END_SRC

#+BEGIN_SRC shell :tangle no
<<yum>>
#+END_SRC

*** Install Docker
:PROPERTIES:
:CUSTOM_ID: h:786799C4
:END:

Define a ~DOCKER_USER~. Again, think before you type.

#+BEGIN_SRC shell
#+BEGIN_SRC shell :tangle '("../ubuntu-init.sh" "../centos-init.sh")
curl -sSL get.docker.com | sh
usermod -aG docker ${DOCKER_USER}
#+END_SRC
Expand All @@ -162,7 +142,7 @@ Define a ~DOCKER_USER~. Again, think before you type.
1.19.0
#+END_SRC

#+BEGIN_SRC shell
#+BEGIN_SRC shell :tangle '("../ubuntu-init.sh" "../centos-init.sh")
curl -L https://github.com/docker/compose/releases/download/<<dcompose-version>>/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose
Expand All @@ -175,46 +155,25 @@ Define a ~DOCKER_USER~. Again, think before you type.

As ~root~ user, make sure Docker is available as a daemon. You can issue one of the following commands depending on your flavor of Linux.

#+BEGIN_SRC org :noweb-ref service :exports none :tangle no
#+BEGIN_SRC shell :tangle ../ubuntu-init.sh
service docker start
#+END_SRC

#+BEGIN_SRC shell :exports none
if [ -n "$(command -v apt-get)" ]; then
<<service>>
fi
#+END_SRC

#+BEGIN_SRC shell :tangle no
<<service>>
#+END_SRC

or
or

#+BEGIN_SRC org :noweb-ref systemctl :exports none :tangle no
#+BEGIN_SRC shell :tangle ../centos-init.sh
systemctl enable docker.service
systemctl start docker.service
#+END_SRC

#+BEGIN_SRC shell :exports none
if [ -n "$(command -v yum)" ]; then
<<systemctl>>
fi
#+END_SRC


#+BEGIN_SRC shell :tangle no
<<systemctl>>
#+END_SRC

*** Reboot
:PROPERTIES:
:CUSTOM_ID: h:6D94F8D5
:END:

Now reboot the machine:

#+BEGIN_SRC shell
#+BEGIN_SRC shell :tangle '("../ubuntu-init.sh" "../centos-init.sh")
reboot now
#+END_SRC

Expand Down
29 changes: 6 additions & 23 deletions docker-install.sh → centos-init.sh
Expand Up @@ -31,22 +31,11 @@ if [ -z "$DOCKER_USER" ]; then
exit 1
fi

if [ -n "$(command -v apt-get)" ]; then
service docker stop
systemctl stop docker

dpkg --configure -a && apt-get remove -y docker docker-engine docker.io \
docker-ce && rm -rf /var/lib/docker && apt-get update && apt-get -y upgrade \
&& apt-get -y dist-upgrade && apt-get -y install git unzip wget \
nfs-kernel-server nfs-common && apt autoremove -y
fi

if [ -n "$(command -v yum)" ]; then
systemctl stop docker

yum -y remove docker docker-common docker-selinux docker-engine-selinux \
docker-engine docker-ce && rm -rf /var/lib/docker && yum -y update && yum -y \
install git unzip wget nfs-kernel-server nfs-common
fi
yum -y remove docker docker-common docker-selinux docker-engine-selinux \
docker-engine docker-ce && rm -rf /var/lib/docker && yum -y update && yum -y \
install git unzip wget nfs-kernel-server nfs-common

curl -sSL get.docker.com | sh
usermod -aG docker ${DOCKER_USER}
Expand All @@ -55,13 +44,7 @@ curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compos

chmod +x /usr/local/bin/docker-compose

if [ -n "$(command -v apt-get)" ]; then
service docker start
fi

if [ -n "$(command -v yum)" ]; then
systemctl enable docker.service
systemctl start docker.service
fi
systemctl enable docker.service
systemctl start docker.service

reboot now
50 changes: 50 additions & 0 deletions ubuntu-init.sh
@@ -0,0 +1,50 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi

usage="$(basename "$0") [-h] [-u, --user user name] --
script to setup Docker. Run as root. Think before your type:\n
-h show this help text\n
-u, --user User name that will be running Docker containers.\n"

while [[ $# > 0 ]]
do
key="$1"
case $key in
-u|--user)
DOCKER_USER="$2"
shift # past argument
;;
-h|--help)
echo -e $usage
exit
;;
esac
shift # past argument or value
done

if [ -z "$DOCKER_USER" ]; then
echo "Must supply a user:"
echo -e $usage
exit 1
fi

service docker stop

dpkg --configure -a && apt-get remove -y docker docker-engine docker.io \
docker-ce && rm -rf /var/lib/docker && apt-get update && apt-get -y upgrade \
&& apt-get -y dist-upgrade && apt-get -y install git unzip wget \
nfs-kernel-server nfs-common && apt autoremove -y

curl -sSL get.docker.com | sh
usermod -aG docker ${DOCKER_USER}

curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

service docker start

reboot now
10 changes: 5 additions & 5 deletions docker-readme.md → vm-init-readme.md
@@ -1,4 +1,4 @@
- [Docker Installation](#h:BA11A408)
- [Virtual Machine Initialization](#h:BA11A408)
- [Linux VM or Bare Metal Linux](#h:FF95E7EC)
- [Quick Start](#h:4A4B1084)
- [System Maintenance](#h:AE788331)
Expand All @@ -13,9 +13,9 @@

<a id="h:BA11A408"></a>

# Docker Installation
# Virtual Machine Initialization

The `xsede-jetstream` project is heavily dependent on Docker, and you will have to have access to a recent version of Docker. Herein are some instructions to help you get going with Docker.
The `xsede-jetstream` project is heavily dependent on Docker, and you will have to have access to a recent version of Docker. Herein are some instructions to help you get going with Docker and other system maintenance you will need to perform.


<a id="h:FF95E7EC"></a>
Expand All @@ -33,11 +33,11 @@ Quick start instructions for Linux OS can be found here. For a more complete exp
git clone https://github.com/Unidata/xsede-jetstream
```

and run the `docker-install.sh` script collocated with this readme, e.g.,:
and run the `ubuntu-init.sh` or `centos-init.sh` script collocated with this readme, e.g.,:

```shell
cd xsede-jetstream
sudo ./docker-install.sh -u ${USER}
sudo ./<linux-distro>-init.sh -u ${USER}
```


Expand Down

0 comments on commit 22e3d6f

Please sign in to comment.