Просмотр исходного кода

Dolibarr App (#4668)

* Dolibarr App
* Run NPM Format

----

Co-authored-by: Sergi Almacellas Abellana <sergi@kopen.es>
Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
Aitor Roma 1 год назад
Родитель
Сommit
82a2a1b8cc

+ 86 - 0
install/deb/templates/web/nginx/php-fpm/dolibarr.stpl

@@ -0,0 +1,86 @@
+#=========================================================================#
+# Default Web Domain Template                                             #
+# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
+# https://hestiacp.com/docs/server-administration/web-templates.html      #
+#=========================================================================#
+
+server {
+	listen      %ip%:%web_ssl_port% ssl;
+	server_name %domain_idn% %alias_idn%;
+	root        %sdocroot%/htdocs;
+	index       index.php index.html index.htm;
+	access_log  /var/log/nginx/domains/%domain%.log combined;
+	access_log  /var/log/nginx/domains/%domain%.bytes bytes;
+	error_log   /var/log/nginx/domains/%domain%.error.log error;
+
+	ssl_certificate     %ssl_pem%;
+	ssl_certificate_key %ssl_key%;
+	ssl_stapling        on;
+	ssl_stapling_verify on;
+
+	# TLS 1.3 0-RTT anti-replay
+	if ($anti_replay = 307) { return 307 https://$host$request_uri; }
+	if ($anti_replay = 425) { return 425; }
+
+	include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
+
+	location = /favicon.ico {
+		log_not_found off;
+		access_log off;
+	}
+
+	location = /robots.txt {
+		try_files $uri $uri/ /index.php?$args;
+		log_not_found off;
+		access_log off;
+	}
+
+	location ~ /\.(?!well-known\/) {
+		deny all;
+		return 404;
+	}
+
+	location / {
+		try_files $uri $uri/ /index.php?$args;
+
+		location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+			expires 30d;
+			fastcgi_hide_header "Set-Cookie";
+		}
+
+		location ~* /(?:uploads|files)/.*.php$ {
+			deny all;
+			return 404;
+		}
+
+		location ~ [^/]\.php(/|$) {
+			try_files $uri =404;
+
+			include /etc/nginx/fastcgi_params;
+
+			fastcgi_index index.php;
+			fastcgi_param HTTP_EARLY_DATA $rfc_early_data if_not_empty;
+			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+			fastcgi_pass %backend_lsnr%;
+
+			include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
+
+		}
+	}
+
+	location /error/ {
+		alias %home%/%user%/web/%domain%/document_errors/;
+	}
+
+	location /vstats/ {
+		alias   %home%/%user%/web/%domain%/stats/;
+		include %home%/%user%/web/%domain%/stats/auth.conf*;
+	}
+
+	proxy_hide_header Upgrade;
+
+	include /etc/nginx/conf.d/phpmyadmin.inc*;
+	include /etc/nginx/conf.d/phppgadmin.inc*;
+	include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
+}

+ 74 - 0
install/deb/templates/web/nginx/php-fpm/dolibarr.tpl

@@ -0,0 +1,74 @@
+#=========================================================================#
+# Default Web Domain Template                                             #
+# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
+# https://hestiacp.com/docs/server-administration/web-templates.html      #
+#=========================================================================#
+
+server {
+	listen      %ip%:%web_port%;
+	server_name %domain_idn% %alias_idn%;
+	root        %docroot%/htdocs;
+	index       index.php index.html index.htm;
+	access_log  /var/log/nginx/domains/%domain%.log combined;
+	access_log  /var/log/nginx/domains/%domain%.bytes bytes;
+	error_log   /var/log/nginx/domains/%domain%.error.log error;
+
+	include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
+
+	location = /favicon.ico {
+		log_not_found off;
+		access_log off;
+	}
+
+	location = /robots.txt {
+		try_files $uri $uri/ /index.php?$args;
+		log_not_found off;
+		access_log off;
+	}
+
+	location ~ /\.(?!well-known\/) {
+		deny all;
+		return 404;
+	}
+
+	location / {
+		try_files $uri $uri/ /index.php?$args;
+
+		location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+			expires 30d;
+			fastcgi_hide_header "Set-Cookie";
+		}
+
+		location ~* /(?:uploads|files)/.*.php$ {
+			deny all;
+			return 404;
+		}
+
+		location ~ [^/]\.php(/|$) {
+			try_files $uri =404;
+
+			include /etc/nginx/fastcgi_params;
+
+			fastcgi_index index.php;
+			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+			fastcgi_pass %backend_lsnr%;
+
+			include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
+
+		}
+	}
+
+	location /error/ {
+		alias %home%/%user%/web/%domain%/document_errors/;
+	}
+
+	location /vstats/ {
+		alias   %home%/%user%/web/%domain%/stats/;
+		include %home%/%user%/web/%domain%/stats/auth.conf*;
+	}
+
+	include /etc/nginx/conf.d/phpmyadmin.inc*;
+	include /etc/nginx/conf.d/phppgadmin.inc*;
+	include %home%/%user%/conf/web/%domain%/nginx.conf_*;
+}

