From 8e36867acd797f5a09ba38d22fcae140970f282b Mon Sep 17 00:00:00 2001 From: Neko Nekowazarashi Date: Thu, 1 Jun 2023 12:44:14 +0700 Subject: [PATCH] pakai nodejs dan ubah izin --- conf/systemd.service | 1 + scripts/change_url | 1 + scripts/install | 11 +++++++++-- scripts/remove | 2 ++ scripts/restore | 5 +++++ scripts/upgrade | 9 +++++++++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 752e578..ada7bcf 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,6 +6,7 @@ After=network.target Type=simple User=__APP__ Group=__APP__ +Environment=__YNH_NODE_LOAD_PATH__ WorkingDirectory=__INSTALL_DIR__/ ExecStart=yarn run next start -p __PORT__ diff --git a/scripts/change_url b/scripts/change_url index 207fb82..45c85e8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -70,6 +70,7 @@ fi #================================================= ynh_script_progression --message="Rebuilding the app..." --weight=1 +ynh_use_nodejs ynh_exec_warn_less yarn --cwd "$install_dir" build #================================================= diff --git a/scripts/install b/scripts/install index 26fdc57..993a523 100755 --- a/scripts/install +++ b/scripts/install @@ -48,8 +48,8 @@ chown $app:$app "$install_dir/.env.local" # CONFIGURATION FOR SUBPATH #================================================= -rm "$install_dir/public/manifest.json" -rm "$install_dir/next.config.js" +ynh_secure_remove --file="$install_dir/public/manifest.json" +ynh_secure_remove --file="$install_dir/next.config.js" if [ "$path" = "/" ]; then next_path="" @@ -69,11 +69,18 @@ ynh_replace_string --match_string="href=\"/apple" --replace_string="href=\"$next ynh_replace_string --match_string="href=\"/manifest" --replace_string="href=\"$next_path/manifest" --target_file="$install_dir/components/CustomHead.tsx" +chown $app:www-data "$install_dir/public/manifest.json" +chown $app:www-data "$install_dir/next.config.js" +chmod 664 "$install_dir/public/manifest.json" +chmod 664 "$install_dir/next.config.js" + #================================================= # BUILD AND INSTALL THE APP #================================================= ynh_script_progression --message="Building the app..." --weight=1 +ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_use_nodejs yarn config set enableTelemetry 0 ynh_exec_warn_less yarn --cwd "$install_dir" install yarn --cwd "$install_dir" run next telemetry disable diff --git a/scripts/remove b/scripts/remove index 0d88fec..e87bd68 100755 --- a/scripts/remove +++ b/scripts/remove @@ -42,6 +42,8 @@ ynh_remove_systemd_config ynh_remove_nginx_config +ynh_secure_remove --file="/var/log/$app/$app.log" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index fc7dd0b..2bda9d7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,9 +10,14 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +# starting nodejs for fresh install +ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_use_nodejs + #================================================= # RESTORE THE APP MAIN DIR #================================================= + ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" diff --git a/scripts/upgrade b/scripts/upgrade index 7520309..f43770c 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -110,6 +110,9 @@ chown $app:$app "$install_dir/.env.local" # CONFIGURATION FOR SUBPATH #================================================= +ynh_secure_remove --file="$install_dir/public/manifest.json" +ynh_secure_remove --file="$install_dir/next.config.js" + if [ "$path" = "/" ]; then next_path="" else @@ -128,11 +131,17 @@ ynh_replace_string --match_string="href=\"/apple" --replace_string="href=\"$next ynh_replace_string --match_string="href=\"/manifest" --replace_string="href=\"$next_path/manifest" --target_file="$install_dir/components/CustomHead.tsx" +chown $app:www-data "$install_dir/public/manifest.json" +chown $app:www-data "$install_dir/next.config.js" +chmod 664 "$install_dir/public/manifest.json" +chmod 664 "$install_dir/next.config.js" + #================================================= # REBUILD AND INSTALL THE APP #================================================= ynh_script_progression --message="Rebuilding the app..." --weight=1 +ynh_use_nodejs ynh_exec_warn_less yarn --cwd "$install_dir" install ynh_exec_warn_less yarn --cwd "$install_dir" build