Refactor installation scripts

This commit is contained in:
Shivam Mathur
2019-10-11 04:41:25 +05:30
parent 3087ceb811
commit e755fb7a69
25 changed files with 345 additions and 520 deletions

View File

@ -1,5 +1,6 @@
version=$(php-config --version | cut -c 1-3)
if [ "$version" != "$1" ]; then
existing_version=$(php-config --version | cut -c 1-3)
version=$1
if [ "$existing_version" != "$1" ]; then
if [ ! -e "/usr/bin/php$1" ]; then
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
sudo DEBIAN_FRONTEND=noninteractive apt update -y >/dev/null 2>&1
@ -37,3 +38,20 @@ sudo chmod 777 "$ini_file"
sudo mkdir -p /run/php
php -v
composer -V
add_extension()
{
extension=$1
install_command=$2
prefix=$3
log_prefix=$4
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >> "$ini_file" && echo "\033[32;1m$log_prefix: Enabled $extension\033[0m";
elif php -m | grep -i -q "$extension"; then
echo "\033[33;1m$log_prefix: $extension was already enabled\033[0m";
elif ! php -m | grep -i -q "$extension"; then
eval "$install_command" && \
echo "\033[32;1m$log_prefix: Installed and enabled $extension\033[0m" || \
echo "\033[31;1m$log_prefix: Could not find php$version-$extension on APT repository\033[0m";
fi
}