+ 86 - 0
install/rpm/templates/web/nginx/php-fpm/dolibarr.stpl

@@ -0,0 +1,86 @@
+#=========================================================================#
+# Default Web Domain Template                                             #
+# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
+# https://hestiacp.com/docs/server-administration/web-templates.html      #
+#=========================================================================#
+
+server {
+	listen      %ip%:%web_ssl_port% ssl;
+	server_name %domain_idn% %alias_idn%;
+	root        %sdocroot%/htdocs;
+	index       index.php index.html index.htm;
+	access_log  /var/log/nginx/domains/%domain%.log combined;
+	access_log  /var/log/nginx/domains/%domain%.bytes bytes;
+	error_log   /var/log/nginx/domains/%domain%.error.log error;
+
+	ssl_certificate     %ssl_pem%;
+	ssl_certificate_key %ssl_key%;
+	ssl_stapling        on;
+	ssl_stapling_verify on;
+
+	# TLS 1.3 0-RTT anti-replay
+	if ($anti_replay = 307) { return 307 https://$host$request_uri; }
+	if ($anti_replay = 425) { return 425; }
+
+	include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
+
+	location = /favicon.ico {
+		log_not_found off;
+		access_log off;
+	}
+
+	location = /robots.txt {
+		try_files $uri $uri/ /index.php?$args;
+		log_not_found off;
+		access_log off;
+	}
+
+	location ~ /\.(?!well-known\/) {
+		deny all;
+		return 404;
+	}
+
+	location / {
+		try_files $uri $uri/ /index.php?$args;
+
+		location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+			expires 30d;
+			fastcgi_hide_header "Set-Cookie";
+		}
+
+		location ~* /(?:uploads|files)/.*.php$ {
+			deny all;
+			return 404;
+		}
+
+		location ~ [^/]\.php(/|$) {
+			try_files $uri =404;
+
+			include /etc/nginx/fastcgi_params;
+
+			fastcgi_index index.php;
+			fastcgi_param HTTP_EARLY_DATA $rfc_early_data if_not_empty;
+			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+			fastcgi_pass %backend_lsnr%;
+
+			include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
+
+		}
+	}
+
+	location /error/ {
+		alias %home%/%user%/web/%domain%/document_errors/;
+	}
+
+	location /vstats/ {
+		alias   %home%/%user%/web/%domain%/stats/;
+		include %home%/%user%/web/%domain%/stats/auth.conf*;
+	}
+
+	proxy_hide_header Upgrade;
+
+	include /etc/nginx/conf.d/phpmyadmin.inc*;
+	include /etc/nginx/conf.d/phppgadmin.inc*;
+	include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
+}

