diff options
| author | Yunheng Liu <121078488+Kookiejarz@users.noreply.github.com> | 2026-04-01 14:59:48 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-01 14:59:48 +0300 |
| commit | 169b216d7eba1641f46dd8ab4b64dfb8f0a5cc2f (patch) | |
| tree | 6c9a7558c2fb24453d1d5eadec2f3a6c1b96dffa /update.sh | |
| parent | 7e6d80efa5de0990fc701d75230a9505289f9de0 (diff) | |
perf: replace /dev/urandom | tr with openssl rand to fix CPU spike (#3887)
Diffstat (limited to 'update.sh')
| -rwxr-xr-x | update.sh | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -100,37 +100,38 @@ is_port_in_use() { gen_random_string() { local length="$1" - local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w "$length" | head -n 1) - echo "$random_string" + openssl rand -base64 $(( length * 2 )) \ + | tr -dc 'a-zA-Z0-9' \ + | head -c "$length" } install_base() { echo -e "${green}Updating and install dependency packages...${plain}" case "${release}" in ubuntu | debian | armbian) - apt-get update >/dev/null 2>&1 && apt-get install -y -q curl tar tzdata socat >/dev/null 2>&1 + apt-get update >/dev/null 2>&1 && apt-get install -y -q curl tar tzdata socat openssl >/dev/null 2>&1 ;; fedora | amzn | virtuozzo | rhel | almalinux | rocky | ol) - dnf -y update >/dev/null 2>&1 && dnf install -y -q curl tar tzdata socat >/dev/null 2>&1 + dnf -y update >/dev/null 2>&1 && dnf install -y -q curl tar tzdata socat openssl >/dev/null 2>&1 ;; centos) if [[ "${VERSION_ID}" =~ ^7 ]]; then - yum -y update >/dev/null 2>&1 && yum install -y -q curl tar tzdata socat >/dev/null 2>&1 + yum -y update >/dev/null 2>&1 && yum install -y -q curl tar tzdata socat openssl >/dev/null 2>&1 else - dnf -y update >/dev/null 2>&1 && dnf install -y -q curl tar tzdata socat >/dev/null 2>&1 + dnf -y update >/dev/null 2>&1 && dnf install -y -q curl tar tzdata socat openssl >/dev/null 2>&1 fi ;; arch | manjaro | parch) - pacman -Syu >/dev/null 2>&1 && pacman -Syu --noconfirm curl tar tzdata socat >/dev/null 2>&1 + pacman -Syu >/dev/null 2>&1 && pacman -Syu --noconfirm curl tar tzdata socat openssl >/dev/null 2>&1 ;; opensuse-tumbleweed | opensuse-leap) - zypper refresh >/dev/null 2>&1 && zypper -q install -y curl tar timezone socat >/dev/null 2>&1 + zypper refresh >/dev/null 2>&1 && zypper -q install -y curl tar timezone socat openssl >/dev/null 2>&1 ;; alpine) - apk update >/dev/null 2>&1 && apk add curl tar tzdata socat >/dev/null 2>&1 + apk update >/dev/null 2>&1 && apk add curl tar tzdata socat openssl>/dev/null 2>&1 ;; *) - apt-get update >/dev/null 2>&1 && apt install -y -q curl tar tzdata socat >/dev/null 2>&1 + apt-get update >/dev/null 2>&1 && apt install -y -q curl tar tzdata socat openssl >/dev/null 2>&1 ;; esac } |
