updated from server
This commit is contained in:
255
root/parallels/pool/PSA_18.0.73_17971/examiners/check_broken_timezone.sh
Executable file
255
root/parallels/pool/PSA_18.0.73_17971/examiners/check_broken_timezone.sh
Executable file
@@ -0,0 +1,255 @@
|
||||
#!/bin/bash
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
[ -z "$PLESK_INSTALLER_DEBUG" ] || set -x
|
||||
[ -z "$PLESK_INSTALLER_STRICT_MODE" ] || set -e
|
||||
|
||||
export LC_ALL=C
|
||||
unset GREP_OPTIONS
|
||||
|
||||
RET_SUCCESS=0
|
||||
RET_WARN=1
|
||||
RET_FATAL=2
|
||||
|
||||
is_function_defined()
|
||||
{
|
||||
local fn="$1"
|
||||
case "$(type $fn 2>/dev/null)" in
|
||||
*function*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# @params are tags in format "key=value"
|
||||
# Report body (human readable information) is read from stdin
|
||||
# and copied to stderr.
|
||||
make_error_report()
|
||||
{
|
||||
local report_file="${PLESK_INSTALLER_ERROR_REPORT:-}"
|
||||
|
||||
local python_bin=
|
||||
for bin in "/opt/psa/bin/python" "/usr/local/psa/bin/python" "/usr/bin/python2" "/opt/psa/bin/py3-python" "/usr/local/psa/bin/py3-python" "/usr/libexec/platform-python" "/usr/bin/python3"; do
|
||||
if [ -x "$bin" ]; then
|
||||
python_bin="$bin"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$report_file" -a -x "$python_bin" ]; then
|
||||
"$python_bin" -c 'import sys, json
|
||||
report_file = sys.argv[1]
|
||||
error = sys.stdin.read()
|
||||
|
||||
sys.stderr.write(error)
|
||||
|
||||
data = {
|
||||
"error": error,
|
||||
}
|
||||
|
||||
for tag in sys.argv[2:]:
|
||||
k, v = tag.split("=", 1)
|
||||
data[k] = v
|
||||
|
||||
with open(report_file, "a") as f:
|
||||
json.dump(data, f)
|
||||
f.write("\n")
|
||||
' "$report_file" "date=$(date --utc --iso-8601=ns)" "$@"
|
||||
else
|
||||
cat - >&2
|
||||
fi
|
||||
}
|
||||
|
||||
detect_platform()
|
||||
{
|
||||
. /etc/os-release
|
||||
os_name="$ID"
|
||||
os_version="${VERSION_ID%%.*}"
|
||||
os_arch="$(uname -m)"
|
||||
if [ -e /etc/debian_version ]; then
|
||||
case "$os_arch" in
|
||||
x86_64) pkg_arch="amd64" ;;
|
||||
aarch64) pkg_arch="arm64" ;;
|
||||
esac
|
||||
if [ -n "$VERSION_CODENAME" ]; then
|
||||
os_codename="$VERSION_CODENAME"
|
||||
else
|
||||
case "$os_name$os_version" in
|
||||
debian10) os_codename="buster" ;;
|
||||
debian11) os_codename="bullseye" ;;
|
||||
debian12) os_codename="bookworm" ;;
|
||||
ubuntu18) os_codename="bionic" ;;
|
||||
ubuntu20) os_codename="focal" ;;
|
||||
ubuntu22) os_codename="jammy" ;;
|
||||
ubuntu24) os_codename="noble" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$os_name$os_version" in
|
||||
rhel7|centos7|cloudlinux7|virtuozzo7)
|
||||
package_manager="yum"
|
||||
;;
|
||||
rhel*|centos*|cloudlinux*|almalinux*|rocky*)
|
||||
package_manager="dnf"
|
||||
;;
|
||||
debian*|ubuntu*)
|
||||
package_manager="apt"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$os_name" = "ubuntu" -o "$os_name" = "debian" ]; then
|
||||
PRODUCT_ROOT_D="/opt/psa"
|
||||
else
|
||||
PRODUCT_ROOT_D="/usr/local/psa"
|
||||
fi
|
||||
}
|
||||
|
||||
has_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
is_function_defined "$fn"
|
||||
}
|
||||
|
||||
call_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
shift
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
"$fn" "$@"
|
||||
}
|
||||
|
||||
skip_checker_on_flag()
|
||||
{
|
||||
local name="$1"
|
||||
local flag="$2"
|
||||
|
||||
if [ -f "$flag" ]; then
|
||||
echo "$name was skipped due to flag file." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
skip_checker_on_env()
|
||||
{
|
||||
local name="$1"
|
||||
local env="$2"
|
||||
|
||||
if [ -n "$env" ]; then
|
||||
echo "$name was skipped due to environment variable." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
checker_main()
|
||||
{
|
||||
local fnprefix="$1"
|
||||
shift
|
||||
|
||||
detect_platform
|
||||
# try to execute checker only if all attributes are detected
|
||||
[ -n "$os_name" -a -n "$os_version" ] || return $RET_SUCCESS
|
||||
|
||||
for checker in "${fnprefix}_${os_name}${os_version}" "${fnprefix}_${os_name}" "${fnprefix}"; do
|
||||
if is_function_defined "$checker"; then
|
||||
local rc=$RET_SUCCESS
|
||||
"$checker" "$@" || rc=$?
|
||||
[ "$(( $rc & $RET_FATAL ))" = "0" ] || return $RET_FATAL
|
||||
[ "$(( $rc & $RET_WARN ))" = "0" ] || return $RET_WARN
|
||||
return $rc
|
||||
fi
|
||||
done
|
||||
return $RET_SUCCESS
|
||||
}
|
||||
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
# If env variable PLESK_INSTALLER_ERROR_REPORT=path_to_file is specified then in case of error
|
||||
# check-broken-tz.sh writes single line json report into it with the following fields:
|
||||
# - "stage": "timezonefix"
|
||||
# - "level": "error"
|
||||
# - "errtype": "failure"
|
||||
# - "date": time of error occurance ("2024-07-24T06:59:43,127545441+0000")
|
||||
# - "error": human readable error message
|
||||
|
||||
report_dpkg_configure_fail()
|
||||
{
|
||||
local pkgname="$1"
|
||||
make_error_report 'stage=timezonefix' 'level=error' 'errtype=dpkgconfigurefailed' <<-EOL
|
||||
Could not configure the packages ( $pkgname ). See https://support.plesk.com/hc/en-us/articles/24721507961623-Plesk-provides-error-on-update-Package-tzdata-is-not-configured-yet for more details.
|
||||
EOL
|
||||
}
|
||||
|
||||
report_get_tz_fail()
|
||||
{
|
||||
make_error_report 'stage=timezonefix' 'level=error' 'errtype=gettzfailed' <<-EOL
|
||||
Could not get the system timezone. See https://support.plesk.com/hc/en-us/articles/24721507961623-Plesk-provides-error-on-update-Package-tzdata-is-not-configured-yet for more details.
|
||||
EOL
|
||||
}
|
||||
|
||||
report_set_tz_fail()
|
||||
{
|
||||
local tz="$1"
|
||||
|
||||
make_error_report 'stage=timezonefix' 'level=error' 'errtype=settzfailed' <<-EOL
|
||||
Could not set the system timezone ( $tz ). See https://support.plesk.com/hc/en-us/articles/24721507961623-Plesk-provides-error-on-update-Package-tzdata-is-not-configured-yet for more details.
|
||||
EOL
|
||||
}
|
||||
|
||||
get_current_tz()
|
||||
{
|
||||
[ -L /etc/localtime ] || return 1
|
||||
|
||||
local tz
|
||||
tz="$(readlink -m /etc/localtime)" || return 1
|
||||
[ -f "$tz" ] || return 1
|
||||
case "$tz" in
|
||||
/usr/share/zoneinfo/*) ;;
|
||||
*) return 1;;
|
||||
esac
|
||||
tz="${tz#/usr/share/zoneinfo/}"
|
||||
[ -n "$tz" ] || return 1
|
||||
|
||||
echo -n "${tz}"
|
||||
}
|
||||
|
||||
check_timezone_ubuntu()
|
||||
{
|
||||
[ -n "$os_codename" ] || return 0
|
||||
local mode="$1"
|
||||
|
||||
# PPP-65676: Plesk update fails on ubuntu if timezone is CET
|
||||
if dpkg-query --showformat='${db:Status-Status}\n' --show 'tzdata' | grep -wq 'half-configured'; then
|
||||
local origtz
|
||||
origtz=$(get_current_tz)
|
||||
if [ $? != 0 ]; then
|
||||
report_get_tz_fail
|
||||
return $RET_WARN
|
||||
fi
|
||||
if ! timedatectl set-timezone 'Etc/UTC'; then
|
||||
timedatectl set-timezone "$origtz"
|
||||
report_set_tz_fail 'Etc/UTC'
|
||||
return $RET_WARN
|
||||
fi
|
||||
if ! dpkg --configure 'tzdata'; then
|
||||
timedatectl set-timezone "$origtz"
|
||||
report_dpkg_configure_fail 'tzdata'
|
||||
return $RET_WARN
|
||||
fi
|
||||
if ! timedatectl set-timezone "$origtz"; then
|
||||
report_set_tz_fail "$origtz"
|
||||
return $RET_WARN
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
skip_checker_on_flag "Broken timezone check" "/tmp/plesk-installer-skip-check-broken-timezone.flag"
|
||||
|
||||
checker_main 'check_timezone' "$1"
|
||||
542
root/parallels/pool/PSA_18.0.73_17971/examiners/disk_space_check.sh
Executable file
542
root/parallels/pool/PSA_18.0.73_17971/examiners/disk_space_check.sh
Executable file
@@ -0,0 +1,542 @@
|
||||
#!/bin/bash
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
[ -z "$PLESK_INSTALLER_DEBUG" ] || set -x
|
||||
[ -z "$PLESK_INSTALLER_STRICT_MODE" ] || set -e
|
||||
|
||||
export LC_ALL=C
|
||||
unset GREP_OPTIONS
|
||||
|
||||
RET_SUCCESS=0
|
||||
RET_WARN=1
|
||||
RET_FATAL=2
|
||||
|
||||
is_function_defined()
|
||||
{
|
||||
local fn="$1"
|
||||
case "$(type $fn 2>/dev/null)" in
|
||||
*function*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# @params are tags in format "key=value"
|
||||
# Report body (human readable information) is read from stdin
|
||||
# and copied to stderr.
|
||||
make_error_report()
|
||||
{
|
||||
local report_file="${PLESK_INSTALLER_ERROR_REPORT:-}"
|
||||
|
||||
local python_bin=
|
||||
for bin in "/opt/psa/bin/python" "/usr/local/psa/bin/python" "/usr/bin/python2" "/opt/psa/bin/py3-python" "/usr/local/psa/bin/py3-python" "/usr/libexec/platform-python" "/usr/bin/python3"; do
|
||||
if [ -x "$bin" ]; then
|
||||
python_bin="$bin"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$report_file" -a -x "$python_bin" ]; then
|
||||
"$python_bin" -c 'import sys, json
|
||||
report_file = sys.argv[1]
|
||||
error = sys.stdin.read()
|
||||
|
||||
sys.stderr.write(error)
|
||||
|
||||
data = {
|
||||
"error": error,
|
||||
}
|
||||
|
||||
for tag in sys.argv[2:]:
|
||||
k, v = tag.split("=", 1)
|
||||
data[k] = v
|
||||
|
||||
with open(report_file, "a") as f:
|
||||
json.dump(data, f)
|
||||
f.write("\n")
|
||||
' "$report_file" "date=$(date --utc --iso-8601=ns)" "$@"
|
||||
else
|
||||
cat - >&2
|
||||
fi
|
||||
}
|
||||
|
||||
detect_platform()
|
||||
{
|
||||
. /etc/os-release
|
||||
os_name="$ID"
|
||||
os_version="${VERSION_ID%%.*}"
|
||||
os_arch="$(uname -m)"
|
||||
if [ -e /etc/debian_version ]; then
|
||||
case "$os_arch" in
|
||||
x86_64) pkg_arch="amd64" ;;
|
||||
aarch64) pkg_arch="arm64" ;;
|
||||
esac
|
||||
if [ -n "$VERSION_CODENAME" ]; then
|
||||
os_codename="$VERSION_CODENAME"
|
||||
else
|
||||
case "$os_name$os_version" in
|
||||
debian10) os_codename="buster" ;;
|
||||
debian11) os_codename="bullseye" ;;
|
||||
debian12) os_codename="bookworm" ;;
|
||||
ubuntu18) os_codename="bionic" ;;
|
||||
ubuntu20) os_codename="focal" ;;
|
||||
ubuntu22) os_codename="jammy" ;;
|
||||
ubuntu24) os_codename="noble" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$os_name$os_version" in
|
||||
rhel7|centos7|cloudlinux7|virtuozzo7)
|
||||
package_manager="yum"
|
||||
;;
|
||||
rhel*|centos*|cloudlinux*|almalinux*|rocky*)
|
||||
package_manager="dnf"
|
||||
;;
|
||||
debian*|ubuntu*)
|
||||
package_manager="apt"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$os_name" = "ubuntu" -o "$os_name" = "debian" ]; then
|
||||
PRODUCT_ROOT_D="/opt/psa"
|
||||
else
|
||||
PRODUCT_ROOT_D="/usr/local/psa"
|
||||
fi
|
||||
}
|
||||
|
||||
has_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
is_function_defined "$fn"
|
||||
}
|
||||
|
||||
call_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
shift
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
"$fn" "$@"
|
||||
}
|
||||
|
||||
skip_checker_on_flag()
|
||||
{
|
||||
local name="$1"
|
||||
local flag="$2"
|
||||
|
||||
if [ -f "$flag" ]; then
|
||||
echo "$name was skipped due to flag file." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
skip_checker_on_env()
|
||||
{
|
||||
local name="$1"
|
||||
local env="$2"
|
||||
|
||||
if [ -n "$env" ]; then
|
||||
echo "$name was skipped due to environment variable." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
checker_main()
|
||||
{
|
||||
local fnprefix="$1"
|
||||
shift
|
||||
|
||||
detect_platform
|
||||
# try to execute checker only if all attributes are detected
|
||||
[ -n "$os_name" -a -n "$os_version" ] || return $RET_SUCCESS
|
||||
|
||||
for checker in "${fnprefix}_${os_name}${os_version}" "${fnprefix}_${os_name}" "${fnprefix}"; do
|
||||
if is_function_defined "$checker"; then
|
||||
local rc=$RET_SUCCESS
|
||||
"$checker" "$@" || rc=$?
|
||||
[ "$(( $rc & $RET_FATAL ))" = "0" ] || return $RET_FATAL
|
||||
[ "$(( $rc & $RET_WARN ))" = "0" ] || return $RET_WARN
|
||||
return $rc
|
||||
fi
|
||||
done
|
||||
return $RET_SUCCESS
|
||||
}
|
||||
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
# If env variable PLESK_INSTALLER_ERROR_REPORT=path_to_file is specified then in case of error
|
||||
# disk_space_check.sh writes single line json report into it with the following fields:
|
||||
# - "stage": "diskspacecheck"
|
||||
# - "level": "error"
|
||||
# - "errtype": "notenoughdiskspace"
|
||||
# - "volume": volume with not enough diskspace (e.g. "/")
|
||||
# - "required": required diskspace on the volume, human readable (e.g. "600 MB")
|
||||
# - "available": available diskspace on the volume, human readable (e.g. "255 MB")
|
||||
# - "needtofree": amount of diskspace which should be freed on the volume, human readable (e.g. "345 MB")
|
||||
# - "date": time of error occurance ("2020-03-24T06:59:43,127545441+0000")
|
||||
# - "error": human readable error message ("There is not enough disk space available in the / directory.")
|
||||
|
||||
# Required values below for Full installation are in MB. See 'du -cs -BM /*' and 'df -Pm'.
|
||||
|
||||
required_disk_space_cloudlinux7()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 900 ;;
|
||||
/usr) echo 4400 ;;
|
||||
/var) echo 600 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_cloudlinux8()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 1200 ;;
|
||||
/usr) echo 4400 ;;
|
||||
/var) echo 700 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_centos7()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 900 ;;
|
||||
/usr) echo 4100 ;;
|
||||
/var) echo 600 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_centos8()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 900 ;;
|
||||
/usr) echo 4500 ;;
|
||||
/var) echo 800 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_virtuozzo7()
|
||||
{
|
||||
required_disk_space_centos7 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_rhel7()
|
||||
{
|
||||
required_disk_space_centos7 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_rhel8()
|
||||
{
|
||||
required_disk_space_centos8 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_almalinux8()
|
||||
{
|
||||
required_disk_space_centos8 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_rocky8()
|
||||
{
|
||||
required_disk_space_centos8 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_rhel9()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 500 ;;
|
||||
/usr) echo 4000 ;;
|
||||
/var) echo 800 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_almalinux9()
|
||||
{
|
||||
required_disk_space_rhel9 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_almalinux10()
|
||||
{
|
||||
required_disk_space_almalinux9 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_cloudlinux9()
|
||||
{
|
||||
required_disk_space_rhel9 "$1"
|
||||
}
|
||||
|
||||
required_disk_space_debian10()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 1800 ;;
|
||||
/usr) echo 2300 ;;
|
||||
/var) echo 1700 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_debian11()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 1500 ;;
|
||||
/usr) echo 3100 ;;
|
||||
/var) echo 1800 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_debian12()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 2700 ;;
|
||||
/usr) echo 2500 ;;
|
||||
/var) echo 2200 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_debian13()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 2700 ;;
|
||||
/usr) echo 2500 ;;
|
||||
/var) echo 2200 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_ubuntu18()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 900 ;;
|
||||
/usr) echo 1800 ;;
|
||||
/var) echo 600 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_ubuntu20()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 1800 ;;
|
||||
/usr) echo 2900 ;;
|
||||
/var) echo 1600 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_ubuntu22()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 1800 ;;
|
||||
/usr) echo 3900 ;;
|
||||
/var) echo 1900 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_disk_space_ubuntu24()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 3200 ;;
|
||||
/usr) echo 1800 ;;
|
||||
/var) echo 2400 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
required_update_upgrade_disk_space()
|
||||
{
|
||||
case "$1" in
|
||||
/opt) echo 100 ;;
|
||||
/usr) echo 300 ;;
|
||||
/var) echo 600 ;;
|
||||
/tmp) echo 100 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
clean_tmp()
|
||||
{
|
||||
local volume="$1"
|
||||
local path="/tmp"
|
||||
is_path_on_volume "$path" "$volume" || return 0
|
||||
|
||||
echo "Cleaning $path via 'systemd-tmpfiles --clean --prefix $path'"
|
||||
systemd-tmpfiles --clean --prefix "$path" 2>&1
|
||||
}
|
||||
|
||||
clean_yum()
|
||||
{
|
||||
local volume="$1"
|
||||
local path="/var/cache/yum"
|
||||
is_path_on_volume "$path" "$volume" || return 0
|
||||
|
||||
echo "Cleaning $path via 'yum clean all'"
|
||||
yum clean all 2>&1
|
||||
|
||||
# The command above doesn't clean untracked repos (missing in configuration), clean if left > 2 Mb
|
||||
[ "`du -sm "$path" | awk '{ print $1 }'`" -gt 2 ] || return 0
|
||||
echo "Cleaning $path via 'rm -rf $path/*'"
|
||||
rm -rf "$path"/* 2>&1
|
||||
}
|
||||
|
||||
clean_dnf()
|
||||
{
|
||||
local volume="$1"
|
||||
local path="/var/cache/dnf"
|
||||
is_path_on_volume "$path" "$volume" || return 0
|
||||
|
||||
echo "Cleaning $path via 'dnf clean all'"
|
||||
dnf clean all 2>&1
|
||||
}
|
||||
|
||||
clean_apt()
|
||||
{
|
||||
local volume="$1"
|
||||
local path="/var/cache/apt"
|
||||
is_path_on_volume "$path" "$volume" || return 0
|
||||
|
||||
echo "Cleaning $path via 'apt-get clean'"
|
||||
apt-get clean 2>&1
|
||||
}
|
||||
|
||||
clean_journal()
|
||||
{
|
||||
local volume="$1"
|
||||
local path="/var/log/journal"
|
||||
is_path_on_volume "$path" "$volume" || return 0
|
||||
|
||||
# Note that --rotate may cause more space to be freed, but may also cause more space to be used
|
||||
echo "Cleaning $path via 'journalctl --vacuum-time 1d'"
|
||||
journalctl --vacuum-time 1d 2>&1
|
||||
}
|
||||
|
||||
clean_ext_packages()
|
||||
{
|
||||
local volume="$1"
|
||||
local path="$PRODUCT_ROOT_D/var/modules-packages"
|
||||
is_path_on_volume "$path" "$volume" || return 0
|
||||
|
||||
echo "Cleaning $path via 'rm -rf $path/*'"
|
||||
rm -rf "$path"/* 2>&1
|
||||
}
|
||||
|
||||
# @param $1 target directory
|
||||
mount_point()
|
||||
{
|
||||
df -Pm $1 | awk 'NR==2 { print $6 }'
|
||||
}
|
||||
|
||||
# @param $1 target directory
|
||||
available_disk_space()
|
||||
{
|
||||
df -Pm $1 | awk 'NR==2 { print $4 }'
|
||||
}
|
||||
|
||||
is_path_on_volume()
|
||||
{
|
||||
local path="$1"
|
||||
local volume="$2"
|
||||
[ -d "$path" ] && [ "`mount_point "$path"`" = "$volume" ]
|
||||
}
|
||||
|
||||
# @param $1 target directory
|
||||
# @param $2 mode (install/upgrade/update)
|
||||
req_disk_space()
|
||||
{
|
||||
if [ "$2" != "install" ]; then
|
||||
required_update_upgrade_disk_space "$1"
|
||||
return
|
||||
fi
|
||||
|
||||
has_os_impl_function "required_disk_space" || {
|
||||
echo "There are no requirements defined for $os_name$os_version." >&2
|
||||
echo "Disk space check cannot be performed." >&2
|
||||
exit $RET_WARN
|
||||
}
|
||||
call_os_impl_function "required_disk_space" "$1"
|
||||
}
|
||||
|
||||
human_readable_size()
|
||||
{
|
||||
echo "$1" | awk '
|
||||
function human(x) {
|
||||
s = "MGTEPYZ";
|
||||
while (x >= 1000 && length(s) > 1) {
|
||||
x /= 1024; s = substr(s, 2);
|
||||
}
|
||||
# 0.05 below will make sure the value is rounded up
|
||||
return sprintf("%.1f %sB", x + 0.05, substr(s, 1, 1));
|
||||
}
|
||||
{ print human($1); }'
|
||||
}
|
||||
|
||||
# @param $1 target directory
|
||||
# @param $2 required disk space
|
||||
# @param $3 check only flag (don't emit errors)
|
||||
check_available_disk_space()
|
||||
{
|
||||
local volume="$1"
|
||||
local required="$2"
|
||||
local check_only="${3:-}"
|
||||
local available="$(available_disk_space "$volume")"
|
||||
if [ "$available" -lt "$required" ]; then
|
||||
local needtofree
|
||||
needtofree="`human_readable_size $((required - available))`"
|
||||
[ -n "$check_only" ] ||
|
||||
make_error_report 'stage=diskspacecheck' 'level=error' 'errtype=notenoughdiskspace' \
|
||||
"volume=$volume" "required=$required MB" "available=$available MB" "needtofree=$needtofree" \
|
||||
<<-EOL
|
||||
There is not enough disk space available in the $1 directory.
|
||||
You need to free up $needtofree.
|
||||
EOL
|
||||
return "$RET_FATAL"
|
||||
fi
|
||||
}
|
||||
|
||||
# @param $1 target directory
|
||||
# @param $2 required disk space
|
||||
clean_and_check_available_disk_space()
|
||||
{
|
||||
if [ -n "$PLESK_INSTALLER_FORCE_CLEAN_DISK_SPACE" ] || ! check_available_disk_space "$@" --check-only; then
|
||||
clean_disk_space "$1"
|
||||
check_available_disk_space "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Cleans up disk space on the volume
|
||||
clean_disk_space()
|
||||
{
|
||||
local volume="$1"
|
||||
for cleanup_func in clean_tmp clean_yum clean_dnf clean_apt clean_journal clean_ext_packages; do
|
||||
"$cleanup_func" "$volume"
|
||||
done
|
||||
}
|
||||
|
||||
# @param $1 mode (install/upgrade/update)
|
||||
clean_and_check_disk_space()
|
||||
{
|
||||
local mode="$1"
|
||||
local shared=0
|
||||
|
||||
for target_directory in /opt /usr /var /tmp; do
|
||||
local required=$(req_disk_space "$target_directory" "$mode")
|
||||
[ -n "$required" ] || return "$RET_WARN"
|
||||
|
||||
if is_path_on_volume "$target_directory" "/"; then
|
||||
shared="$((shared + required))"
|
||||
else
|
||||
clean_and_check_available_disk_space "$target_directory" "$required" || return $?
|
||||
fi
|
||||
done
|
||||
|
||||
clean_and_check_available_disk_space "/" "$shared" || return $?
|
||||
}
|
||||
|
||||
checker_main 'clean_and_check_disk_space' "$1"
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
// vim: set et :
|
||||
|
||||
require_once('sdk.php');
|
||||
|
||||
define('TARGET_VERSION', '18.0.73');
|
||||
|
||||
define('RESULT_NETWORK_PROBLEM', 1);
|
||||
define('RESULT_ERROR', 2);
|
||||
define('RESULT_LICENSE_PROBLEM', 3);
|
||||
define('RESULT_LICENSE_OK', 4);
|
||||
|
||||
function finish($rc, $sure = true)
|
||||
{
|
||||
if ($rc !== 0) {
|
||||
fwrite(STDERR, "\n");
|
||||
if ($sure) {
|
||||
fwrite(STDERR, "Your license key is not compatible with Plesk Obsidian.\n");
|
||||
} else {
|
||||
fwrite(STDERR, "Your license key may not be compatible with Plesk Obsidian.\n");
|
||||
}
|
||||
fwrite(STDERR, "You need to upgrade your license before updating Plesk.\n");
|
||||
fwrite(STDERR, "For details, refer to the KB https://support.plesk.com/hc/en-us/articles/360023612594\n");
|
||||
}
|
||||
exit($rc);
|
||||
}
|
||||
|
||||
|
||||
$skipFlag = PRODUCT_VAR . DIRECTORY_SEPARATOR . "plesk-installer-skip-license-key-check.flag";
|
||||
if (file_exists($skipFlag)) {
|
||||
fwrite(STDERR, "Plesk license key upgrade availability check was skipped due to a flag file.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!function_exists('of_get_key_by_product') || !function_exists('of_get_versions')) {
|
||||
fwrite(STDERR, "Plesk license key upgrade availability check should be run on sw-engine only.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
foreach (["plesk-unified", "plesk-unix", "plesk-win"] as $prod) {
|
||||
$key = of_get_key_by_product($prod);
|
||||
if ($key !== false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($key === false) {
|
||||
fwrite(STDERR, "No Plesk license key was found. License upgrade check is skipped.\n");
|
||||
finish(0);
|
||||
}
|
||||
|
||||
$targetVersion = TARGET_VERSION;
|
||||
$vers = of_get_versions($key); /* plesk >= 10.0.0 */
|
||||
if (!is_array($vers)) {
|
||||
$vers = [$vers];
|
||||
}
|
||||
|
||||
$match = false;
|
||||
foreach ($vers as $ver) {
|
||||
if (!is_array($ver)) {
|
||||
$match |= strtok($ver, ".") == strtok($targetVersion, ".");
|
||||
} else {
|
||||
$match |= ("any" == $ver[0] || version_compare($ver[0], $targetVersion) <= 0) &&
|
||||
("any" == $ver[1] || version_compare($ver[1], $targetVersion) >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
fwrite(STDERR, "You do not need to upgrade the current license key.\n");
|
||||
fwrite(STDOUT, "License upgrade check to $targetVersion can be skipped.\n");
|
||||
fwrite(STDOUT, "Plesk versions compatible with the license key: " . preg_replace('/\n\s*/', '', var_export($vers, true)) . "\n");
|
||||
finish(0);
|
||||
}
|
||||
|
||||
if (!function_exists('ka_is_key_upgrade_available')) {
|
||||
// Plesk 17.0
|
||||
fwrite(STDERR, "Cannot check whether Plesk license key upgrade is available.\n");
|
||||
finish(1, false);
|
||||
}
|
||||
|
||||
$si = getServerInfo();
|
||||
$result = ka_is_key_upgrade_available($prod, $targetVersion, $si);
|
||||
|
||||
$isConfused = false;
|
||||
switch ($result['code']) {
|
||||
case RESULT_LICENSE_OK:
|
||||
fwrite(STDERR, "The licensing server accepted the key upgrade request.\n");
|
||||
fwrite(STDERR, "License upgrade to $targetVersion is available.\n");
|
||||
fwrite(STDERR, "Response from the licensing server: {$result['message']}\n");
|
||||
finish(0);
|
||||
case RESULT_NETWORK_PROBLEM:
|
||||
fwrite(STDERR, "Unable to connect to the licensing server to check if license upgrade is available.\n");
|
||||
fwrite(STDERR, "Error message: {$result['message']}\n");
|
||||
finish(2, false);
|
||||
case RESULT_LICENSE_PROBLEM:
|
||||
fwrite(STDERR, "Warning: Your Plesk license key cannot be upgraded.\n");
|
||||
fwrite(STDERR, "Response from the licensing server: {$result['message']}\n");
|
||||
finish(2);
|
||||
default:
|
||||
$isConfused = true;
|
||||
// fall-through
|
||||
case RESULT_ERROR:
|
||||
// This includes "Software Update Service (SUS) is not found for the given license key" case, but also many others.
|
||||
fwrite(STDERR, "Failed to check whether a new license key is available.\n");
|
||||
fwrite(STDERR, "Error message: {$result['message']}\n");
|
||||
if ($isConfused) {
|
||||
fwrite(STDERR, "Error code: {$result['code']}\n");
|
||||
}
|
||||
finish(2, !$isConfused);
|
||||
}
|
||||
224
root/parallels/pool/PSA_18.0.73_17971/examiners/package_manager_check.sh
Executable file
224
root/parallels/pool/PSA_18.0.73_17971/examiners/package_manager_check.sh
Executable file
@@ -0,0 +1,224 @@
|
||||
#!/bin/bash
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
[ -z "$PLESK_INSTALLER_DEBUG" ] || set -x
|
||||
[ -z "$PLESK_INSTALLER_STRICT_MODE" ] || set -e
|
||||
|
||||
export LC_ALL=C
|
||||
unset GREP_OPTIONS
|
||||
|
||||
RET_SUCCESS=0
|
||||
RET_WARN=1
|
||||
RET_FATAL=2
|
||||
|
||||
is_function_defined()
|
||||
{
|
||||
local fn="$1"
|
||||
case "$(type $fn 2>/dev/null)" in
|
||||
*function*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# @params are tags in format "key=value"
|
||||
# Report body (human readable information) is read from stdin
|
||||
# and copied to stderr.
|
||||
make_error_report()
|
||||
{
|
||||
local report_file="${PLESK_INSTALLER_ERROR_REPORT:-}"
|
||||
|
||||
local python_bin=
|
||||
for bin in "/opt/psa/bin/python" "/usr/local/psa/bin/python" "/usr/bin/python2" "/opt/psa/bin/py3-python" "/usr/local/psa/bin/py3-python" "/usr/libexec/platform-python" "/usr/bin/python3"; do
|
||||
if [ -x "$bin" ]; then
|
||||
python_bin="$bin"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$report_file" -a -x "$python_bin" ]; then
|
||||
"$python_bin" -c 'import sys, json
|
||||
report_file = sys.argv[1]
|
||||
error = sys.stdin.read()
|
||||
|
||||
sys.stderr.write(error)
|
||||
|
||||
data = {
|
||||
"error": error,
|
||||
}
|
||||
|
||||
for tag in sys.argv[2:]:
|
||||
k, v = tag.split("=", 1)
|
||||
data[k] = v
|
||||
|
||||
with open(report_file, "a") as f:
|
||||
json.dump(data, f)
|
||||
f.write("\n")
|
||||
' "$report_file" "date=$(date --utc --iso-8601=ns)" "$@"
|
||||
else
|
||||
cat - >&2
|
||||
fi
|
||||
}
|
||||
|
||||
detect_platform()
|
||||
{
|
||||
. /etc/os-release
|
||||
os_name="$ID"
|
||||
os_version="${VERSION_ID%%.*}"
|
||||
os_arch="$(uname -m)"
|
||||
if [ -e /etc/debian_version ]; then
|
||||
case "$os_arch" in
|
||||
x86_64) pkg_arch="amd64" ;;
|
||||
aarch64) pkg_arch="arm64" ;;
|
||||
esac
|
||||
if [ -n "$VERSION_CODENAME" ]; then
|
||||
os_codename="$VERSION_CODENAME"
|
||||
else
|
||||
case "$os_name$os_version" in
|
||||
debian10) os_codename="buster" ;;
|
||||
debian11) os_codename="bullseye" ;;
|
||||
debian12) os_codename="bookworm" ;;
|
||||
ubuntu18) os_codename="bionic" ;;
|
||||
ubuntu20) os_codename="focal" ;;
|
||||
ubuntu22) os_codename="jammy" ;;
|
||||
ubuntu24) os_codename="noble" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$os_name$os_version" in
|
||||
rhel7|centos7|cloudlinux7|virtuozzo7)
|
||||
package_manager="yum"
|
||||
;;
|
||||
rhel*|centos*|cloudlinux*|almalinux*|rocky*)
|
||||
package_manager="dnf"
|
||||
;;
|
||||
debian*|ubuntu*)
|
||||
package_manager="apt"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$os_name" = "ubuntu" -o "$os_name" = "debian" ]; then
|
||||
PRODUCT_ROOT_D="/opt/psa"
|
||||
else
|
||||
PRODUCT_ROOT_D="/usr/local/psa"
|
||||
fi
|
||||
}
|
||||
|
||||
has_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
is_function_defined "$fn"
|
||||
}
|
||||
|
||||
call_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
shift
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
"$fn" "$@"
|
||||
}
|
||||
|
||||
skip_checker_on_flag()
|
||||
{
|
||||
local name="$1"
|
||||
local flag="$2"
|
||||
|
||||
if [ -f "$flag" ]; then
|
||||
echo "$name was skipped due to flag file." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
skip_checker_on_env()
|
||||
{
|
||||
local name="$1"
|
||||
local env="$2"
|
||||
|
||||
if [ -n "$env" ]; then
|
||||
echo "$name was skipped due to environment variable." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
checker_main()
|
||||
{
|
||||
local fnprefix="$1"
|
||||
shift
|
||||
|
||||
detect_platform
|
||||
# try to execute checker only if all attributes are detected
|
||||
[ -n "$os_name" -a -n "$os_version" ] || return $RET_SUCCESS
|
||||
|
||||
for checker in "${fnprefix}_${os_name}${os_version}" "${fnprefix}_${os_name}" "${fnprefix}"; do
|
||||
if is_function_defined "$checker"; then
|
||||
local rc=$RET_SUCCESS
|
||||
"$checker" "$@" || rc=$?
|
||||
[ "$(( $rc & $RET_FATAL ))" = "0" ] || return $RET_FATAL
|
||||
[ "$(( $rc & $RET_WARN ))" = "0" ] || return $RET_WARN
|
||||
return $rc
|
||||
fi
|
||||
done
|
||||
return $RET_SUCCESS
|
||||
}
|
||||
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
check_package_manager_deb_based()
|
||||
{
|
||||
local output=
|
||||
output="`dpkg --audit 2>&1`" || output="$output"$'\n'"'dpkg --audit' finished with error code $?."
|
||||
|
||||
if [ -n "$output" ]; then
|
||||
make_error_report 'stage=packagemanagercheck' 'level=error' 'errtype=brokenpackages' <<-EOL
|
||||
The system package manager reports the following problems:
|
||||
|
||||
$output
|
||||
|
||||
To continue with the installation, you need to resolve these issues
|
||||
using the procedure below:
|
||||
|
||||
1. Make sure you have a full server snapshot. Although the
|
||||
following steps are usually safe, they can still cause
|
||||
data loss or irreversible changes.
|
||||
2. Run 'dpkg --configure -a'. This command can fix some of the
|
||||
issues. However, it may fail. Regardless if it fails or not,
|
||||
proceed with the following steps.
|
||||
3. Run 'PLESK_INSTALLER_SKIP_PACKAGE_MANAGER_CHECK=1 plesk installer update --skip-cleanup'.
|
||||
Instead of 'update', you may need to use the command you used
|
||||
previously (for example, 'upgrade' or 'install').
|
||||
4. The next step depends on the outcome of the previous one:
|
||||
- If step 3 was completed with the "You already have the latest
|
||||
version of product(s) and all the selected components installed.
|
||||
Installation will not continue." message,
|
||||
run 'plesk repair installation'.
|
||||
- If step 3 failed, run 'dpkg --audit'. This command can show you
|
||||
packages that need to be reinstalled. To reinstall them, run
|
||||
'apt-get install --reinstall <packages>'.
|
||||
5. Run 'plesk installer update' to revert temporary changes and
|
||||
validate that the issues are resolved. If the command fails or
|
||||
triggers this check again, contact Plesk support.
|
||||
|
||||
For more information, see
|
||||
https://support.plesk.com/hc/en-us/articles/12871173047447-Plesk-update-on-Debian-Ubuntu-fails-dpkg-was-interrupted-you-must-manually-run-dpkg-configure-a-to-correct-the-problem
|
||||
EOL
|
||||
return "$RET_FATAL"
|
||||
fi
|
||||
}
|
||||
|
||||
check_package_manager_debian()
|
||||
{
|
||||
check_package_manager_deb_based
|
||||
}
|
||||
|
||||
check_package_manager_ubuntu()
|
||||
{
|
||||
check_package_manager_deb_based
|
||||
}
|
||||
|
||||
skip_checker_on_env "Package manager check" "$PLESK_INSTALLER_SKIP_PACKAGE_MANAGER_CHECK"
|
||||
skip_checker_on_flag "Package manager check" "/tmp/plesk-installer-skip-package-manager-check.flag"
|
||||
checker_main 'check_package_manager' "$@"
|
||||
File diff suppressed because it is too large
Load Diff
38
root/parallels/pool/PSA_18.0.73_17971/examiners/php_launcher.sh
Executable file
38
root/parallels/pool/PSA_18.0.73_17971/examiners/php_launcher.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
die()
|
||||
{
|
||||
echo $*
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -n "$1" ] || die "Usage: $0 php_script [args...]"
|
||||
|
||||
[ "X${PLESK_INSTALLER_DEBUG}" = "X" ] || set -x
|
||||
[ "X${PLESK_INSTALLER_STRICT_MODE}" = "X" ] || set -e
|
||||
|
||||
php_bin=
|
||||
|
||||
lookup()
|
||||
{
|
||||
[ -z "$php_bin" ] || return
|
||||
|
||||
local paths="$1"
|
||||
local name="$2"
|
||||
|
||||
for path in $paths; do
|
||||
if [ -x "$path/$name" ]; then
|
||||
php_bin="$path/$name"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
lookup "/usr/local/psa/admin/bin /opt/psa/admin/bin" "php"
|
||||
lookup "/usr/local/psa/bin /opt/psa/bin" "sw-engine-pleskrun"
|
||||
|
||||
[ -n "$php_bin" ] || \
|
||||
die "Unable to locate the sw-engine PHP interpreter to execute the script. Make sure that Parallels Plesk Panel is installed on this server."
|
||||
|
||||
exec "${php_bin}" "$@"
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
INFO: Installed Plesk version/build: 18.0.73 Ubuntu 24.04 1800251117.15...
|
||||
INFO: You have already installed the latest version Plesk 18.0.73. Tool must be launched prior to upgrade to Plesk 18.0.73 for the purpose of getting a report on potential problems with the upgrade.
|
||||
30
root/parallels/pool/PSA_18.0.73_17971/examiners/py_launcher.sh
Executable file
30
root/parallels/pool/PSA_18.0.73_17971/examiners/py_launcher.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
die()
|
||||
{
|
||||
echo "$*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -f "$1" ] || die "Usage: $0 PEX [args...]"
|
||||
|
||||
[ "X${PLESK_INSTALLER_DEBUG}" = "X" ] || set -x
|
||||
[ "X${PLESK_INSTALLER_STRICT_MODE}" = "X" ] || set -e
|
||||
|
||||
find_python_bin()
|
||||
{
|
||||
local bin
|
||||
for bin in "/opt/psa/bin/py3-python" "/usr/local/psa/bin/py3-python" "/usr/libexec/platform-python" "/usr/bin/python3" "/opt/psa/bin/python" "/usr/local/psa/bin/python" "/usr/bin/python2"; do
|
||||
[ -x "$bin" ] || continue
|
||||
python_bin="$bin"
|
||||
return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
find_python_bin ||
|
||||
die "Unable to locate Python interpreter to execute the script."
|
||||
|
||||
exec "$python_bin" "$@"
|
||||
782
root/parallels/pool/PSA_18.0.73_17971/examiners/repository_check.sh
Executable file
782
root/parallels/pool/PSA_18.0.73_17971/examiners/repository_check.sh
Executable file
@@ -0,0 +1,782 @@
|
||||
#!/bin/bash
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
[ -z "$PLESK_INSTALLER_DEBUG" ] || set -x
|
||||
[ -z "$PLESK_INSTALLER_STRICT_MODE" ] || set -e
|
||||
|
||||
export LC_ALL=C
|
||||
unset GREP_OPTIONS
|
||||
|
||||
RET_SUCCESS=0
|
||||
RET_WARN=1
|
||||
RET_FATAL=2
|
||||
|
||||
is_function_defined()
|
||||
{
|
||||
local fn="$1"
|
||||
case "$(type $fn 2>/dev/null)" in
|
||||
*function*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# @params are tags in format "key=value"
|
||||
# Report body (human readable information) is read from stdin
|
||||
# and copied to stderr.
|
||||
make_error_report()
|
||||
{
|
||||
local report_file="${PLESK_INSTALLER_ERROR_REPORT:-}"
|
||||
|
||||
local python_bin=
|
||||
for bin in "/opt/psa/bin/python" "/usr/local/psa/bin/python" "/usr/bin/python2" "/opt/psa/bin/py3-python" "/usr/local/psa/bin/py3-python" "/usr/libexec/platform-python" "/usr/bin/python3"; do
|
||||
if [ -x "$bin" ]; then
|
||||
python_bin="$bin"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$report_file" -a -x "$python_bin" ]; then
|
||||
"$python_bin" -c 'import sys, json
|
||||
report_file = sys.argv[1]
|
||||
error = sys.stdin.read()
|
||||
|
||||
sys.stderr.write(error)
|
||||
|
||||
data = {
|
||||
"error": error,
|
||||
}
|
||||
|
||||
for tag in sys.argv[2:]:
|
||||
k, v = tag.split("=", 1)
|
||||
data[k] = v
|
||||
|
||||
with open(report_file, "a") as f:
|
||||
json.dump(data, f)
|
||||
f.write("\n")
|
||||
' "$report_file" "date=$(date --utc --iso-8601=ns)" "$@"
|
||||
else
|
||||
cat - >&2
|
||||
fi
|
||||
}
|
||||
|
||||
detect_platform()
|
||||
{
|
||||
. /etc/os-release
|
||||
os_name="$ID"
|
||||
os_version="${VERSION_ID%%.*}"
|
||||
os_arch="$(uname -m)"
|
||||
if [ -e /etc/debian_version ]; then
|
||||
case "$os_arch" in
|
||||
x86_64) pkg_arch="amd64" ;;
|
||||
aarch64) pkg_arch="arm64" ;;
|
||||
esac
|
||||
if [ -n "$VERSION_CODENAME" ]; then
|
||||
os_codename="$VERSION_CODENAME"
|
||||
else
|
||||
case "$os_name$os_version" in
|
||||
debian10) os_codename="buster" ;;
|
||||
debian11) os_codename="bullseye" ;;
|
||||
debian12) os_codename="bookworm" ;;
|
||||
ubuntu18) os_codename="bionic" ;;
|
||||
ubuntu20) os_codename="focal" ;;
|
||||
ubuntu22) os_codename="jammy" ;;
|
||||
ubuntu24) os_codename="noble" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$os_name$os_version" in
|
||||
rhel7|centos7|cloudlinux7|virtuozzo7)
|
||||
package_manager="yum"
|
||||
;;
|
||||
rhel*|centos*|cloudlinux*|almalinux*|rocky*)
|
||||
package_manager="dnf"
|
||||
;;
|
||||
debian*|ubuntu*)
|
||||
package_manager="apt"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$os_name" = "ubuntu" -o "$os_name" = "debian" ]; then
|
||||
PRODUCT_ROOT_D="/opt/psa"
|
||||
else
|
||||
PRODUCT_ROOT_D="/usr/local/psa"
|
||||
fi
|
||||
}
|
||||
|
||||
has_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
is_function_defined "$fn"
|
||||
}
|
||||
|
||||
call_os_impl_function()
|
||||
{
|
||||
local prefix="$1"
|
||||
shift
|
||||
local fn="${prefix}_${os_name}${os_version}"
|
||||
"$fn" "$@"
|
||||
}
|
||||
|
||||
skip_checker_on_flag()
|
||||
{
|
||||
local name="$1"
|
||||
local flag="$2"
|
||||
|
||||
if [ -f "$flag" ]; then
|
||||
echo "$name was skipped due to flag file." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
skip_checker_on_env()
|
||||
{
|
||||
local name="$1"
|
||||
local env="$2"
|
||||
|
||||
if [ -n "$env" ]; then
|
||||
echo "$name was skipped due to environment variable." >&2
|
||||
exit $RET_SUCCESS
|
||||
fi
|
||||
}
|
||||
|
||||
checker_main()
|
||||
{
|
||||
local fnprefix="$1"
|
||||
shift
|
||||
|
||||
detect_platform
|
||||
# try to execute checker only if all attributes are detected
|
||||
[ -n "$os_name" -a -n "$os_version" ] || return $RET_SUCCESS
|
||||
|
||||
for checker in "${fnprefix}_${os_name}${os_version}" "${fnprefix}_${os_name}" "${fnprefix}"; do
|
||||
if is_function_defined "$checker"; then
|
||||
local rc=$RET_SUCCESS
|
||||
"$checker" "$@" || rc=$?
|
||||
[ "$(( $rc & $RET_FATAL ))" = "0" ] || return $RET_FATAL
|
||||
[ "$(( $rc & $RET_WARN ))" = "0" ] || return $RET_WARN
|
||||
return $rc
|
||||
fi
|
||||
done
|
||||
return $RET_SUCCESS
|
||||
}
|
||||
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
# If env variable PLESK_INSTALLER_ERROR_REPORT=path_to_file is specified then in case of error
|
||||
# repository_check.sh writes single line json report into it with the following fields:
|
||||
# - "stage": "repositorycheck"
|
||||
# - "level": "error"
|
||||
# - "errtype" is one of the following:
|
||||
# * "reponotcached" - repository is not cached (mostly due to unavailability).
|
||||
# * "reponotenabled" - required repository is not enabled.
|
||||
# * "reponotsupported" - unsupported repository is enabled.
|
||||
# * "configmanagernotinstalled" - dnf config-manager is disabled.
|
||||
# - "repo": repository name.
|
||||
# - "date": time of error occurance ("2020-03-24T06:59:43,127545441+0000")
|
||||
# - "error": human readable error message.
|
||||
|
||||
report_no_repo()
|
||||
{
|
||||
local repo="$1"
|
||||
|
||||
make_error_report 'stage=repositorycheck' 'level=error' 'errtype=reponotenabled' "repo=$repo" <<-EOL
|
||||
Plesk installation requires '$repo' OS repository to be enabled.
|
||||
Make sure it is available and enabled, then try again.
|
||||
EOL
|
||||
}
|
||||
|
||||
report_no_repo_cache()
|
||||
{
|
||||
local repo="$1"
|
||||
|
||||
make_error_report 'stage=repositorycheck' 'level=error' 'errtype=reponotcached' "repo=$repo" <<-EOL
|
||||
Unable to create $package_manager cache for '$repo' OS repository.
|
||||
Make sure the repository is available, otherwise either disable it or fix its configuration, then try again.
|
||||
EOL
|
||||
}
|
||||
|
||||
report_unsupported_repo()
|
||||
{
|
||||
local repo="$1"
|
||||
|
||||
make_error_report 'stage=repositorycheck' 'level=error' 'errtype=reponotsupported' "repo=$repo" <<-EOL
|
||||
Plesk installation doesn't support '$repo' OS repository.
|
||||
Make sure it is disabled, then try again.
|
||||
EOL
|
||||
}
|
||||
|
||||
report_rh_no_config_manager()
|
||||
{
|
||||
local target
|
||||
case "$package_manager" in
|
||||
yum)
|
||||
target="yum-utils package"
|
||||
;;
|
||||
dnf)
|
||||
target="config-manager dnf plugin"
|
||||
;;
|
||||
esac
|
||||
|
||||
make_error_report 'stage=repositorycheck' 'level=error' 'errtype=configmanagernotinstalled' <<-EOL
|
||||
Failed to install $target.
|
||||
Make sure repositories configuration of $package_manager package manager is correct
|
||||
(use '$package_manager repolist --verbose' to get its actual state), then try again.
|
||||
EOL
|
||||
}
|
||||
|
||||
check_rh_broken_repos()
|
||||
{
|
||||
local rh_enabled_repos rh_available_repos
|
||||
|
||||
# 1. `yum repolist` and `dnf repolist` list all repos
|
||||
# which were enabled before last cache creation
|
||||
# even if cache for them was not created.
|
||||
# If some repo is misconfigured and cache was created with `skip_if_unavailable=1`
|
||||
# then such repo will be listed anyway despite on cache state.
|
||||
# If some repo was enabled after last cache creation
|
||||
# then `repolist --cacheonly` will fail.
|
||||
# 2. `yum repolist --verbose` and `dnf repoinfo` list only repos
|
||||
# which were successfully cached before.
|
||||
# These commands fail if at least one repo is not available
|
||||
# and the 'skip_if_unavailable' flag is not set.
|
||||
case "$package_manager" in
|
||||
yum)
|
||||
rh_enabled_repos="$(
|
||||
{
|
||||
yum repolist enabled --cacheonly -q 2>/dev/null \
|
||||
|| yum repolist enabled -q --setopt='*.skip_if_unavailable=1'
|
||||
} | sed -n -e '1d' -e 's/^\*\?!\?\([^/[:space:]]\+\).*/\1/p'
|
||||
)" || return $RET_FATAL
|
||||
|
||||
rh_available_repos="$(
|
||||
yum repolist enabled --verbose --cacheonly -q --setopt='*.skip_if_unavailable=1' \
|
||||
| sed -n -e 's/^Repo-id\s*:\s*\([^/[:space:]]\+\).*/\1/p'
|
||||
)" || return $RET_FATAL
|
||||
;;
|
||||
dnf)
|
||||
rh_enabled_repos="$(
|
||||
{
|
||||
dnf repolist --enabled --cacheonly -q 2>/dev/null \
|
||||
|| dnf repolist --enabled -q --setopt='*.skip_if_unavailable=1'
|
||||
} | sed -n -e '1d' -e 's/^!\?\(\S\+\).*/\1/p'
|
||||
)" || return $RET_FATAL
|
||||
|
||||
rh_available_repos="$( \
|
||||
dnf repoinfo --enabled --cacheonly -q --setopt='*.skip_if_unavailable=1' \
|
||||
| sed -n -e 's|^Repo-id\s*:\s*\(\S\+\)\s*$|\1|p'
|
||||
)" || return $RET_FATAL
|
||||
;;
|
||||
esac
|
||||
|
||||
local rh_enabled_repos_f="$(mktemp /tmp/plesk-installer.preupgrade_checker.XXXXXX)"
|
||||
echo "$rh_enabled_repos" | sort > "$rh_enabled_repos_f"
|
||||
local rh_available_repos_f="$(mktemp /tmp/plesk-installer.preupgrade_checker.XXXXXX)"
|
||||
echo "$rh_available_repos" | sort > "$rh_available_repos_f"
|
||||
|
||||
local repo rc=0
|
||||
for repo in $(comm -23 "$rh_enabled_repos_f" "$rh_available_repos_f"); do
|
||||
report_no_repo_cache "$repo"
|
||||
rc=$RET_WARN
|
||||
done
|
||||
|
||||
rm -f "$rh_enabled_repos_f" "$rh_available_repos_f"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
has_rh_enabled_repo()
|
||||
{
|
||||
local repo="$1"
|
||||
|
||||
# Try to get list of repos from cache first.
|
||||
# If some repo was enabled after last cache creation
|
||||
# or some repo is unavailable the query from cache will fail.
|
||||
# Try to fetch actual metadata in this case.
|
||||
case "$package_manager" in
|
||||
yum)
|
||||
# Repo-id may end with OS version and/or architecture
|
||||
# if baseurl of the repo refers to $releasever and/or $basearch variables
|
||||
# eg 'epel/7/x86_64', 'epel/7', 'epel/x86_64'
|
||||
{
|
||||
yum repolist enabled --verbose --cacheonly -q 2>/dev/null \
|
||||
|| yum repolist enabled --verbose -q --setopt='*.skip_if_unavailable=1'
|
||||
} | grep -E -q "^Repo-id\s*: $repo(/.+)?\s*$"
|
||||
;;
|
||||
dnf)
|
||||
# note: --noplugins may cause failure and empty output on RedHat
|
||||
{
|
||||
dnf repoinfo --enabled --cacheonly -q 2>/dev/null \
|
||||
|| dnf repoinfo --enabled -q --setopt='*.skip_if_unavailable=1'
|
||||
} | grep -E -q "^Repo-id\s*: $repo\s*$"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
has_rh_config_manager()
|
||||
{
|
||||
case "$package_manager" in
|
||||
yum) yum-config-manager --help >/dev/null 2>&1 ;;
|
||||
dnf) dnf config-manager --help >/dev/null 2>&1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_rh_config_manager()
|
||||
{
|
||||
case "$package_manager" in
|
||||
yum) yum install --disablerepo 'PLESK_*' -q -y 'yum-utils' --setopt='*.skip_if_unavailable=1' ;;
|
||||
dnf) dnf install --disablerepo 'PLESK_*' -q -y 'dnf-command(config-manager)' --setopt='*.skip_if_unavailable=1' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_rh_config_manager()
|
||||
{
|
||||
if ! has_rh_config_manager && ! install_rh_config_manager; then
|
||||
report_rh_no_config_manager
|
||||
return $RET_FATAL
|
||||
fi
|
||||
}
|
||||
|
||||
enable_rh_repo()
|
||||
{
|
||||
case "$package_manager" in
|
||||
yum) yum-config-manager --enable "$@" && has_rh_enabled_repo "$@" ;;
|
||||
dnf) dnf config-manager --set-enabled "$@" && has_rh_enabled_repo "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
enable_sm_repo()
|
||||
{
|
||||
! has_rh_enabled_repo "$@" || return 0
|
||||
subscription-manager repos --enable "$@" || return $?
|
||||
# On RedHat 8 above command may return 0 on failure with "Repositories disabled by configuration."
|
||||
has_rh_enabled_repo "$@"
|
||||
}
|
||||
|
||||
check_epel()
|
||||
{
|
||||
! enable_rh_repo "epel" || return 0
|
||||
|
||||
# try to install epel-release from centos/extras or plesk/thirdparty repo
|
||||
# and then try to update it to last version shipped by epel itself
|
||||
# to make package upgradable with pum
|
||||
"$package_manager" install --disablerepo 'PLESK_*' -q -y 'epel-release' --setopt='*.skip_if_unavailable=1' 2>/dev/null \
|
||||
|| "$package_manager" install --disablerepo='*' --enablerepo 'PLESK_18_*-thirdparty' -q -y 'epel-release' \
|
||||
|| "$package_manager" install -q -y "https://dl.fedoraproject.org/pub/epel/epel-release-latest-$os_version.noarch.rpm" \
|
||||
&& "$package_manager" update -q -y 'epel-release' --setopt='*.skip_if_unavailable=1' 2>/dev/null
|
||||
|
||||
# Ensure any other EPEL repos have cache for subsequent check for broken repos (AL9)
|
||||
local epel_repos="$(
|
||||
[ "$package_manager" != "dnf" ] || {
|
||||
dnf repolist --enabled --cacheonly -q 2>/dev/null ||
|
||||
dnf repolist --enabled -q --setopt='*.skip_if_unavailable=1'
|
||||
} | sed -n -e '1d' -e 's/^!\?\(epel\S\+\).*/\1/p'
|
||||
)"
|
||||
for repo in $epel_repos; do
|
||||
"$package_manager" makecache --repo "$repo" -q
|
||||
done
|
||||
|
||||
! has_rh_enabled_repo "epel" || return 0
|
||||
|
||||
report_no_repo "epel"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_codeready()
|
||||
{
|
||||
local repo_rhel="codeready-builder-for-rhel-$os_version-$os_arch-rpms"
|
||||
local repo_rhui="codeready-builder-for-rhel-$os_version-rhui-rpms"
|
||||
local repo_rhui_alt="codeready-builder-for-rhel-$os_version-$os_arch-rhui-rpms"
|
||||
local repo_rhui_alt2="rhui-codeready-builder-for-rhel-$os_version-$os_arch-rhui-rpms"
|
||||
|
||||
! enable_sm_repo "$repo_rhel" || return 0
|
||||
! enable_rh_repo "$repo_rhui" || return 0
|
||||
! enable_rh_repo "$repo_rhui_alt" || return 0
|
||||
! enable_rh_repo "$repo_rhui_alt2" || return 0
|
||||
|
||||
report_no_repo "$repo_rhel"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_optional()
|
||||
{
|
||||
local repo_rhel="rhel-$os_version-server-optional-rpms"
|
||||
local repo_rhui="rhel-$os_version-server-rhui-optional-rpms"
|
||||
|
||||
! enable_sm_repo "$repo_rhel" || return 0
|
||||
! enable_rh_repo "$repo_rhui" || return 0
|
||||
|
||||
report_no_repo "$repo_rhel"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_repos_rhel9()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_codeready || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
check_repos_almalinux9()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
# powertools is renamed to crb since AlmaLinux 9
|
||||
! enable_rh_repo "crb" || return $rc
|
||||
|
||||
report_no_repo "crb"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_repos_cloudlinux9()
|
||||
{
|
||||
check_repos_almalinux9 "$@"
|
||||
}
|
||||
|
||||
check_repos_almalinux10()
|
||||
{
|
||||
check_repos_almalinux9 "$@"
|
||||
}
|
||||
|
||||
check_repos_centos8()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
# names of repos are lowercased since 8.3
|
||||
! enable_rh_repo "powertools" || return $rc
|
||||
! enable_rh_repo "PowerTools" || return $rc
|
||||
|
||||
report_no_repo "powertools"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_repos_cloudlinux8()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
# names of repos are changed since 8.5
|
||||
! enable_rh_repo "powertools" || return $rc
|
||||
! enable_rh_repo "cloudlinux-PowerTools" || return $rc
|
||||
|
||||
report_no_repo "powertools"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_repos_rhel8()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
[ "$1" = "install" ] || return $rc
|
||||
|
||||
check_codeready || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
check_repos_almalinux8()
|
||||
{
|
||||
check_repos_centos8 "$@"
|
||||
}
|
||||
|
||||
check_repos_rocky8()
|
||||
{
|
||||
check_repos_centos8 "$@"
|
||||
}
|
||||
|
||||
check_repos_rhel7()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_optional || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
check_repos_centos7_based()
|
||||
{
|
||||
check_rh_config_manager || return $?
|
||||
|
||||
local rc=0
|
||||
|
||||
check_epel || rc="$(( $rc | $? ))"
|
||||
check_rh_broken_repos || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
sed_escape()
|
||||
{
|
||||
# Note: this is not a full implementation
|
||||
echo -n "$1" | sed -e 's|\.|\\.|g'
|
||||
}
|
||||
|
||||
switch_eol_centos_repos()
|
||||
{
|
||||
local old_mirrorlist_host="mirrorlist.centos.org"
|
||||
local old_host="mirror.centos.org"
|
||||
local new_host="vault.centos.org"
|
||||
|
||||
grep -qFw "$old_host" /etc/yum.repos.d/CentOS-*.repo 2>/dev/null || return 0
|
||||
local backup="`mktemp -d "/tmp/yum.repos.d-$(date --rfc-3339=date)-XXXXXX"`"
|
||||
! [ -d "$backup" ] || cp -raT /etc/yum.repos.d "$backup" || :
|
||||
|
||||
sed -i \
|
||||
-e "s|^\s*\(mirrorlist\b[^/]*//`sed_escape "$old_mirrorlist_host"`/.*\)$|#\1|" \
|
||||
-e "s|^#*\s*baseurl\b\([^/]*\)//`sed_escape "$old_host"`/\(.*\)$|baseurl\1//$new_host/\2|" \
|
||||
/etc/yum.repos.d/CentOS-*.repo
|
||||
echo "YUM package manager repositories were backed up to '$backup' and switched from $old_host to $new_host ." >&2
|
||||
}
|
||||
|
||||
check_repos_centos7()
|
||||
{
|
||||
switch_eol_centos_repos
|
||||
|
||||
check_repos_centos7_based "$@"
|
||||
}
|
||||
|
||||
check_repos_cloudlinux7()
|
||||
{
|
||||
check_repos_centos7_based "$@"
|
||||
}
|
||||
|
||||
check_repos_virtuozzo7()
|
||||
{
|
||||
check_repos_centos7_based "$@"
|
||||
}
|
||||
|
||||
find_apt_repo()
|
||||
{
|
||||
local repo="$1"
|
||||
|
||||
local dist_tag=
|
||||
! [ "$os_name" = "ubuntu" ] || dist_tag="a"
|
||||
! [ "$os_name" = "debian" ] || dist_tag="n"
|
||||
|
||||
if [ -z "$_apt_cache_policy" ]; then
|
||||
# extract info of each available release as a string which consists of 'tag=value'
|
||||
# filter out releases with priority less or equal to 100
|
||||
_apt_cache_policy="$(
|
||||
apt-cache policy \
|
||||
| grep "b=$pkg_arch" \
|
||||
| grep -Eo '([a-z]=[^,]+,?)*' \
|
||||
)"
|
||||
fi
|
||||
|
||||
local l="$(echo "$repo" | cut -f1 -d'/')"
|
||||
local d="$(echo "$repo" | cut -f2 -d'/')"
|
||||
local c="$(echo "$repo" | cut -f3 -d'/')"
|
||||
|
||||
# try to find releases by distribution and component
|
||||
echo "$_apt_cache_policy" \
|
||||
| grep -E "(^|,)l=$l(,|$)" \
|
||||
| grep -E "(^|,)$dist_tag=$d(,|$)" \
|
||||
| grep -E "(^|,)c=$c(,|$)" \
|
||||
| while IFS="$(printf '\n')" read rel && [ -n "$rel" ]; do
|
||||
l="$(echo "$rel" | grep -Eo "(^|,)l=[^,]+" | cut -f2 -d"=")"
|
||||
d="$(echo "$rel" | grep -Eo "(^|,)$dist_tag=[^,]+" | cut -f2 -d"=")"
|
||||
c="$(echo "$rel" | grep -Eo "(^|,)c=[^,]+" | cut -f2 -d"=")"
|
||||
echo "$l/$d/$c"
|
||||
done
|
||||
}
|
||||
|
||||
apt_install_packages()
|
||||
{
|
||||
DEBIAN_FRONTEND=noninteractive LANG=C PATH=/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
apt-get -qq --assume-yes -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -o APT::Install-Recommends=no \
|
||||
install "$@"
|
||||
}
|
||||
|
||||
# Takes a list of suites and disables them in APT sources.
|
||||
# Multiline deb822 format is supported.
|
||||
disable_apt_suites_deb822()
|
||||
{
|
||||
local python3=/usr/bin/python3
|
||||
|
||||
"$python3" -c 'import aptsources.sourceslist' 2>/dev/null ||
|
||||
apt_install_packages python3-apt
|
||||
|
||||
"$python3" -c '
|
||||
import sys
|
||||
|
||||
from aptsources.sourceslist import SourcesList
|
||||
|
||||
|
||||
suites_to_disable=set(sys.argv[1:])
|
||||
|
||||
sources_list = SourcesList(deb822=True)
|
||||
|
||||
sources_changed = False
|
||||
for src in sources_list:
|
||||
if src.invalid:
|
||||
continue
|
||||
suites = getattr(src, "suites", ())
|
||||
if not suites:
|
||||
continue
|
||||
new_suites = [s for s in suites if s not in suites_to_disable]
|
||||
if len(new_suites) != len(suites):
|
||||
sources_changed = True
|
||||
if len(new_suites) == 0:
|
||||
src.disabled = True
|
||||
else:
|
||||
src.suites = new_suites
|
||||
|
||||
if sources_changed:
|
||||
sources_list.save()
|
||||
' "$@"
|
||||
|
||||
# Since we have changed the repositories list, we should re-read _apt_cache_policy on a next call
|
||||
# of the find_apt_repo function. Hence we have to reset the value of the variable
|
||||
_apt_cache_policy=""
|
||||
}
|
||||
|
||||
disable_apt_repo()
|
||||
{
|
||||
local repos_to_disable="$(find_apt_repo "$1" | cut -d '/' -f 2,3 | sort | uniq)"
|
||||
if [ -z "$repos_to_disable" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "$repos_to_disable" \
|
||||
| while IFS= read -r repo_to_disable && [ -n "$repo_to_disable" ]; do
|
||||
local distrib=${repo_to_disable%%/*}
|
||||
local component=${repo_to_disable##*/}
|
||||
find /etc/apt -name "*.list" -exec \
|
||||
sed -i -e "/^\s*#/! s/.*\s$distrib\s\+$component\b/# &/" {} +
|
||||
done
|
||||
|
||||
# Since we have changed the repositories list, we should re-read _apt_cache_policy on a next call
|
||||
# of the find_apt_repo function. Hence we have to reset the value of the variable
|
||||
_apt_cache_policy=""
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
check_required_apt_repo()
|
||||
{
|
||||
local repo="$1"
|
||||
[ -z "$(find_apt_repo "$repo")" ] || return 0
|
||||
report_no_repo "$repo"
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_unsupported_apt_repos_ubuntu()
|
||||
{
|
||||
[ -n "$os_codename" ] || return 0
|
||||
local mode="$1"
|
||||
|
||||
local repos="$(
|
||||
find_apt_repo "Ubuntu/[^,]+/[^,]+" | grep -v "Ubuntu/$os_codename.*/.*"
|
||||
find_apt_repo "Debian[^,]*/[^,]+/[^,]+"
|
||||
)"
|
||||
[ -n "$repos" ] || return 0
|
||||
|
||||
echo "$repos" | while IFS="$(printf '\n')" read repo; do
|
||||
report_unsupported_repo "$repo"
|
||||
done
|
||||
|
||||
[ "$mode" = "install" ] || return $RET_WARN
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_repos_ubuntu18()
|
||||
{
|
||||
[ -n "$os_codename" ] || return 0
|
||||
local mode="$1"
|
||||
local rc=0
|
||||
|
||||
check_required_apt_repo "Ubuntu/$os_codename/main" || rc="$(( $rc | $? ))"
|
||||
check_required_apt_repo "Ubuntu/$os_codename/universe" || rc="$(( $rc | $? ))"
|
||||
check_required_apt_repo "Ubuntu/$os_codename-updates/main" || rc="$(( $rc | $? ))"
|
||||
check_required_apt_repo "Ubuntu/$os_codename-updates/universe" || rc="$(( $rc | $? ))"
|
||||
check_unsupported_apt_repos_ubuntu "$mode" || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
|
||||
check_repos_ubuntu()
|
||||
{
|
||||
[ -n "$os_codename" ] || return 0
|
||||
local mode="$1"
|
||||
local rc=0
|
||||
|
||||
check_required_apt_repo "Ubuntu/$os_codename/main" || rc="$(( $rc | $? ))"
|
||||
check_required_apt_repo "Ubuntu/$os_codename/universe" || rc="$(( $rc | $? ))"
|
||||
check_unsupported_apt_repos_ubuntu "$mode" || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
check_unsupported_apt_repos_debian()
|
||||
{
|
||||
[ -n "$os_codename" ] || return 0
|
||||
local mode="$1"
|
||||
|
||||
local repos="$(
|
||||
find_apt_repo "Debian Backports/$os_codename-backports/[^,]+"
|
||||
find_apt_repo "Debian[^,]*/[^,]+/[^,]+" | grep -v "Debian.*/$os_codename.*/.*"
|
||||
find_apt_repo "Ubuntu/[^,]+/[^,]+"
|
||||
)"
|
||||
[ -n "$repos" ] || return 0
|
||||
|
||||
echo "$repos" | while IFS="$(printf '\n')" read repo; do
|
||||
report_unsupported_repo "$repo"
|
||||
done
|
||||
|
||||
[ "$mode" = "install" ] || return $RET_WARN
|
||||
return $RET_FATAL
|
||||
}
|
||||
|
||||
check_repos_debian()
|
||||
{
|
||||
[ -n "$os_codename" ] || return 0
|
||||
local mode="$1"
|
||||
local rc=0
|
||||
|
||||
if [ "$os_name" = "debian" -a "$os_version" -ge 12 ]; then
|
||||
disable_apt_suites_deb822 "$os_codename-backports"
|
||||
else
|
||||
disable_apt_repo "Debian Backports/$os_codename-backports/[^,]+"
|
||||
fi
|
||||
|
||||
check_required_apt_repo "Debian/$os_codename/main" || rc="$(( $rc | $? ))"
|
||||
check_unsupported_apt_repos_debian "$mode" || rc="$(( $rc | $? ))"
|
||||
|
||||
return $rc
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
skip_checker_on_flag "Repository check" "/tmp/plesk-installer-skip-repository-check.flag"
|
||||
|
||||
checker_main 'check_repos' "$1"
|
||||
7
root/parallels/pool/PSA_18.0.73_17971/examiners/sh_cmd.sh
Executable file
7
root/parallels/pool/PSA_18.0.73_17971/examiners/sh_cmd.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
||||
|
||||
[ "X${PLESK_INSTALLER_DEBUG}" = "X" ] || set -x
|
||||
[ "X${PLESK_INSTALLER_STRICT_MODE}" = "X" ] || set -e
|
||||
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user