+ 74 - 0
install/rpm/templates/web/nginx/php-fpm/dolibarr.tpl

@@ -0,0 +1,74 @@
+#=========================================================================#
+# Default Web Domain Template                                             #
+# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS   #
+# https://hestiacp.com/docs/server-administration/web-templates.html      #
+#=========================================================================#
+
+server {
+	listen      %ip%:%web_port%;
+	server_name %domain_idn% %alias_idn%;
+	root        %docroot%/htdocs;
+	index       index.php index.html index.htm;
+	access_log  /var/log/nginx/domains/%domain%.log combined;
+	access_log  /var/log/nginx/domains/%domain%.bytes bytes;
+	error_log   /var/log/nginx/domains/%domain%.error.log error;
+
+	include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
+
+	location = /favicon.ico {
+		log_not_found off;
+		access_log off;
+	}
+
+	location = /robots.txt {
+		try_files $uri $uri/ /index.php?$args;
+		log_not_found off;
+		access_log off;
+	}
+
+	location ~ /\.(?!well-known\/) {
+		deny all;
+		return 404;
+	}
+
+	location / {
+		try_files $uri $uri/ /index.php?$args;
+
+		location ~* ^.+\.(ogg|ogv|svg|svgz|swf|eot|otf|woff|woff2|mov|mp3|mp4|webm|flv|ttf|rss|atom|jpg|jpeg|gif|png|webp|ico|bmp|mid|midi|wav|rtf|css|js|jar)$ {
+			expires 30d;
+			fastcgi_hide_header "Set-Cookie";
+		}
+
+		location ~* /(?:uploads|files)/.*.php$ {
+			deny all;
+			return 404;
+		}
+
+		location ~ [^/]\.php(/|$) {
+			try_files $uri =404;
+
+			include /etc/nginx/fastcgi_params;
+
+			fastcgi_index index.php;
+			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+			fastcgi_pass %backend_lsnr%;
+
+			include %home%/%user%/conf/web/%domain%/nginx.fastcgi_cache.conf*;
+
+		}
+	}
+
+	location /error/ {
+		alias %home%/%user%/web/%domain%/document_errors/;
+	}
+
+	location /vstats/ {
+		alias   %home%/%user%/web/%domain%/stats/;
+		include %home%/%user%/web/%domain%/stats/auth.conf*;
+	}
+
+	include /etc/nginx/conf.d/phpmyadmin.inc*;
+	include /etc/nginx/conf.d/phppgadmin.inc*;
+	include %home%/%user%/conf/web/%domain%/nginx.conf_*;
+}

