diff --git a/app/src/App.php b/app/src/App.php index cc983570..fd75bfe3 100644 --- a/app/src/App.php +++ b/app/src/App.php @@ -9,7 +9,7 @@ class App extends Application { - const NAME = "Doil Version 20231024 - build 2023-10-24"; + const NAME = "Doil Version 20231102 - build 2023-11-02"; public function __construct(Command ...$commands) { diff --git a/app/src/Commands/Instances/CreateCommand.php b/app/src/Commands/Instances/CreateCommand.php index fd4c9057..075929e9 100644 --- a/app/src/Commands/Instances/CreateCommand.php +++ b/app/src/Commands/Instances/CreateCommand.php @@ -733,7 +733,7 @@ protected function getIliasVersion(string $path) : string "ILIAS_VERSION_NUMERIC" ); - preg_match("/\d.\d/", $ilias_version, $version); + preg_match("/\d+.\d/", $ilias_version, $version); return $version[0]; } diff --git a/setup/updates/update-20231024.sh b/setup/updates/update-20231024.sh deleted file mode 100644 index a8c8f345..00000000 --- a/setup/updates/update-20231024.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash - -source "${SCRIPT_DIR}"/updates/update.sh - -doil_update_20231024() { - echo "" - echo "This update disables Xdebug on all instances. In order to continue using xdebug," - echo "you must run 'doil apply enable-xdebug' for the desired instances after the update." - echo "" - - update - - if [ $(docker ps -a --filter "name=_local" --filter "name=_global" --format "{{.Names}}" | wc -l) -gt 0 ] - doil_status_send_message "Applying patch on existing instances" - then - for INSTANCE in $(docker ps -a --filter "name=_local" --filter "name=_global" --format "{{.Names}}") - do - NAME=${INSTANCE%_*} - SUFFIX=${INSTANCE##*_} - - if [ "${SUFFIX}" == "global" ] - then - INSTANCE_PATH=$(/usr/local/bin/doil path "${NAME}" -g -p) - su -c "/usr/local/bin/doil apply ${NAME} disable-xdebug -g" "${SUDO_USER}" 2>&1 > /dev/null - else - INSTANCE_PATH=$(su -c "/usr/local/bin/doil path ${NAME} -p" "${SUDO_USER}") - su -c "/usr/local/bin/doil apply ${NAME} disable-xdebug" "${SUDO_USER}" 2>&1 > /dev/null - fi - - DOCKER_COMPOSE_PATH="${INSTANCE_PATH}/docker-compose.yml" - LINE_NUMBER="$(grep -n 'source: ~/.config/composer/' "${DOCKER_COMPOSE_PATH}")" - - if [ ! -z "${LINE_NUMBER}" ] - then - LINE_NUMBER=${LINE_NUMBER%%:*} - sed -i "$((LINE_NUMBER-1)),$((LINE_NUMBER+1))d" "${DOCKER_COMPOSE_PATH}" - fi - - mkdir "${INSTANCE_PATH}"/volumes/logs/xdebug - chmod 775 "${INSTANCE_PATH}"/volumes/logs/xdebug - if [ "${SUFFIX}" == "global" ] - then - chown root:doil "${INSTANCE_PATH}"/volumes/logs/xdebug - else - chown "${SUDO_USER}":"${SUDO_USER}" "${INSTANCE_PATH}"/volumes/logs/xdebug - fi - - sed -i 's/volumes:/&\n - type: bind\n source: .\/volumes\/logs\/xdebug\n target: \/var\/log\/doil\/xdebug/' "${DOCKER_COMPOSE_PATH}" - - done - doil_status_okay - fi - - return $? -} diff --git a/setup/updates/update-20231102.sh b/setup/updates/update-20231102.sh new file mode 100644 index 00000000..f0073dac --- /dev/null +++ b/setup/updates/update-20231102.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash + +source "${SCRIPT_DIR}"/updates/update.sh + +doil_update_20231102() { + echo "" + echo "This update disables Xdebug on all instances. In order to continue using xdebug," + echo "you must run 'doil apply enable-xdebug' for the desired instances after the update." + echo "" + + update + + if [ $(docker ps -a --filter "name=_local" --filter "name=_global" --format "{{.Names}}" | wc -l) -gt 0 ] + doil_status_send_message "Applying patch on existing instances" + then + for INSTANCE in $(docker ps -a --filter "name=_local" --filter "name=_global" --format "{{.Names}}") + do + NAME=${INSTANCE%_*} + SUFFIX=${INSTANCE##*_} + + if [ -L /usr/local/share/doil/instances/"${NAME}" ] || [ -L /home/"${SUDO_USER}"/.doil/instances/"${NAME}" ] + then + if [ "${SUFFIX}" == "global" ] + then + INSTANCE_PATH=$(/usr/local/bin/doil path "${NAME}" -g -p) + su -c "/usr/local/bin/doil apply ${NAME} disable-xdebug -g" "${SUDO_USER}" 2>&1 > /dev/null + else + INSTANCE_PATH=$(su -c "/usr/local/bin/doil path ${NAME} -p" "${SUDO_USER}") + su -c "/usr/local/bin/doil apply ${NAME} disable-xdebug" "${SUDO_USER}" 2>&1 > /dev/null + fi + + DOCKER_COMPOSE_PATH="${INSTANCE_PATH}/docker-compose.yml" + LINE_NUMBER="$(grep -n 'source: ~/.config/composer/' "${DOCKER_COMPOSE_PATH}")" + + if [ ! -z "${LINE_NUMBER}" ] + then + LINE_NUMBER=${LINE_NUMBER%%:*} + sed -i "$((LINE_NUMBER-1)),$((LINE_NUMBER+1))d" "${DOCKER_COMPOSE_PATH}" + fi + + if [ ! -d "${INSTANCE_PATH}"/volumes/logs/xdebug ] + then + mkdir "${INSTANCE_PATH}"/volumes/logs/xdebug + fi + chmod 775 "${INSTANCE_PATH}"/volumes/logs/xdebug + if [ "${SUFFIX}" == "global" ] + then + chown root:doil "${INSTANCE_PATH}"/volumes/logs/xdebug + else + chown "${SUDO_USER}":"${SUDO_USER}" "${INSTANCE_PATH}"/volumes/logs/xdebug + fi + + if ! grep -q "source: ./volumes/logs/xdebug" "${DOCKER_COMPOSE_PATH}" + then + sed -i 's/volumes:/&\n - type: bind\n source: .\/volumes\/logs\/xdebug\n target: \/var\/log\/doil\/xdebug/' "${DOCKER_COMPOSE_PATH}" + fi + fi + done + + su -c "/usr/local/bin/doil restart -a" "${SUDO_USER}" 2>&1 > /dev/null + su -c "/usr/local/bin/doil restart -a -g" "${SUDO_USER}" 2>&1 > /dev/null + + doil_status_okay + fi + + return $? +}