From c822ddfe4b8eccebd51789767258cc8d0ab13547 Mon Sep 17 00:00:00 2001 From: MatteoGheza Date: Tue, 16 Mar 2021 11:10:38 +0000 Subject: [PATCH] Fixes --- .gitignore | 1 + .gitpod.yml | 25 +++++++++++++++++-------- server/install/installHelper.php | 19 +++++++++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 901db68..7377c24 100644 --- a/.gitignore +++ b/.gitignore @@ -521,6 +521,7 @@ sw.js !/server/cypress/videos/.gitkeep deployment_remotes.php +adminer.php /server/resources/images/logo.png /server/resources/images/owner.png \ No newline at end of file diff --git a/.gitpod.yml b/.gitpod.yml index e4c2bb2..7c00d22 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,5 +1,3 @@ -#Inspired from - image: file: .gitpod.dockerfile ports: @@ -10,9 +8,12 @@ ports: tasks: - name: Apache command: > - touch /var/log/apache2/error.log; - touch /var/log/apache2/access.log; - multitail /var/log/apache2/error.log -I /var/log/apache2/access.log + mkdir /tmp/apache; + touch /tmp/apache/error.log; + touch /tmp/apache/access.log; + export APACHE_PID_FILE="/tmp/apache/PID" APACHE_RUN_USER="gitpod" APACHE_RUN_GROUP="gitpod" APACHE_SERVER_NAME="localhost" APACHE_LOG_DIR="/tmp/apache"; + apache2; + multitail /tmp/apache/error.log -I /tmp/apache/access.log; - name: Allerta init: > cd server; @@ -29,6 +30,14 @@ tasks: mysql -e "CREATE USER 'allerta'@'localhost' IDENTIFIED BY 'allerta_pwd';"; mysql -e "GRANT ALL PRIVILEGES ON * . * TO 'allerta'@'localhost';"; mysqladmin reload; - php install.php config -n "allerta" -u "allerta" -a "allerta_pwd" -o "127.0.0.1" -r "DEV_ENV"; - php install.php populate -m "admin" -b -s "password" -w "owner" -e "mail@mailserver.local"; - apachectl start; \ No newline at end of file + php install.php config -n "allerta" -u "allerta" -a "allerta_pwd" -o $WORKSPACE_URL -r "DEV_ENV"; + php install.php populate -m "admin" -b -d -s "password" -w "owner" -e "mail@mailserver.local"; + cd ..; + wget https://github.com/vrana/adminer/releases/download/v4.8.0/adminer-4.8.0.php; + mv adminer-4.8.0.php adminer.php +vscode: + extensions: + - gruntfuggly.todo-tree@0.0.205:sbsZJOTJzKZtMVHQuS2iPw== + - coenraads.bracket-pair-colorizer-2@0.1.4:+JUeb/jFYZt2/0MS/gUllA== + - shelex.vscode-cy-helper@1.1.0:U9ok2y1bSmqn17OMuRMOfw== + - hookyqr.beautify@1.4.11:n9DJEUFbYD/YHaBXxm+pYw== \ No newline at end of file diff --git a/server/install/installHelper.php b/server/install/installHelper.php index f3903d4..d82bc2e 100644 --- a/server/install/installHelper.php +++ b/server/install/installHelper.php @@ -461,7 +461,7 @@ function full_path() return $url; } -function initOptions($name, $visible, $developer, $password, $report_email, $owner) +function initOptions($name, $visible, $developer, $password, $report_email, $owner, $url=null) { try{ include_once "../config.php"; @@ -508,7 +508,10 @@ INSERT INTO `".$prefix."_profiles` (`id`, `hidden`) VALUES (NULL, :hidden);".$qu $prep->bindValue(':hidden', ($visible ? 0 : 1), PDO::PARAM_INT); $prep->bindValue(':report_email', $report_email, PDO::PARAM_STR); $prep->bindValue(':owner', $owner, PDO::PARAM_STR); - $prep->bindValue(':web_url', str_replace("install/install.php", "", full_path()), PDO::PARAM_STR); + if(is_null($url)){ + $url = str_replace("install/install.php", "", full_path()); + } + $prep->bindValue(':web_url', $url, PDO::PARAM_STR); $prep->bindValue(':cron_job_code', str_replace(".", "", bin2hex(random_bytes(10)).base64_encode(openssl_random_pseudo_bytes(30))), PDO::PARAM_STR); $prep->bindValue(':cron_job_time', "01;00:00", PDO::PARAM_STR); $prep->execute(); @@ -564,11 +567,13 @@ function cli_helper($action, $options) case "populate": $name = validate_arg($options, "name", "admin"); $visible = array_key_exists("visible", $options); + $developer = array_key_exists("developer", $options); $password = validate_arg($options, "password", "password"); $report_email = validate_arg($options, "report_email", "postmaster@localhost.local"); $owner = validate_arg($options, "owner", "Owner"); + $url = validate_arg($options, "url", "htp://localhost/"); initDB(); - initOptions($name, $visible, $password, $report_email, $owner); + initOptions($name, $visible, $developer, $password, $report_email, $owner, $url); t("DB Populated successful"); finalInstallationHelperStep(); exit(0); @@ -612,6 +617,9 @@ function run_cli() \GetOpt\Option::create('b', 'visible', \GetOpt\GetOpt::NO_ARGUMENT) ->setDescription(t("Is admin visible?", false)) ->setArgumentName(t("Is admin visible?", false)), + \GetOpt\Option::create('d', 'developer', \GetOpt\GetOpt::NO_ARGUMENT) + ->setDescription(t("Enable devmode per the user", false)) + ->setArgumentName(t("Enable devmode per the user", false)), \GetOpt\Option::create('s', 'password', \GetOpt\GetOpt::OPTIONAL_ARGUMENT) ->setDescription(t("Admin password", false)) ->setArgumentName(t("Admin password", false)), @@ -620,7 +628,10 @@ function run_cli() ->setArgumentName(t("Owner", false)), \GetOpt\Option::create('e', 'report_email', \GetOpt\GetOpt::OPTIONAL_ARGUMENT) ->setDescription(t("Report email", false)) - ->setArgumentName(t("Report email", false)) + ->setArgumentName(t("Report email", false)), + \GetOpt\Option::create('u', 'url', \GetOpt\GetOpt::OPTIONAL_ARGUMENT) + ->setDescription(t("App url", false)) + ->setArgumentName(t("App url", false)), ] )->setDescription( t("Populate Allerta database", false) . "." . PHP_EOL .