From f565c082fa1b839326433ad149e32223f7447eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 19 Nov 2021 21:14:19 +0100 Subject: [PATCH] Testing (#86) * Add admin --- check_process | 2 ++ conf/systemd.service | 4 ++++ manifest.json | 8 ++++++++ scripts/_common.sh | 2 +- scripts/install | 14 +++++++++----- scripts/remove | 4 ++++ scripts/restore | 2 +- scripts/upgrade | 9 ++++++--- 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/check_process b/check_process index 8b9b820..cc2fe7c 100644 --- a/check_process +++ b/check_process @@ -2,7 +2,9 @@ ; Manifest domain="domain.tld" path="/path" + admin="john" is_public=1 + password="1Strong-Password" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/conf/systemd.service b/conf/systemd.service index 59299ec..1e5b3bb 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -17,6 +17,10 @@ Environment=MONGO_URL=mongodb://localhost:27017/__APP__?replicaSet=rs01 Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 Environment=ROOT_URL=https://__DOMAIN____PATH__ Environment=PORT=__PORT__ +Environment=ADMIN_USERNAME=__ADMIN__ +Environment=ADMIN_PASS=__PASSWORD__ +Environment=ADMIN_EMAIL=__EMAIL__ +Environment=OVERWRITE_SETTING_Show_Setup_Wizard=completed [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 944f3a9..3a6d61c 100644 --- a/manifest.json +++ b/manifest.json @@ -39,10 +39,18 @@ "example": "/rocketchat", "default": "/rocketchat" }, + { + "name": "admin", + "type": "user" + }, { "name": "is_public", "type": "boolean", "default": true + }, + { + "name": "password", + "type": "password" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 02a93b8..bbf1cfe 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -357,7 +357,7 @@ ynh_remove_mongo() { # Only remove the mongodb service if it is not installed. if ! ynh_package_is_installed --package="mongodb*" then - ynh_print_info --message="Removing MongoDB service..." + ynh_script_progression --message="Removing MongoDB service..." --weight=2 # Define Mongo Service Name if [ "$(lsb_release --codename --short)" = "buster" ]; then MONGODB_SERVICENAME=$MONGO_CE_SERVICENAME diff --git a/scripts/install b/scripts/install index 55f6106..dd22856 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,9 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +password=$YNH_APP_ARG_PASSWORD +admin=$YNH_APP_ARG_ADMIN +email=$(ynh_user_get_info --username=$admin --key=mail) app=$YNH_APP_INSTANCE_NAME @@ -47,6 +50,9 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=admin --value=$admin +ynh_app_setting_set --app=$app --key=password --value=$password +ynh_app_setting_set --app=$app --key=email --value=$email #================================================= # STANDARD MODIFICATIONS @@ -80,8 +86,6 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name -#mongo < ../conf/rocketchat_ldap.js - #================================================= # CREATE DEDICATED USER #================================================= @@ -101,7 +105,7 @@ ynh_setup_source --dest_dir=$final_path chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -120,7 +124,7 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd $final_path/programs/server ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH npm install 2>/dev/null + ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null popd #================================================= @@ -179,7 +183,7 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_systemd_action --service_name=$app --action=start --log_path=systemd -sleep 120 +sleep 100 #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 33b029f..3e8bd12 100644 --- a/scripts/remove +++ b/scripts/remove @@ -77,6 +77,10 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +if [ -d "/tmp/ufs" ]; then + ynh_secure_remove --file="/tmp/ufs" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 95372e4..f801460 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,7 +65,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 92452bc..2e10976 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,9 @@ admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) port=$(ynh_app_setting_get --app=$app --key=port) +password=$(ynh_app_setting_get --app=$app --key=password) +admin=$(ynh_app_setting_get --app=$app --key=admin) +email=$(ynh_app_setting_get --app=$app --key=email) #================================================= # CHECK VERSION @@ -93,7 +96,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -119,7 +122,7 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd $final_path/programs/server ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH npm install 2>/dev/null + ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null popd #================================================= @@ -169,7 +172,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=10 ynh_systemd_action --service_name=$mongodb_servicename --action=restart --log_path=systemd ynh_systemd_action --service_name=$app --action=start --log_path=systemd -sleep 120 +sleep 100 #================================================= # RELOAD NGINX