mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Fix adding sudo to self-hosted runners
This commit is contained in:
parent
f3010adf3e
commit
f7f679181d
@ -1,9 +1,13 @@
|
|||||||
|
# Function to add sudo
|
||||||
|
add_sudo() {
|
||||||
|
if ! command -v sudo >/dev/null; then
|
||||||
|
check_package sudo || apt-get update
|
||||||
|
apt-get install -y sudo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup environment for self-hosted runners.
|
# Function to setup environment for self-hosted runners.
|
||||||
self_hosted_helper() {
|
self_hosted_helper() {
|
||||||
if ! command -v sudo >/dev/null; then
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y sudo || add_log "${cross:?}" "sudo" "Could not install sudo"
|
|
||||||
fi
|
|
||||||
if ! command -v apt-fast >/dev/null; then
|
if ! command -v apt-fast >/dev/null; then
|
||||||
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
||||||
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
||||||
@ -61,7 +65,7 @@ add_pdo_extension() {
|
|||||||
|
|
||||||
# Function to check if a package exists
|
# Function to check if a package exists
|
||||||
check_package() {
|
check_package() {
|
||||||
sudo apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add extensions.
|
# Function to add extensions.
|
||||||
@ -201,7 +205,7 @@ setup_php() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ! command -v php"$version" >/dev/null; then
|
if ! command -v php"$version" >/dev/null; then
|
||||||
add_log "$cross" "PHP" "Could not setup PHP $version"
|
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
semver=$(php_semver)
|
semver=$(php_semver)
|
||||||
@ -228,6 +232,8 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
|||||||
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
||||||
scripts="${dist}"/../src/scripts
|
scripts="${dist}"/../src/scripts
|
||||||
|
|
||||||
|
add_sudo
|
||||||
|
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/unix.sh
|
. "${scripts:?}"/unix.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user