Conversation
Update install.sh
Update uninstall.sh
WalkthroughTwo installer scripts were updated. install/install.sh now detects when actual_user differs from USER, prints English and Chinese diagnostics, force-exports USER, LOGNAME, HOME, and PWD to root values, and echoes commands related to Hydro startup and pm2 (resurrect, unstartup, startup) with bilingual guidance. install/uninstall.sh adds a root permission preflight check with bilingual messaging and exit, and includes the same environment remediation when actual_user differs from USER prior to the confirmation delay. Minor whitespace adjustments were made. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
install/install.sh(1 hunks)install/uninstall.sh(2 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
install/uninstall.sh
[warning] 9-9: This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.
(SC2320)
[warning] 26-26: actual_user is referenced but not assigned.
(SC2154)
| 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 $? |
There was a problem hiding this comment.
Return a failure code when root is required
After the informational echo calls, $? is 0, so exit $? reports success even though the script aborted. Please return a non-zero status (for example exit 1) so callers can detect the failure.
- exit $?
+ exit 1📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 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 $? | |
| 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 1 |
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 9-9: This $? refers to echo/printf, not a previous command. Assign to variable to avoid it being overwritten.
(SC2320)
🤖 Prompt for AI Agents
In install/uninstall.sh around lines 4 to 9, the script exits with "exit $?"
after printing the root-required messages which returns 0 (success); change that
to a non-zero exit (e.g., exit 1) so the script reports failure when not run as
root; simply replace "exit $?" with "exit 1" immediately after the echo lines.
| 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 |
There was a problem hiding this comment.
Define actual_user before using it
actual_user is never assigned, so the test on Line 26 always treats it as empty, entering this block and printing misleading messages while forcibly rewriting env vars. Add actual_user=$(whoami) (as in install.sh) before the comparison.
-read -p "> " confirm;
+read -p "> " confirm;
if [ "$confirm" != "Yes, do as I say!" ];then
echo "Aborted."
exit;
fi
+actual_user=$(whoami)
if [ "$actual_user" != "$USER" ]; then🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 26-26: actual_user is referenced but not assigned.
(SC2154)
🤖 Prompt for AI Agents
In install/uninstall.sh around lines 26 to 37, actual_user is never assigned so
the if-test always treats it as empty and the script unnecessarily overwrites
environment variables; fix it by assigning actual_user=$(whoami) (same as
install.sh) immediately before the comparison, then keep the existing if [
"$actual_user" != "$USER" ] conditional and its body unchanged so the check
behaves correctly and only runs when users differ.
| 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 可能不能正常自启动" |
There was a problem hiding this comment.
perhaps the wording should be optimized (?)
|
This is a 'script'. If you already know it will broke in some environment that you want to support, find out the most fundamental reason and fix it automatically instead of telling user what to do - likely they are going to ignore those messages. |
更加人性化的提示
对于 install.sh :添加了提示以及退路
环境:KVM 的 debian13,CPU为I7 9700(amd 64),不过网络为校园网(未备案的网站访问不了)
Lirzh.log
Summary by CodeRabbit
New Features
Bug Fixes
Style