Skip to content

Commit

Permalink
improve: add more checks for agent script (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
uubulb authored Dec 2, 2024
1 parent e19a559 commit 8b13399
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions agent/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,23 @@ install() {
path=$(printf "%s" "$NZ_AGENT_PATH/config-$random.yml")
fi

if [ -z "$NZ_SERVER" ]; then
err "NZ_SERVER should not be empty"
exit 1
fi

if [ -z "$NZ_CLIENT_SECRET" ]; then
err "NZ_CLIENT_SECRET should not be empty"
exit 1
fi

env="NZ_SERVER=$NZ_SERVER NZ_CLIENT_SECRET=$NZ_CLIENT_SECRET NZ_TLS=$NZ_TLS NZ_DISABLE_AUTO_UPDATE=$NZ_DISABLE_AUTO_UPDATE NZ_DISABLE_FORCE_UPDATE=$DISABLE_FORCE_UPDATE NZ_DISABLE_COMMAND_EXECUTE=$NZ_DISABLE_COMMAND_EXECUTE NZ_SKIP_CONNECTION_COUNT=$NZ_SKIP_CONNECTION_COUNT"

sudo "${NZ_AGENT_PATH}"/nezha-agent service -c "$path" uninstall >/dev/null 2>&1
_cmd="sudo env $env $NZ_AGENT_PATH/nezha-agent service -c $path install"
if ! eval "$_cmd"; then
err "Install nezha-agent service failed"
sudo "${NZ_AGENT_PATH}"/nezha-agent service -c "$path" uninstall >/dev/null 2>&1
exit 1
fi

Expand Down

0 comments on commit 8b13399

Please sign in to comment.