diff --git a/README.md b/README.md index c36eabc5..d489ff55 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,21 @@ testing environments for ILIAS. It will create and provision a docker container according to your requirements, pull the ILIAS version you want to use and even install it if possible. -## Setup +## Installation -1. download and unpack the [latest release](https://github.com/conceptsandtraining/ilias-tool-doil/releases) +1. download and unpack the [latest release](https://github.com/conceptsandtraining/doil/releases) 1. execute `sudo ./install.sh` in order to install **doil** 1. you can remove the downloaded folder afterwards 1. check `doil help` for available commands and further instructions +## Update + +If you alread installed **doil** you can easily update with following steps: + +1. download and unpack the [latest release](https://github.com/conceptsandtraining/doil/releases) +1. execute `sudo ./update.sh` in order to update **doil** +1. you can remove the downloaded folder afterwards + ## Dependencies **doil** tries to use as little 3rd party software on the host system as possible. @@ -136,3 +144,12 @@ users, so make sure to understand what you are doing. * `doil salt:update` updates the saltstack if you are using a custom saltstack * `doil salt:login` logs the user into the main salt server * `doil salt:prune` prunes the main salt server + +## Changelog + +### 1.0.1 + +* Fixed a bug in linux templates where the port 80 is blocked so no machine + could be started +* Added update script +* Changed readme (thanks @Rillke) \ No newline at end of file diff --git a/install.sh b/install.sh index 1afb61ec..e283b62e 100755 --- a/install.sh +++ b/install.sh @@ -23,7 +23,7 @@ # ,' | / ;' # (,,/ (,,/ Thanks to Concepts and Training for supporting doil # -# Last revised 2021-02-08 +# Last revised 2021-03-23 # sudo user check if [ "$EUID" -ne 0 ] diff --git a/src/lib/instances/create/create.sh b/src/lib/instances/create/create.sh index 643aff8d..6df369d2 100755 --- a/src/lib/instances/create/create.sh +++ b/src/lib/instances/create/create.sh @@ -190,10 +190,16 @@ echo "[${NOW}] Copying necessary files" # docker stuff cp "/usr/local/lib/doil/tpl/minion/run-supervisor.sh" "${FOLDERPATH}/conf/run-supervisor.sh" -cp "/usr/local/lib/doil/tpl/minion/docker-compose.yml" "${FOLDERPATH}/docker-compose.yml" cp "/usr/local/lib/doil/tpl/minion/Dockerfile" "${FOLDERPATH}/Dockerfile" cp "/usr/local/lib/doil/tpl/stack/config/minion.cnf" "${FOLDERPATH}/conf/minion.cnf" cp "/usr/local/lib/doil/tpl/minion/salt-minion.conf" "${FOLDERPATH}/conf/salt-minion.conf" +if [[ ${HOST} == 'linux' ]] +then + cp "/usr/local/lib/doil/tpl/minion/docker-compose.yml" "${FOLDERPATH}/docker-compose.yml" +elif [[ ${HOST} == 'mac' ]] +then + cp "/usr/local/lib/doil/tpl/minion/docker-compose-mac.yml" "${FOLDERPATH}/docker-compose.yml" +fi # setting up config file touch "${FOLDERPATH}/conf/doil.conf" @@ -254,7 +260,7 @@ fi until [[ ! -z ${DCMAINSALTSERVICE} ]] do echo "Master service not ready ..." - sleep 0.1 + doil salt:restart done echo "Master service ready." @@ -301,14 +307,14 @@ fi # check if the new key is registered SALTKEYS=$(docker exec -t -i ${DCMAINHASH} /bin/bash -c "salt-key -L" | grep "${NAME}.local") -if [ ! -z ${SALTKEYS} ] +if [[ ! -z ${SALTKEYS} ]] then echo "Key not ready yet" sleep 5 SALTKEYS=$(docker exec -t -i ${DCMAINHASH} /bin/bash -c "salt-key -L" | grep "${NAME}.local") - if [ ! -z ${SALTKEYS} ] + if [[ ! -z ${SALTKEYS} ]] then echo "Key not ready yet" sleep 5 diff --git a/src/tpl/minion/docker-compose-mac.yml b/src/tpl/minion/docker-compose-mac.yml new file mode 100644 index 00000000..9fd1303d --- /dev/null +++ b/src/tpl/minion/docker-compose-mac.yml @@ -0,0 +1,36 @@ +version: "3.5" +services: + %TPL_PROJECT_NAME%: + build: + context: . + dockerfile: Dockerfile + image: doil/%TPL_PROJECT_NAME%:stable + container_name: %TPL_PROJECT_NAME% + hostname: %TPL_PROJECT_NAME% + domainname: local + ports: + - "80:80" + volumes: + - ./volumes/ilias:/var/www/html + - ./volumes/data:/var/ilias/data + - ./volumes/db/:/var/lib/mysql + - ./volumes/index:/var/ilias/index + - ./volumes/logs:/var/ilias/logs + - ./volumes/logs/error/:/var/ilias/logs/error + - ./volumes/logs/apache:/var/log/apache2 + - ./conf/minion.cnf:/etc/salt/minion + - type: bind + source: ./conf/salt-minion.conf + target: /etc/supervisor/conf.d/salt-minion.conf + environment: + - ILIAS_INI_PATH=/var/www/html/ilias.ini.php + - TZ=Europe/Berlin + - JAVA_SERVER_PATH=/var/www/html/Services/WebServices/RPC/lib + - JAVA_SERVER_START + networks: + - main_saltnet +networks: + main_saltnet: + external: true +volumes: + persistent: diff --git a/src/tpl/minion/docker-compose.yml b/src/tpl/minion/docker-compose.yml index 9fd1303d..0e79cfc7 100644 --- a/src/tpl/minion/docker-compose.yml +++ b/src/tpl/minion/docker-compose.yml @@ -8,8 +8,6 @@ services: container_name: %TPL_PROJECT_NAME% hostname: %TPL_PROJECT_NAME% domainname: local - ports: - - "80:80" volumes: - ./volumes/ilias:/var/www/html - ./volumes/data:/var/ilias/data diff --git a/update.sh b/update.sh new file mode 100755 index 00000000..69628d0f --- /dev/null +++ b/update.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +# doil is a tool that creates and manages multiple docker container +# with ILIAS and comes with several tools to help manage everything. +# It is able to download ILIAS and other ILIAS related software +# like cate. +# +# Copyright (C) 2020 - 2021 Laura Herzog (laura.herzog@concepts-and-training.de) +# Permission to copy and modify is granted under the AGPL license +# +# Contribute: https://github.com/conceptsandtraining/ilias-tool-doil +# +# .-. +# / / +# / | +# |\ ._ ,-"" `. +# | |,,_/ 7 ; +# `;= ,=( , / +# |`q q ` | \_,| +# .=; <> _ ; / ,/'/ | +# ';|\,j_ \;=\ ,/ `-' +# `--'_|\ ) +# ,' | / ;' +# (,,/ (,,/ Thanks to Concepts and Training for supporting doil +# +# Last revised 2021-03-23 + +# sudo user check +if [ "$EUID" -ne 0 ] +then + echo -e "\033[1mREQUIREMENT ERROR:\033[0m" + echo -e "\tPlease execute this script as sudo user!" + exit +fi + +CHECK_DOCKER=$(docker --version | tail -n 1 | cut -d " " -f 3 | cut -c 1-5) +vercomp () { + if [[ $1 == $2 ]] + then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 +} + +testvercomp () { + vercomp $1 $2 + case $? in + 0) op='=';; + 1) op='>';; + 2) op='<';; + esac + if [[ $op != $3 ]] + then + echo -e "\033[1mREQUIREMENT ERROR:\033[0m" + echo -e "\tYour docker version is not supported!" + echo -e "\tdoil requires at least docker version \033[1m19.03\033[0m. You have \033[1m${CHECK_DOCKER}\033[0m installed." + exit + fi +} +testvercomp ${CHECK_DOCKER} "19.02" ">" + +# check the OS +OPS="" +case "$(uname -s)" in + Darwin) + OPS="mac" + ;; + Linux) + OPS="linux" + ;; + *) + echo -e "\033[1mREQUIREMENT ERROR:\033[0m" + echo -e "\tYour operating system is not supported!" + exit + ;; +esac + +################################ +# Removing old version if needed +NOW=$(date +'%d.%m.%Y %I:%M:%S') +echo "[${NOW}] Removing old version" + +if [ -f "/usr/local/bin/doil" ] +then + rm /usr/local/bin/doil +fi +if [ -d "/usr/local/lib/doil" ] +then + rm -rf /usr/local/lib/doil/lib +fi + +######################### +# Copying the doil system +NOW=$(date +'%d.%m.%Y %I:%M:%S') +echo "[${NOW}] Copying the doil system" + +# Move the base script to the /usr/local/bin folder and make it executeable +cp src/doil.sh /usr/local/bin/doil +chmod a+x /usr/local/bin/doil + +# Move the script library to /usr/local/lib/doil +if [ ! -d "/usr/local/lib/doil" ] +then + mkdir /usr/local/lib/doil +fi +cp -r src/lib /usr/local/lib/doil/lib +chmod -R a+x /usr/local/lib/doil/lib + +################# +# Everything done +NOW=$(date +'%d.%m.%Y %I:%M:%S') +echo "[${NOW}] Everything done" \ No newline at end of file