Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 19 additions & 2 deletions install/uninstall.sh
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -9,15 +16,25 @@ Warning:
You are warned.
警告:
此脚本会删除所有 pm2 托管的进程,并删除所有相关数据。

Type 'Yes, do as I say!' (without quotes) below to continue:
输入 'Yes, do as I say!' (不含引号) 继续:"
read -p "> " confirm;
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
Expand Down