From 9c37e95309833ae19048ee1e53b8c4070f3e7f8d Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 21 Jun 2018 08:18:02 +0530 Subject: Improved the app --- scripts/restore | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/restore b/scripts/restore index a8dc79f..4716e64 100644 --- a/scripts/restore +++ b/scripts/restore @@ -62,8 +62,7 @@ ynh_restore_file "$final_path" # RECREATE THE DEDICATED USER #================================================= -# Create user unix -adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password +ynh_system_user_create $app #================================================= # RESTORE USER RIGHTS @@ -95,13 +94,8 @@ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list ynh_package_update -# Install de Node.js -# TODO: use https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_install_nodejs/ynh_install_nodejs -( - cd /opt - curl -sL https://deb.nodesource.com/setup_6.x | bash - - apt-get -y install nodejs -) +# install nodejs +ynh_install_nodejs 8 # TODO: use the same mecanism with other files ynh_install_app_dependencies \ @@ -123,25 +117,17 @@ ynh_install_app_dependencies \ #================================================= # Restore PostgreSQL database -db_user=$(ynh_sanitize_dbid "$app") + db_name=$(ynh_app_setting_get "$app" db_name) -if [ -z "$db_name" ]; then - db_name="${app}_production" - ynh_app_setting_set "$app" db_name "$db_name" -fi db_pwd=$(ynh_app_setting_get "$app" db_pwd) ynh_psql_test_if_first_run -ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd" +ynh_psql_create_user "$app" "$db_pwd" +ynh_psql_execute_as_root \ +"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $app;" ynh_psql_execute_file_as_root ./db.sql "$db_name" -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= -yunohost service add $app-web -yunohost service add $app-sidekiq -yunohost service add $app-streaming #================================================= # RESTORE SYSTEMD @@ -152,11 +138,21 @@ ynh_restore_file "/etc/systemd/system/$app-sidekiq.service" ynh_restore_file "/etc/systemd/system/$app-streaming.service" systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app-web +yunohost service add $app-sidekiq +yunohost service add $app-streaming + #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND services #================================================= systemctl restart "$app-web" "$app-sidekiq" "$app-streaming" +# Waiting start all services +sleep 30 systemctl reload nginx -- cgit v1.2.3-70-g09d2 From 531aaa6a47c87e41f18eff02a4dd10d2481f9a08 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 21 Jun 2018 08:44:18 +0530 Subject: Fallback user create command --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/install b/scripts/install index f4a8f63..cd9a1ce 100644 --- a/scripts/install +++ b/scripts/install @@ -144,7 +144,7 @@ ynh_add_nginx_config #================================================= # Create a system user -ynh_system_user_create $app +adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password chown -R "$app" "$final_path" diff --git a/scripts/restore b/scripts/restore index 4716e64..a25bb6f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -62,7 +62,7 @@ ynh_restore_file "$final_path" # RECREATE THE DEDICATED USER #================================================= -ynh_system_user_create $app +adduser $app --home $final_path --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index a9cde11..0f99bab 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,12 +112,6 @@ ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf" ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf" ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= - -# Create a system user -ynh_system_user_create $app # Upgrade rbenv and ruby plugins ynh_setup_source "$final_path/.rbenv" "app-rbenv" -- cgit v1.2.3-70-g09d2