diff --git a/scripts/_common.sh b/scripts/_common.sh index ac79128..f24d870 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,6 +10,29 @@ nodejs_version=12 # PERSONAL HELPERS #================================================= +_configure_framagames() { + ynh_replace_string --target_file="$install_dir/sources/src/data/main.yml" \ + --match_string="canonical: .*" \ + --replace_string="canonical: https://$domain$path" + + ynh_replace_string --target_file="$install_dir/sources/config/env.js" \ + --match_string=": '/'," \ + --replace_string=": '$path/'," +} + +_build_install_framagames() { + pushd "$install_dir/sources" + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run commons + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run prod + popd + + mv -f "$install_dir/sources/dist" "$install_dir/www" + mv -f "$install_dir/sources/games/"* "$install_dir/www" + cp "$install_dir/www/fr/index.html" "$install_dir/www/index.html" + # cd public && for f in $(find -type l);do cp --remove-destination $(readlink -f $f) $f;done; +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index be44aee..342aced 100755 --- a/scripts/backup +++ b/scripts/backup @@ -25,12 +25,6 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE PHP-FPM CONFIGURATION -#================================================= - -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 6dd5830..6348524 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,6 +14,20 @@ ynh_script_progression --message="Updating NGINX web server configuration..." ynh_change_url_nginx_config +#================================================= +# CONFIGURE APP +#================================================= +ynh_script_progression --message="Configuring $app..." + +_configure_framagames + +#================================================= +# BUILD APP +#================================================= +ynh_script_progression --message="Building $app..." + +_build_install_framagames + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index aa29251..6089329 100644 --- a/scripts/install +++ b/scripts/install @@ -30,29 +30,14 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Configuring $app..." -ynh_replace_string --target_file="$install_dir/sources/src/data/main.yml" \ - --match_string="canonical: .*" \ - --replace_string="canonical: https://$domain$path" - -ynh_replace_string --target_file="$install_dir/sources/config/env.js" \ - --match_string=": '/'," \ - --replace_string=": '$path/'," +_configure_framagames #================================================= # BUILD APP #================================================= ynh_script_progression --message="Building $app..." -pushd "$install_dir/sources" - ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run commons - ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" "$ynh_npm" run prod -popd - -mv -f "$install_dir/sources/dist" "$install_dir/www" -mv -f "$install_dir/sources/games/"* "$install_dir/www" -cp "$install_dir/www/fr/index.html" "$install_dir/www/index.html" -# cd public && for f in $(find -type l);do cp --remove-destination $(readlink -f $f) $f;done; +_build_install_framagames #================================================= # SYSTEM CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 998f2e0..7016c53 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,6 +8,13 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL NODEJS +#================================================= +ynh_script_progression --message="Restoring NodeJS..." --weight=1 + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -16,15 +23,13 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= @@ -32,7 +37,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 465b62e..bfced82 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,13 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL NODEJS +#================================================= +ynh_script_progression --message="Updating NodeJS..." --weight=1 + +ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -16,15 +23,26 @@ ynh_script_progression --message="Upgrading source files..." ynh_setup_source --dest_dir="$install_dir" --full_replace=1 chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= -# REAPPLY SYSTEM CONFIGURATIONS +# CONFIGURE APP #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression --message="Configuring $app..." -# Create a dedicated PHP-FPM config -ynh_add_fpm_config +_configure_framagames + +#================================================= +# BUILD APP +#================================================= +ynh_script_progression --message="Building $app..." + +_build_install_framagames + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config