mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Improve cURL use
This commit is contained in:
parent
90b6355bf0
commit
8b218279a3
@ -28,7 +28,7 @@ read_env() {
|
||||
self_hosted_setup() {
|
||||
if [[ $(command -v brew) == "" ]]; then
|
||||
step_log "Setup Brew"
|
||||
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1
|
||||
curl "${curl_opts[@]}" https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1
|
||||
add_log "$tick" "Brew" "Installed Homebrew"
|
||||
fi
|
||||
}
|
||||
@ -62,7 +62,7 @@ get_pecl_version() {
|
||||
extension=$1
|
||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
||||
pecl_rest='https://pecl.php.net/rest/r/'
|
||||
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
|
||||
if [ ! "$pecl_version" ]; then
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
||||
@ -155,7 +155,7 @@ add_tool() {
|
||||
rm -rf "$tool_path"
|
||||
fi
|
||||
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||
if [ "$status_code" = "200" ]; then
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
@ -239,6 +239,7 @@ version=$1
|
||||
nodot_version=${1/./}
|
||||
old_versions="5.[3-5]"
|
||||
tool_path_dir="/usr/local/bin"
|
||||
curl_opts=(-sSL --retry 5 --retry-delay 1)
|
||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||
|
||||
read_env
|
||||
@ -254,7 +255,7 @@ fi
|
||||
# Setup PHP
|
||||
step_log "Setup PHP"
|
||||
if [[ "$version" =~ $old_versions ]]; then
|
||||
curl -sSL https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 &&
|
||||
curl "${curl_opts[@]}" https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 &&
|
||||
status="Installed"
|
||||
elif [ "$existing_version" != "$version" ]; then
|
||||
setup_php "install" >/dev/null 2>&1
|
||||
|
@ -1,11 +1,17 @@
|
||||
version=${1/./}
|
||||
extension=${2}
|
||||
extension_version=$(echo "$extension" | cut -d '-' -f 2)
|
||||
if [ "$extension_version" = "blackfire" ]; then
|
||||
extension_version=$(curl -sSL https://blackfire.io/docs/up-and-running/update | grep 'class="version"' | sed -e 's/<[^>]*>\| //g' | sed -n '3,3p')
|
||||
fi
|
||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
ini_file="$scan_dir/50-blackfire.ini"
|
||||
sudo curl -o $ext_dir/blackfire.so -SL https://packages.blackfire.io/binaries/blackfire-php/$extension_version/blackfire-php-linux_amd64-php-$version.so
|
||||
echo "extension=blackfire.so" | sudo tee -a "$ini_file"
|
||||
# Function to install blackfire extension.
|
||||
add_blackfire() {
|
||||
extension=$1
|
||||
version=${version:?}
|
||||
no_dot_version=${version/./}
|
||||
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
extension_version=$(echo "$extension" | cut -d '-' -f 2)
|
||||
blackfire_ini_file="${scan_dir:?}/50-blackfire.ini"
|
||||
if [ ! -e "${ext_dir:?}/blackfire.so" ]; then
|
||||
if [ "$extension_version" = "blackfire" ]; then
|
||||
extension_version=$(curl "${curl_opts[@]:?}" https://blackfire.io/docs/up-and-running/update | grep 'class="version"' | sed -e "s/ //g" | sed -n '3,3p' | cut -d '>' -f 2 | cut -d '<' -f 1)
|
||||
fi
|
||||
sudo curl -o "${ext_dir:?}/blackfire.so" "${curl_opts[@]:?}" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_amd64-php-"$no_dot_version".so >/dev/null 2>&1
|
||||
fi
|
||||
echo "extension=blackfire.so" | sudo tee -a "$blackfire_ini_file" >/dev/null 2>&1
|
||||
add_extension_log "$extension-$extension_version" "Installed and enabled"
|
||||
}
|
@ -4,8 +4,9 @@ extension_version=$(echo "$extension" | cut -d '-' -f 2)
|
||||
if [ "$extension_version" = "blackfire" ]; then
|
||||
extension_version=$(curl -sSL https://blackfire.io/docs/up-and-running/update | grep 'class="version"' | sed -e "s/ //g" | sed -n '3,3p' | cut -d '>' -f 2 | cut -d '<' -f 1)
|
||||
fi
|
||||
curl_opts=(-sSL --retry 5 --retry-delay 1)
|
||||
ext_dir=$(php -i | grep -Ei "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
ini_file="$scan_dir/50-blackfire.ini"
|
||||
sudo curl -o $ext_dir/blackfire.so -SL https://packages.blackfire.io/binaries/blackfire-php/$extension_version/blackfire-php-darwin_amd64-php-$version.so
|
||||
sudo curl -o $ext_dir/blackfire.so "${curl_opts[@]}" "https://packages.blackfire.io/binaries/blackfire-php/$extension_version/blackfire-php-darwin_amd64-php-$version.so"
|
||||
echo "extension=blackfire.so" | sudo tee -a "$ini_file"
|
@ -1,41 +1,19 @@
|
||||
# Function to log result of a operation.
|
||||
add_log() {
|
||||
mark=$1
|
||||
subject=$2
|
||||
message=$3
|
||||
if [ "$mark" = "$tick" ]; then
|
||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
|
||||
cat /tmp/ioncube/LICENSE.txt
|
||||
echo "::endgroup::"
|
||||
else
|
||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to test if extension is loaded.
|
||||
check_extension() {
|
||||
extension=$1
|
||||
php -m | grep -i -q -w "$extension"
|
||||
add_license_log() {
|
||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
|
||||
cat /tmp/ioncube/LICENSE.txt
|
||||
echo "::endgroup::"
|
||||
}
|
||||
|
||||
# Function to install ioncube.
|
||||
install_ioncube() {
|
||||
if [ ! -e "$ext_dir/ioncube.so" ]; then
|
||||
os_name='lin'
|
||||
add_ioncube() {
|
||||
if [ ! -e "${ext_dir:?}/ioncube.so" ]; then
|
||||
status='Installed and enabled'
|
||||
[ "$(uname -s)" = "Darwin" ] && os_name='mac'
|
||||
curl -sSL https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp
|
||||
sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"$version".so "$ext_dir/ioncube.so"
|
||||
os_name='lin' && [ "$(uname -s)" = "Darwin" ] && os_name='mac'
|
||||
curl "${curl_opts[@]:?}" https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp
|
||||
sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"${version:?}".so "$ext_dir/ioncube.so"
|
||||
fi
|
||||
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "$scan_dir/00-ioncube.ini"
|
||||
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1
|
||||
add_extension_log "ioncube" "$status"
|
||||
check_extension "ioncube" && add_license_log
|
||||
}
|
||||
|
||||
version=$1
|
||||
tick='✓'
|
||||
cross='✗'
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||
status='Enabled'
|
||||
install_ioncube >/dev/null 2>&1
|
||||
(check_extension "ioncube" && add_log "$tick" "ioncube" "$status") || add_log "$cross" "ioncube" "Could not install ioncube"
|
||||
|
@ -47,7 +47,7 @@ install_client() {
|
||||
arch='macos'
|
||||
lib_ext='dylib'
|
||||
fi
|
||||
curl -o "/opt/oracle/$package.zip" -sSL "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-$arch.zip"
|
||||
curl -o "/opt/oracle/$package.zip" "${curl_opts[@]}" "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-$arch.zip"
|
||||
unzip "/opt/oracle/$package.zip" -d "$oracle_home"
|
||||
done
|
||||
sudo ln -sf /opt/oracle/instantclient*/*.$lib_ext* $libs
|
||||
@ -57,7 +57,7 @@ install_client() {
|
||||
|
||||
# Function to get PHP source.
|
||||
get_php() {
|
||||
[ ! -d "/opt/oracle/php-src-$tag" ] && curl -sSL "https://github.com/php/php-src/archive/$tag.tar.gz" | tar xzf - -C "$oracle_home/"
|
||||
[ ! -d "/opt/oracle/php-src-$tag" ] && curl "${curl_opts[@]}" "https://github.com/php/php-src/archive/$tag.tar.gz" | tar xzf - -C "$oracle_home/"
|
||||
}
|
||||
|
||||
# Function to get phpize location on darwin.
|
||||
@ -86,7 +86,7 @@ restore_phpize() {
|
||||
|
||||
# Function to patch pdo_oci.
|
||||
patch_pdo_oci_config() {
|
||||
curl -sSLO https://raw.githubusercontent.com/php/php-src/master/ext/pdo_oci/config.m4
|
||||
curl -O "${curl_opts[@]}" https://raw.githubusercontent.com/php/php-src/master/ext/pdo_oci/config.m4
|
||||
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4
|
||||
}
|
||||
|
||||
@ -132,6 +132,7 @@ oracle_home='/opt/oracle'
|
||||
oracle_client=$oracle_home/instantclient
|
||||
runner="${runner:-github}" && RUNNER="${RUNNER:-github}"
|
||||
os=$(uname -s)
|
||||
curl_opts=(-sSL --retry 5 --retry-delay 1)
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||
install_client >/dev/null 2>&1
|
||||
|
@ -35,16 +35,6 @@ cleanup_lists() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to update the package lists.
|
||||
update_lists() {
|
||||
if [ ! -e /tmp/setup_php ]; then
|
||||
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1
|
||||
cleanup_lists
|
||||
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||
echo '' | sudo tee "/tmp/setup_php" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to add ppa:ondrej/php.
|
||||
add_ppa() {
|
||||
if ! apt-cache policy | grep -q ondrej/php; then
|
||||
@ -56,6 +46,16 @@ add_ppa() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to update the package lists.
|
||||
update_lists() {
|
||||
if [ ! -e /tmp/setup_php ]; then
|
||||
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1
|
||||
cleanup_lists
|
||||
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||
echo '' | sudo tee "/tmp/setup_php" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to setup environment for self-hosted runners.
|
||||
self_hosted_setup() {
|
||||
echo "Set disable_coredump false" | sudo tee -a /etc/sudo.conf
|
||||
@ -83,7 +83,7 @@ get_pecl_version() {
|
||||
extension=$1
|
||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
||||
pecl_rest='https://pecl.php.net/rest/r/'
|
||||
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
|
||||
if [ ! "$pecl_version" ]; then
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
||||
@ -218,7 +218,7 @@ add_extension_from_source() {
|
||||
(
|
||||
add_devtools
|
||||
delete_extension "$extension"
|
||||
curl -o /tmp/"$extension".tar.gz -sSL https://github.com/"$repo"/archive/"$release".tar.gz
|
||||
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz
|
||||
tar xf /tmp/"$extension".tar.gz -C /tmp
|
||||
cd /tmp/"$extension-$release" || exit 1
|
||||
phpize && ./configure "$args" && make && sudo make install
|
||||
@ -253,7 +253,7 @@ add_tool() {
|
||||
if [ ! -e "$tool_path" ]; then
|
||||
rm -rf "$tool_path"
|
||||
fi
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||
if [ "$status_code" = "200" ]; then
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
@ -300,7 +300,7 @@ add_devtools() {
|
||||
# Function to add blackfire and blackfire-agent.
|
||||
add_blackfire() {
|
||||
sudo mkdir -p /var/run/blackfire
|
||||
sudo curl -sSL https://packages.blackfire.io/gpg.key | sudo apt-key add - >/dev/null 2>&1
|
||||
sudo curl "${curl_opts[@]}" https://packages.blackfire.io/gpg.key | sudo apt-key add - >/dev/null 2>&1
|
||||
echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list >/dev/null 2>&1
|
||||
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||
$apt_install blackfire-agent >/dev/null 2>&1
|
||||
@ -317,12 +317,12 @@ add_blackfire() {
|
||||
|
||||
# Function to setup the nightly build from master branch.
|
||||
setup_master() {
|
||||
curl -sSL "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner"
|
||||
curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner"
|
||||
}
|
||||
|
||||
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
|
||||
setup_old_versions() {
|
||||
curl -sSL "$github"/php5-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
||||
curl "${curl_opts[@]}" "$github"/php5-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
||||
configure_pecl
|
||||
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
|
||||
}
|
||||
@ -362,7 +362,7 @@ add_packaged_php() {
|
||||
IFS=' ' read -r -a packages <<< "$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
|
||||
$apt_install "${packages[@]}"
|
||||
else
|
||||
curl -sSL "$github"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
||||
curl "${curl_opts[@]}" "$github"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -402,6 +402,7 @@ debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||
github="https://github.com/shivammathur"
|
||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||
tool_path_dir="/usr/local/bin"
|
||||
curl_opts=(-sSL --retry 5 --retry-delay 1)
|
||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||
|
||||
read_env
|
||||
|
Loading…
Reference in New Issue
Block a user