diff --git a/app/src/App.php b/app/src/App.php index cbb96e67..32744a19 100644 --- a/app/src/App.php +++ b/app/src/App.php @@ -9,7 +9,7 @@ class App extends Application { - const NAME = "Doil Version 20231114 - build 2023-11-14"; + const NAME = "Doil Version 20231115 - build 2023-11-15"; public function __construct(Command ...$commands) { diff --git a/app/src/Commands/Instances/CreateCommand.php b/app/src/Commands/Instances/CreateCommand.php index 075929e9..5f7070b7 100644 --- a/app/src/Commands/Instances/CreateCommand.php +++ b/app/src/Commands/Instances/CreateCommand.php @@ -308,6 +308,8 @@ public function execute(InputInterface $input, OutputInterface $output) : int $this->docker->setGrain($instance_salt_name, "doil_project_name", $options["name"]); sleep(1); $this->docker->setGrain($instance_salt_name, "doil_host_system", "linux"); + sleep(1); + $this->docker->setGrain($instance_salt_name, "ilias_version", $ilias_version); if ($this->linux->isWSL()) { $this->docker->setGrain($instance_salt_name, "doil_host_system", "windows"); } @@ -728,8 +730,16 @@ protected function getBranches(OutputInterface $output, string $path, string $ur protected function getIliasVersion(string $path) : string { + if ($this->filesystem->exists($path . "/volumes/ilias/include/inc.ilias_version.php")) { + $ilias_version_path = $path . "/volumes/ilias/include/inc.ilias_version.php"; + } else if ($this->filesystem->exists($path . "/volumes/ilias/ilias_version.php")) { + $ilias_version_path = $path . "/volumes/ilias/ilias_version.php"; + } else { + throw new RuntimeException("Can't detect ilias version!"); + } + $ilias_version = $this->filesystem->getLineInFile( - $path . "/volumes/ilias/include/inc.ilias_version.php", + $ilias_version_path, "ILIAS_VERSION_NUMERIC" ); diff --git a/app/src/Commands/Instances/DeleteCommand.php b/app/src/Commands/Instances/DeleteCommand.php index 930e1058..56a28e97 100644 --- a/app/src/Commands/Instances/DeleteCommand.php +++ b/app/src/Commands/Instances/DeleteCommand.php @@ -131,18 +131,6 @@ protected function deleteInstance( string $suffix ) : int { $this->writer->beginBlock($output, "Delete instance $instance"); - if (! $this->docker->isInstanceUp($path)) { - $this->docker->startContainerByDockerCompose($path); - } - - $user_id = $this->posix->getUserId(); - $group_id = $this->posix->getGroupId(); - - $this->docker->executeCommand($path, $instance, "chown", "-R", "$user_id:$group_id", "/var/lib/mysql"); - $this->docker->executeCommand($path, $instance, "chown", "-R", "$user_id:$group_id", "/etc/mysql"); - $this->docker->executeCommand($path, $instance, "chown", "-R", "$user_id:$group_id", "/etc/php"); - - $this->docker->stopContainerByDockerCompose($path); $instance_dir = $this->filesystem->readLink($path); $this->filesystem->remove($path); diff --git a/app/tests/Commands/Instances/DeleteCommandTest.php b/app/tests/Commands/Instances/DeleteCommandTest.php index 99e8bcec..90b3d8ea 100644 --- a/app/tests/Commands/Instances/DeleteCommandTest.php +++ b/app/tests/Commands/Instances/DeleteCommandTest.php @@ -171,40 +171,16 @@ public function test_execute() : void ->method("isSudo") ->willReturn(true) ; - $posix - ->expects($this->once()) - ->method("getUserId") - ->willReturn(22) - ; - $posix - ->expects($this->once()) - ->method("getGroupId") - ->willReturn(33) - ; $docker - ->expects($this->once()) - ->method("isInstanceUp") - ->with("/usr/local/share/doil/instances/master") - ->willReturn(true) - ; - $docker - ->expects($this->exactly(6)) + ->expects($this->exactly(3)) ->method("executeCommand") ->withConsecutive( - ["/usr/local/share/doil/instances/master", "master", "chown", "-R", "22:33", "/var/lib/mysql"], - ["/usr/local/share/doil/instances/master", "master", "chown", "-R", "22:33", "/etc/mysql"], - ["/usr/local/share/doil/instances/master", "master", "chown", "-R", "22:33", "/etc/php"], ["/usr/local/lib/doil/server/salt/", "doil_saltmain", "salt-key", "-d", "master.global", "-y", "-q"], ["/usr/local/lib/doil/server/proxy/", "doil_proxy", "/bin/bash", "-c", "/etc/init.d/nginx reload &>/dev/null"], ["/usr/local/lib/doil/server/mail/", "doil_mail", "/bin/bash", "-c", "/root/delete-postbox-configuration.sh $instance &>/dev/null"] ) ; - $docker - ->expects($this->once()) - ->method("stopContainerByDockerCompose") - ->with("/usr/local/share/doil/instances/master") - ; $docker ->expects($this->once()) ->method("removeContainer") diff --git a/setup/stack/states/apache/apache/default_ilias10 b/setup/stack/states/apache/apache/default_ilias10 new file mode 100644 index 00000000..996504d0 --- /dev/null +++ b/setup/stack/states/apache/apache/default_ilias10 @@ -0,0 +1,12 @@ + + ServerAdmin root@concepts-and-training.de + DocumentRoot /var/www/html/ + + Alias /{{ doil_project_name }}/adminer /var/www/adminer + Alias /{{ doil_project_name }} /var/www/html/public + + + AllowOverride All + Require all granted + + \ No newline at end of file diff --git a/setup/stack/states/apache/apache/init.sls b/setup/stack/states/apache/apache/init.sls index 985aa542..0e88d033 100755 --- a/setup/stack/states/apache/apache/init.sls +++ b/setup/stack/states/apache/apache/init.sls @@ -1,7 +1,6 @@ -{% set apache_conf = salt['pillar.get']('web:apache_conf', 'salt://apache/default') %} -{% set apache_docroot = salt['pillar.get']('web:docroot', '/var/www/html/') %} {% set doil_domain = salt['grains.get']('doil_domain', 'http://ilias.local') %} {% set doil_project_name = salt['grains.get']('doil_project_name', 'ilias') %} +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} apache_packages: pkg.installed: @@ -9,12 +8,23 @@ apache_packages: - apache2 - supervisor -/etc/apache2/sites-available/000-default.conf: +{% if ilias_version | int < 10 %} +sites_available_lt_10: file.managed: - - source: {{ apache_conf }} + - name: /etc/apache2/sites-available/000-default.conf + - source: salt://apache/default - template: jinja - context: doil_project_name: {{ doil_project_name }} +{% else %} +sites_available_ge_10: + file.managed: + - name: /etc/apache2/sites-available/000-default.conf + - source: salt://apache/default_ilias10 + - template: jinja + - context: + doil_project_name: {{ doil_project_name }} +{% endif %} /etc/apache2/sites-enabled/000-default.conf: file.symlink: diff --git a/setup/stack/states/autoinstall/autoinstall/init.sls b/setup/stack/states/autoinstall/autoinstall/init.sls index 00954e12..51e1b6c0 100755 --- a/setup/stack/states/autoinstall/autoinstall/init.sls +++ b/setup/stack/states/autoinstall/autoinstall/init.sls @@ -1,6 +1,7 @@ {% set mysql_password = salt['grains.get']('mysql_password', 'ilias') %} {% set doil_domain = salt['grains.get']('doil_domain', 'http://ilias.local') %} {% set doil_host_system = salt['grains.get']('doil_host_system', 'linux') %} +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} /var/ilias/data/ilias-config.json: file.managed: @@ -23,9 +24,15 @@ log_dir: /var/ilias/logs http_path: '{{ doil_domain }}' -ilias-setup: +{% if ilias_version | int < 10 %} +ilias_setup_lt_10: cmd.run: - name: php /var/www/html/setup/setup.php install -y /var/ilias/data/ilias-config.json +{% else %} +ilias_setup_ge_10: + cmd.run: + - name: php /var/www/html/cli/setup.php install -y /var/ilias/data/ilias-config.json +{% endif %} {% if salt['grains.get'] == 'linux' %} /var/www/html/: diff --git a/setup/stack/states/disable-https/https/init.sls b/setup/stack/states/disable-https/https/init.sls index fd4af2f5..2ff7ddd4 100644 --- a/setup/stack/states/disable-https/https/init.sls +++ b/setup/stack/states/disable-https/https/init.sls @@ -1,3 +1,5 @@ +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} + apt_add_jq_tool: pkg.installed: - pkgs: @@ -11,12 +13,21 @@ rewrite_ilias_config: - watch: - pkg: apt_add_jq_tool -update_ilias: +{% if ilias_version | int < 10 %} +update_ilias_lt_10: cmd.wait: - name: php setup/setup.php update -y /var/ilias/data/ilias-config.json - cwd: /var/www/html - watch: - cmd: rewrite_ilias_config +{% else %} +update_ilias_ge_10: + cmd.wait: + - name: php cli/setup.php update -y /var/ilias/data/ilias-config.json + - cwd: /var/www/html + - watch: + - cmd: rewrite_ilias_config +{% endif %} apt_remove_jq_tool: pkg.removed: diff --git a/setup/stack/states/disable-whoops-devmode/whoops-devmode/init.sls b/setup/stack/states/disable-whoops-devmode/whoops-devmode/init.sls index 43950022..5592aa94 100644 --- a/setup/stack/states/disable-whoops-devmode/whoops-devmode/init.sls +++ b/setup/stack/states/disable-whoops-devmode/whoops-devmode/init.sls @@ -1,11 +1,18 @@ +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} +{% if ilias_version | int < 10 %} +{% set client_ini_path = '/var/www/html/data/ilias/client.ini.php' %} +{% else %} +{% set client_ini_path = '/var/www/html/public/data/ilias/client.ini.php' %} +{% endif %} + remove_use_whoops: file.line: - - name: /var/www/html/data/ilias/client.ini.php + - name: {{ client_ini_path }} - match: '^USE_WHOOPS' - mode: delete remove_devmode: file.line: - - name: /var/www/html/data/ilias/client.ini.php + - name: {{ client_ini_path }} - match: '^DEVMODE' - mode: delete \ No newline at end of file diff --git a/setup/stack/states/enable-https/https/init.sls b/setup/stack/states/enable-https/https/init.sls index 602bc6fa..51086630 100644 --- a/setup/stack/states/enable-https/https/init.sls +++ b/setup/stack/states/enable-https/https/init.sls @@ -1,3 +1,5 @@ +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} + apt_add_jq_tool: pkg.installed: - pkgs: @@ -11,12 +13,21 @@ rewrite_ilias_config: - watch: - pkg: apt_add_jq_tool -update_ilias: +{% if ilias_version | int < 10 %} +update_ilias_lt_10: cmd.wait: - name: php setup/setup.php update -y /var/ilias/data/ilias-config.json - cwd: /var/www/html - watch: - cmd: rewrite_ilias_config +{% else %} +update_ilias_ge_10: + cmd.wait: + - name: php cli/setup.php update -y /var/ilias/data/ilias-config.json + - cwd: /var/www/html + - watch: + - cmd: rewrite_ilias_config +{% endif %} apt_remove_jq_tool: pkg.removed: diff --git a/setup/stack/states/enable-whoops-devmode/whoops-devmode/init.sls b/setup/stack/states/enable-whoops-devmode/whoops-devmode/init.sls index d2989fa5..b9d597f5 100644 --- a/setup/stack/states/enable-whoops-devmode/whoops-devmode/init.sls +++ b/setup/stack/states/enable-whoops-devmode/whoops-devmode/init.sls @@ -1,12 +1,19 @@ +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} +{% if ilias_version | int < 10 %} +{% set client_ini_path = '/var/www/html/data/ilias/client.ini.php' %} +{% else %} +{% set client_ini_path = '/var/www/html/public/data/ilias/client.ini.php' %} +{% endif %} + remove_use_whoops: file.line: - - name: /var/www/html/data/ilias/client.ini.php + - name: {{ client_ini_path }} - match: '^USE_WHOOPS' - mode: delete add_use_whoops: file.line: - - name: /var/www/html/data/ilias/client.ini.php + - name: {{ client_ini_path }} - after: '^\[system\]' - before: '^ROOT_FOLDER_ID' - mode: insert @@ -14,13 +21,13 @@ add_use_whoops: remove_devmode: file.line: - - name: /var/www/html/data/ilias/client.ini.php + - name: {{ client_ini_path }} - match: '^DEVMODE' - mode: delete add_devmode: file.line: - - name: /var/www/html/data/ilias/client.ini.php + - name: {{ client_ini_path }} - after: '^\[system\]' - before: '^ROOT_FOLDER_ID' - mode: insert diff --git a/setup/stack/states/ilias/ilServer/ilServer.ini b/setup/stack/states/ilias/ilServer/ilServer.ini index 87f2978c..f27de718 100755 --- a/setup/stack/states/ilias/ilServer/ilServer.ini +++ b/setup/stack/states/ilias/ilServer/ilServer.ini @@ -11,4 +11,4 @@ IndexMaxFileSizeMB = 500 [Client1] ClientId = ilias NicId = 0 -IliasIniPath = /var/www/html/ilias.ini.php +IliasIniPath = {{ path }} diff --git a/setup/stack/states/ilias/ilServer/init.sls b/setup/stack/states/ilias/ilServer/init.sls index e1fde321..a2278975 100755 --- a/setup/stack/states/ilias/ilServer/init.sls +++ b/setup/stack/states/ilias/ilServer/init.sls @@ -1,3 +1,5 @@ +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} + ilServer_packages: pkg.installed: - pkgs: @@ -8,6 +10,7 @@ javaport_grain: - name: javaport - value: 11111 +{% if ilias_version | int < 10 %} /var/www/html/Services/WebServices/RPC/lib/ilServer.ini: file: - managed @@ -17,10 +20,19 @@ javaport_grain: - mode: 644 - template: jinja - context: - port: 11111 - path: /var/www/html - clientid: ilias - ip: salt['grains.get']('ip_interfaces')['eth0'][0] + path: /var/www/html/ilias.ini.php +{% else %} +/var/www/html/components/ILIAS/WebServices/RPC/lib/ilServer.ini: + file: + - managed + - source: salt://ilServer/ilServer.ini + - user: www-data + - group: www-data + - mode: 644 + - template: jinja + - context: + path: /var/www/html/scripts/ilias.ini.php +{% endif %} /etc/supervisor/conf.d/ilServer.conf: file: diff --git a/setup/stack/states/nodejs/nodejs/init.sls b/setup/stack/states/nodejs/nodejs/init.sls index 21e62904..f9c4a8a6 100755 --- a/setup/stack/states/nodejs/nodejs/init.sls +++ b/setup/stack/states/nodejs/nodejs/init.sls @@ -1,3 +1,5 @@ +{% set ilias_version = salt['grains.get']('ilias_version', '9') %} + get_npm_by_curl: cmd.run: - name: curl -sL https://deb.nodesource.com/setup_16.x | bash - @@ -14,8 +16,16 @@ update_npm: - watch: - install_node_js -install_ilias_npm_packages: +{% if ilias_version | int < 10 %} +install_ilias_npm_packages_lt_10: + cmd.run: + - name: cd /var/www/html && npm clean-install --ignore-scripts + - watch: + - update_npm +{% else %} +install_ilias_npm_packages_ge_10: cmd.run: - - name: cd /var/www/html && npm install --ignore-scripts + - name: cd /var/www/html/public && npm clean-install --ignore-scripts - watch: - - update_npm \ No newline at end of file + - update_npm +{% endif %} \ No newline at end of file diff --git a/setup/updates/update-20231115.sh b/setup/updates/update-20231115.sh new file mode 100644 index 00000000..db01fc54 --- /dev/null +++ b/setup/updates/update-20231115.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +source ${SCRIPT_DIR}/updates/update.sh + +doil_update_20231115() { + update + return $? +}