Make all extension variables local

This commit is contained in:
Shivam Mathur 2021-09-28 01:42:44 +05:30
parent ab12e42197
commit 2c5cb7a75e
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 14 additions and 14 deletions

View File

@ -18,7 +18,7 @@ add_log() {
# Function to remove extensions # Function to remove extensions
remove_extension() { remove_extension() {
extension=$1 local extension=$1
sudo sed -Ei '' "/=(.*\/)?\"?$extension/d" "$ini_file" sudo sed -Ei '' "/=(.*\/)?\"?$extension/d" "$ini_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
@ -26,7 +26,7 @@ remove_extension() {
# Function to test if extension is loaded # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 local extension=$1
if [ "$extension" != "mysql" ]; then if [ "$extension" != "mysql" ]; then
php -m | grep -i -q -w "$extension" php -m | grep -i -q -w "$extension"
else else
@ -42,7 +42,7 @@ pecl_install() {
# Function to get the PECL version # Function to get the PECL version
get_pecl_version() { get_pecl_version() {
extension=$1 local extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")" stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
pecl_rest='https://pecl.php.net/rest/r/' pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml) response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
@ -55,7 +55,7 @@ get_pecl_version() {
# Function to install a PECL version # Function to install a PECL version
add_pecl_extension() { add_pecl_extension() {
extension=$1 local extension=$1
pecl_version=$2 pecl_version=$2
prefix=$3 prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
@ -114,7 +114,7 @@ add_brew_extension() {
# Function to setup extensions # Function to setup extensions
add_extension() { add_extension() {
extension=$1 local extension=$1
install_command=$2 install_command=$2
prefix=$3 prefix=$3
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
@ -132,7 +132,7 @@ add_extension() {
# Function to pre-release extensions using PECL # Function to pre-release extensions using PECL
add_unstable_extension() { add_unstable_extension() {
extension=$1 local extension=$1
stability=$2 stability=$2
prefix=$3 prefix=$3
pecl_version=$(get_pecl_version "$extension" "$stability") pecl_version=$(get_pecl_version "$extension" "$stability")

View File

@ -20,7 +20,7 @@ update_ppa() {
# Function to install phalcon # Function to install phalcon
install_phalcon() { install_phalcon() {
extension=$1 local extension=$1
version=$2 version=$2
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-psr" "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || (update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-psr" "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver" add_log "$cross" "$extension" "Could not install $extension on PHP $semver"

View File

@ -62,7 +62,7 @@ configure_pecl() {
# Function to get the PECL version # Function to get the PECL version
get_pecl_version() { get_pecl_version() {
extension=$1 local extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")" stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
pecl_rest='https://pecl.php.net/rest/r/' pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml) response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
@ -89,7 +89,7 @@ enable_extension() {
# Function to test if extension is loaded # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 local extension=$1
if [ "$extension" != "mysql" ]; then if [ "$extension" != "mysql" ]; then
php -m | grep -i -q -w "$extension" php -m | grep -i -q -w "$extension"
else else
@ -99,7 +99,7 @@ check_extension() {
# Function to delete extensions # Function to delete extensions
delete_extension() { delete_extension() {
extension=$1 local extension=$1
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$ini_file" sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$ini_file"
sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$pecl_file" sudo sed -Ei "/=(.*\/)?\"?$extension/d" "$pecl_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
@ -109,7 +109,7 @@ delete_extension() {
# Function to disable and delete extensions # Function to disable and delete extensions
remove_extension() { remove_extension() {
extension=$1 local extension=$1
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
sudo phpdismod -v "$version" "$extension" sudo phpdismod -v "$version" "$extension"
fi fi
@ -118,7 +118,7 @@ remove_extension() {
# Function to setup extensions # Function to setup extensions
add_extension() { add_extension() {
extension=$1 local extension=$1
install_command=$2 install_command=$2
prefix=$3 prefix=$3
enable_extension "$extension" "$prefix" enable_extension "$extension" "$prefix"
@ -135,7 +135,7 @@ add_extension() {
# Function to install a PECL version # Function to install a PECL version
add_pecl_extension() { add_pecl_extension() {
extension=$1 local extension=$1
pecl_version=$2 pecl_version=$2
prefix=$3 prefix=$3
configure_pecl configure_pecl
@ -158,7 +158,7 @@ add_pecl_extension() {
# Function to pre-release extensions using PECL # Function to pre-release extensions using PECL
add_unstable_extension() { add_unstable_extension() {
extension=$1 local extension=$1
stability=$2 stability=$2
prefix=$3 prefix=$3
pecl_version=$(get_pecl_version "$extension" "$stability") pecl_version=$(get_pecl_version "$extension" "$stability")