github.com/deis/deis@v1.13.5-0.20170519182049-1d9e59fbdbfc/tests/bin/setup-node.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Preps a Ubuntu 14.04 box with requirements to run as a Jenkins node to https://ci.deis.io/ 4 # Should be run as root. 5 6 # fail on any command exiting non-zero 7 set -eo pipefail 8 9 apt-get install -y apt-transport-https 10 11 # install docker 12 apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D 13 14 echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list 15 apt-get update 16 apt-get purge lxc-docker* 17 apt-get install -yq --force-yes docker-engine=1.10.3-0~trusty 18 19 # install extra extensions (AUFS, requires reboot) 20 apt-get -y install "linux-image-extra-$(uname -r)" 21 22 rm -rf /var/lib/docker/devicemapper/ # docker startup chokes on this on Docker 1.7.0+ 23 24 # install java 25 apt-get install -yq openjdk-7-jre-headless 26 27 apt-get install -yq build-essential \ 28 libgl1-mesa-glx \ 29 libpython2.7 \ 30 libqt4-network \ 31 libqt4-opengl \ 32 libqtcore4 \ 33 libqtgui4 \ 34 libsdl1.2debian \ 35 libvpx1 \ 36 libxcursor1 \ 37 libxinerama1 \ 38 libxmu6 \ 39 psmisc 40 41 # install virtualbox 42 if ! virtualbox --help &> /dev/null; then 43 wget -nv http://download.virtualbox.org/virtualbox/5.0.16/virtualbox-5.0_5.0.16-105871~Ubuntu~trusty_amd64.deb 44 dpkg -i virtualbox-5.0_5.0.16-105871~Ubuntu~trusty_amd64.deb 45 rm virtualbox-5.0_5.0.16-105871~Ubuntu~trusty_amd64.deb 46 fi 47 48 # install vagrant 49 if ! vagrant -v &> /dev/null; then 50 wget -nv https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb 51 dpkg -i vagrant_1.8.1_x86_64.deb 52 rm vagrant_1.8.1_x86_64.deb 53 fi 54 55 # install go 56 wget -nv -O- https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz | tar -C /usr/local -xz 57 echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile 58 echo "You must reboot for the global $PATH changes to take effect." 59 60 # install test suite requirements 61 apt-get install -yq curl \ 62 mercurial \ 63 python-dev \ 64 libffi-dev \ 65 libpq-dev \ 66 libyaml-dev \ 67 git \ 68 postgresql \ 69 postgresql-client \ 70 libldap2-dev \ 71 libsasl2-dev 72 73 curl -sSL https://bootstrap.pypa.io/get-pip.py | python - pip==8.1.1 74 pip install virtualenv 75 76 # TODO: rely on virtualenvs' pip instead of system pip on slaves 77 pip install -r "contrib/aws/requirements.txt" 78 79 # Use cabal (Haskell installer) to build and install ShellCheck 80 if ! shellcheck -V &> /dev/null; then 81 apt-get install -yq cabal-install 82 cabal update 83 pushd /tmp 84 git clone --branch v0.4.1 --single-branch https://github.com/koalaman/shellcheck.git 85 pushd shellcheck 86 cabal install --global 87 popd +2 88 apt-get purge -yq cabal-install 89 fi 90 91 # create jenkins user and install node bootstrap script 92 if ! getent passwd | cut -d: -f1 | grep -q jenkins; then 93 useradd -G docker,vboxusers -s /bin/bash --system -m jenkins 94 fi 95 96 mkdir -p /home/jenkins/bin 97 wget -nv -x -O /home/jenkins/bin/start-node.sh \ 98 https://raw.githubusercontent.com/deis/deis/master/tests/bin/start-node.sh 99 chmod +x /home/jenkins/bin/start-node.sh 100 chown -R jenkins:jenkins /home/jenkins/bin 101 102 # as the jenkins user, do "vagrant plugin install vagrant-triggers 103 # if not already installed" 104 su - jenkins -c "vagrant plugin list | grep -q vagrant-triggers || vagrant plugin install vagrant-triggers" 105 106 /etc/init.d/postgresql start 107 108 # set up PostgreSQL role for controller unit tests 109 sudo -u postgres psql -c "CREATE ROLE jenkins WITH CREATEDB LOGIN;" || true 110 sudo -u postgres psql -c "CREATE DATABASE deis WITH OWNER jenkins;" || true 111 # edit postgresql.conf and change "fsync = off", then restart postgresql. 112 113 # now the jenkins user has to export some envvars to start as a node 114 echo "Remaining setup:" 115 echo " 1. Log in as the jenkins user (sudo -i -u jenkins)" 116 echo " 2. Visit the nodes admin interface at https://ci.deis.io/ to find the command line for this node" 117 echo " 3. Export the NODE_NAME and NODE_SECRET environment variables defined there to your shell" 118 echo " 4. Run bin/start-node.sh to connect to Jenkins and start handling jobs"