Skip to content

Commit

Permalink
master CreateInstance: 401 enable getIliasVersion function to handle …
Browse files Browse the repository at this point in the history
…two major version digits
  • Loading branch information
daniwe4 committed Nov 6, 2023
1 parent dbac9ef commit 2898f9f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion app/src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion app/src/Commands/Instances/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
55 changes: 0 additions & 55 deletions setup/updates/update-20231024.sh

This file was deleted.

67 changes: 67 additions & 0 deletions setup/updates/update-20231102.sh
Original file line number Diff line number Diff line change
@@ -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 <instance_name> 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 $?
}

0 comments on commit 2898f9f

Please sign in to comment.