+ 142 - 0
web/src/app/WebApp/Installers/Dolibarr/DolibarrSetup.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace Hestia\WebApp\Installers\Dolibarr;
+
+use Hestia\WebApp\Installers\BaseSetup as BaseSetup;
+
+class DolibarrSetup extends BaseSetup {
+	protected $appInfo = [
+		"name" => "Dolibarr",
+		"group" => "CRM",
+		"enabled" => true,
+		"version" => "20.0.2",
+		"thumbnail" => "dolibarr-thumb.png",
+	];
+
+	protected $appname = "dolibarr";
+
+	protected $config = [
+		"form" => [
+			"dolibarr_account_username" => ["value" => "admin"],
+			"dolibarr_account_password" => "password",
+			"language" => [
+				"type" => "select",
+				"options" => [
+					"en_EN" => "English",
+					"es_ES" => "Spanish",
+					"fr_FR" => "French",
+					"de_DE" => "German",
+					"pt_PT" => "Portuguese",
+					"it_IT" => "Italian",
+				],
+				"default" => "en_EN",
+			],
+		],
+		"database" => true,
+		"resources" => [
+			"archive" => [
+				"src" => "https://github.com/Dolibarr/dolibarr/archive/refs/tags/20.0.2.zip",
+			],
+		],
+		"server" => [
+			"nginx" => [
+				"template" => "dolibarr",
+			],
+			"php" => [
+				"supported" => ["7.4", "8.0", "8.1", "8.2", "8.3"],
+			],
+		],
+	];
+
+	public function install(array $options = null): bool {
+		parent::install($options);
+		parent::setup($options);
+
+		$this->appcontext->runUser(
+			"v-copy-fs-directory",
+			[$this->getDocRoot($this->extractsubdir . "/dolibarr-20.0.2/."), $this->getDocRoot()],
+			$status,
+		);
+
+		$this->appcontext->run(
+			"v-list-web-domain",
+			[$this->appcontext->user(), $this->domain, "json"],
+			$status,
+		);
+
+		$sslEnabled = $status->json[$this->domain]["SSL"] == "no" ? false : true;
+		$webDomain = ($sslEnabled ? "https://" : "http://") . $this->domain;
+
+		$language = $options["language"] ?? "en_EN";
+		$username = rawurlencode($options["dolibarr_account_username"]);
+		$password = rawurlencode($options["dolibarr_account_password"]);
+		$databaseUser = rawurlencode($this->appcontext->user() . "_" . $options["database_user"]);
+		$databasePassword = rawurlencode($options["database_password"]);
+		$databaseName = rawurlencode($this->appcontext->user() . "_" . $options["database_name"]);
+
+		$this->appcontext->runUser(
+			"v-copy-fs-file",
+			[
+				$this->getDocRoot("htdocs/conf/conf.php.example"),
+				$this->getDocRoot("htdocs/conf/conf.php"),
+			],
+			$status,
+		);
+
+		$this->appcontext->runUser(
+			"v-change-fs-file-permission",
+			[$this->getDocRoot("htdocs/conf/conf.php"), "666"],
+			$status,
+		);
+
+		$cmd =
+			"curl --request POST " .
+			($sslEnabled ? "" : "--insecure ") .
+			"--url $webDomain/install/step1.php " .
+			"--data 'testpost=ok&action=set" .
+			"&main_dir=" .
+			rawurlencode($this->getDocRoot("htdocs")) .
+			"&main_data_dir=" .
+			rawurlencode($this->getDocRoot("documents")) .
+			"&main_url=" .
+			rawurlencode($webDomain) .
+			"&db_name=$databaseName" .
+			"&db_type=mysqli" .
+			"&db_host=localhost" .
+			"&db_port=3306" .
+			"&db_prefix=llx_" .
+			"&db_user=$databaseUser" .
+			"&db_pass=$databasePassword" .
+			"&selectlang=$language' && " .
+			"curl --request POST " .
+			($sslEnabled ? "" : "--insecure ") .
+			"--url $webDomain/install/step2.php " .
+			"--data 'testpost=ok&action=set" .
+			"&dolibarr_main_db_character_set=utf8" .
+			"&dolibarr_main_db_collation=utf8_unicode_ci" .
+			"&selectlang=$language' && " .
+			"curl --request POST " .
+			($sslEnabled ? "" : "--insecure ") .
+			"--url $webDomain/install/step4.php " .
+			"--data 'testpost=ok&action=set" .
+			"&dolibarrpingno=checked" .
+			"&selectlang=$language' && " .
+			"curl --request POST " .
+			($sslEnabled ? "" : "--insecure ") .
+			"--url $webDomain/install/step5.php " .
+			"--data 'testpost=ok&action=set" .
+			"&login=$username" .
+			"&pass=$password" .
+			"&pass_verif=$password" .
+			"&selectlang=$language'";
+
+		exec($cmd, $output, $return_var);
+		if ($return_var > 0) {
+			throw new \Exception(implode(PHP_EOL, $output));
+		}
+
+		$this->cleanup();
+
+		return $status->code === 0;
+	}
+}

BIN
web/src/app/WebApp/Installers/Dolibarr/dolibarr-thumb.png