feat(install-script): auto install OpenRC on Alpine Linux if needed
Some checks are pending
CodeQL / Analyze (go) (push) Waiting to run
CodeQL / Analyze (javascript-typescript) (push) Waiting to run

This commit is contained in:
Hintay 2025-05-08 05:07:46 +09:00
parent fd501a6d0c
commit d7baa4d0f6
No known key found for this signature in database
GPG key ID: 120FC7FF121F2F2D

View file

@ -171,18 +171,7 @@ identify_the_operating_system_and_architecture() {
echo -e "${FontRed}error: Don't use outdated Linux distributions.${FontSuffix}"
exit 1
fi
# Do not combine this judgment condition with the following judgment condition.
## Be aware of Linux distribution like Gentoo, which kernel supports switch between Systemd and OpenRC.
if [[ -f /.dockerenv ]] || grep -q 'docker\|lxc' /proc/1/cgroup && [[ "$(type -P systemctl)" ]]; then
SERVICE_TYPE='systemd'
elif [[ -d /run/systemd/system ]] || grep -q systemd <(ls -l /sbin/init); then
SERVICE_TYPE='systemd'
elif [[ "$(type -P rc-update)" ]]; then
SERVICE_TYPE='openrc'
else
SERVICE_TYPE='initd'
echo -e "${FontYellow}warning: No systemd or OpenRC detected, falling back to init.d.${FontSuffix}"
fi
if [[ "$(type -P apt)" ]]; then
PACKAGE_MANAGEMENT_INSTALL='apt -y --no-install-recommends install'
PACKAGE_MANAGEMENT_REMOVE='apt purge'
@ -208,6 +197,19 @@ identify_the_operating_system_and_architecture() {
echo -e "${FontRed}error: This script does not support the package manager in this operating system.${FontSuffix}"
exit 1
fi
# Do not combine this judgment condition with the following judgment condition.
## Be aware of Linux distribution like Gentoo, which kernel supports switch between Systemd and OpenRC.
if [[ -f /.dockerenv ]] || grep -q 'docker\|lxc' /proc/1/cgroup && [[ "$(type -P systemctl)" ]]; then
SERVICE_TYPE='systemd'
elif [[ -d /run/systemd/system ]] || grep -q systemd <(ls -l /sbin/init); then
SERVICE_TYPE='systemd'
elif [[ "$(type -P rc-update)" ]] || [[ "$(type -P apk)" ]]; then
SERVICE_TYPE='openrc'
else
SERVICE_TYPE='initd'
echo -e "${FontYellow}warning: No systemd or OpenRC detected, falling back to init.d.${FontSuffix}"
fi
else
echo -e "${FontRed}error: This operating system is not supported by this script.${FontSuffix}"
exit 1
@ -560,6 +562,10 @@ main() {
TMP_DIRECTORY="$(mktemp -d)"
TAR_FILE="${TMP_DIRECTORY}/nginx-ui-linux-$MACHINE.tar.gz"
# Auto install OpenRC on Alpine Linux if needed
if [[ "$(type -P apk)" ]]; then
install_software 'openrc' 'openrc'
fi
install_software 'curl' 'curl'
# Install from a local file