From 0ca24b71c98835e2b27ece59d1d2a0167c3c8ed9 Mon Sep 17 00:00:00 2001 From: Lirzh Date: Sat, 4 Oct 2025 09:15:30 +0800 Subject: [PATCH 1/4] Update install.sh --- install/install.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/install/install.sh b/install/install.sh index 3bf43aa18..46e0c6475 100644 --- a/install/install.sh +++ b/install/install.sh @@ -15,10 +15,23 @@ To disable this feature, checkout our sourcecode." # Sessions started with `su` will not have updated $USER, need to manually fix everything actual_user=$(whoami) if [ "$actual_user" != "$USER" ]; then +echo "In the current environment, the environment variable does not belong to the root, which will cause Hydro to fail to start up properly after the server restart" +echo "在目前环境下,环境变量并不属于 root,这会导致服务器重启后 Hydro 可能不能正常自启动" +echo "Try to fix it..." +echo "尝试修复..." export USER=root export LOGNAME=root export HOME=/root export PWD=/root +echo "This might work" +echo "这可能会奏效" +echo "If Hydro can not be properly self-started after server restart" +echo "如果服务器重启后 Hydro 不能正常自启动" +echo "Use the following code to fix it after reboot" +echo "在重启后使用下面的代码以修复" +echo "pm2 resurrect # 手动载入进程列表" +echo "pm2 unstartup # 清除原来的服务" +echo "pm2 startup systemd -u root # 以 root 身份创建服务" fi mkdir -p /data/db /data/file ~/.hydro bash <(curl https://hydro.ac/nix.sh) From 7f7867702f469f1a21abf70e703f436414cfd75f Mon Sep 17 00:00:00 2001 From: Lirzh Date: Sat, 4 Oct 2025 09:17:37 +0800 Subject: [PATCH 2/4] Update uninstall.sh --- install/uninstall.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/install/uninstall.sh b/install/uninstall.sh index 629732a5b..8dc9b1277 100644 --- a/install/uninstall.sh +++ b/install/uninstall.sh @@ -17,7 +17,18 @@ if [ "$confirm" != "Yes, do as I say!" ];then echo "Aborted." exit; fi - +if [ "$actual_user" != "$USER" ]; then +echo "In the current environment, the environmental variable does not belong to root, which can lead to failed uninstallation and strange errors" +echo "在目前环境下,环境变量并不属于 root,这会导致卸载失败以及奇怪的错误" +echo "Try to fix it..." +echo "尝试修复..." +export USER=root +export LOGNAME=root +export HOME=/root +export PWD=/root +echo "This might work" +echo "这可能会奏效" +fi echo "The script will run in 10 seconds. Press Ctrl+C to cancel." echo "脚本将在 10 秒后执行。按 Ctrl+C 取消。" sleep 10 From 9ee74482cfffdeddb2c43fd7db1df5f1c91841f9 Mon Sep 17 00:00:00 2001 From: Lirzh Date: Sat, 4 Oct 2025 09:26:09 +0800 Subject: [PATCH 3/4] Update uninstall.sh --- install/uninstall.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install/uninstall.sh b/install/uninstall.sh index 8dc9b1277..a1d898bca 100644 --- a/install/uninstall.sh +++ b/install/uninstall.sh @@ -9,7 +9,13 @@ Warning: You are warned. 警告: 此脚本会删除所有 pm2 托管的进程,并删除所有相关数据。 - +if [ $EUID != 0 ]; then + echo "This script requires root however you are currently running under another user." + echo "Please use 'sudo su' to switch to root user before running this script." + echo "卸载脚本需要使用 root 权限,请先使用 sudo su 切换到 root 用户后再运行此脚本。" + # sudo "$0" "$@" + exit $? +fi Type 'Yes, do as I say!' (without quotes) below to continue: 输入 'Yes, do as I say!' (不含引号) 继续:" read -p "> " confirm; From 5a555ee65493f6519f85111b0fae88bb8f22f723 Mon Sep 17 00:00:00 2001 From: Lirzh Date: Sat, 4 Oct 2025 09:53:03 +0800 Subject: [PATCH 4/4] Update uninstall.sh --- install/uninstall.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install/uninstall.sh b/install/uninstall.sh index a1d898bca..75c1a8089 100644 --- a/install/uninstall.sh +++ b/install/uninstall.sh @@ -1,6 +1,13 @@ #!/bin/bash clear +if [ $EUID != 0 ]; then + echo "This script requires root however you are currently running under another user." + echo "Please use 'sudo su' to switch to root user before running this script." + echo "卸载脚本需要使用 root 权限,请先使用 sudo su 切换到 root 用户后再运行此脚本。" + # sudo "$0" "$@" + exit $? +fi echo " Warning: This will also delete all process managed by pm2, @@ -9,13 +16,6 @@ Warning: You are warned. 警告: 此脚本会删除所有 pm2 托管的进程,并删除所有相关数据。 -if [ $EUID != 0 ]; then - echo "This script requires root however you are currently running under another user." - echo "Please use 'sudo su' to switch to root user before running this script." - echo "卸载脚本需要使用 root 权限,请先使用 sudo su 切换到 root 用户后再运行此脚本。" - # sudo "$0" "$@" - exit $? -fi Type 'Yes, do as I say!' (without quotes) below to continue: 输入 'Yes, do as I say!' (不含引号) 继续:" read -p "> " confirm;