Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master trunk: apply changes to install ilias10 #406

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 20231114 - build 2023-11-14";
const NAME = "Doil Version 20231115 - build 2023-11-15";

public function __construct(Command ...$commands)
{
Expand Down
12 changes: 11 additions & 1 deletion app/src/Commands/Instances/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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"
);

Expand Down
12 changes: 0 additions & 12 deletions app/src/Commands/Instances/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 1 addition & 25 deletions app/tests/Commands/Instances/DeleteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 12 additions & 0 deletions setup/stack/states/apache/apache/default_ilias10
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/

Alias /{{ doil_project_name }}/adminer /var/www/adminer
Alias /{{ doil_project_name }} /var/www/html/public

<Directory /var/www/html/public/>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
18 changes: 14 additions & 4 deletions setup/stack/states/apache/apache/init.sls
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
{% 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:
- pkgs:
- 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:
Expand Down
9 changes: 8 additions & 1 deletion setup/stack/states/autoinstall/autoinstall/init.sls
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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/:
Expand Down
13 changes: 12 additions & 1 deletion setup/stack/states/disable-https/https/init.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set ilias_version = salt['grains.get']('ilias_version', '9') %}

apt_add_jq_tool:
pkg.installed:
- pkgs:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion setup/stack/states/enable-https/https/init.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set ilias_version = salt['grains.get']('ilias_version', '9') %}

apt_add_jq_tool:
pkg.installed:
- pkgs:
Expand All @@ -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:
Expand Down
15 changes: 11 additions & 4 deletions setup/stack/states/enable-whoops-devmode/whoops-devmode/init.sls
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
{% 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
- content: 'USE_WHOOPS = "1"'

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
Expand Down
2 changes: 1 addition & 1 deletion setup/stack/states/ilias/ilServer/ilServer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ IndexMaxFileSizeMB = 500
[Client1]
ClientId = ilias
NicId = 0
IliasIniPath = /var/www/html/ilias.ini.php
IliasIniPath = {{ path }}
20 changes: 16 additions & 4 deletions setup/stack/states/ilias/ilServer/init.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% set ilias_version = salt['grains.get']('ilias_version', '9') %}

ilServer_packages:
pkg.installed:
- pkgs:
Expand All @@ -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
Expand All @@ -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:
Expand Down
16 changes: 13 additions & 3 deletions setup/stack/states/nodejs/nodejs/init.sls
Original file line number Diff line number Diff line change
@@ -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 -
Expand All @@ -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
- update_npm
{% endif %}
8 changes: 8 additions & 0 deletions setup/updates/update-20231115.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

source ${SCRIPT_DIR}/updates/update.sh

doil_update_20231115() {
update
return $?
}
Loading