Make /run/php directory in ubuntu and fix extension install

This commit is contained in:
Shivam Mathur 2019-09-19 04:08:02 +05:30
parent c5825452ec
commit e71c06a64f
3 changed files with 41 additions and 20 deletions

View File

@ -42,26 +42,28 @@ function asyncForEach(array, callback) {
Enable extensions which are installed but not enabled Enable extensions which are installed but not enabled
*/ */
function enableExtension(extension) { function enableExtension(extension) {
return __awaiter(this, void 0, void 0, function* () {
windows += `try { windows += `try {
$${extension}_found = 0
$ext_dir = Get-PhpIniKey extension_dir $ext_dir = Get-PhpIniKey extension_dir
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll $exist = Test-Path -Path $ext_dir\\php_${extension}.dll
$enabled = php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}" $enabled = php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}"
if($enabled -eq 'no' -and $exist) { if($enabled -eq 'no' -and $exist) {
Enable-PhpExtension ${extension} C:\\tools\\php$version Enable-PhpExtension ${extension} C:\\tools\\php$version
$${extension}_found = 1
} }
} catch [Exception] { } catch [Exception] {
echo $_ echo $_
}\n`; }\n`;
let shell_code = `ext_dir=$(php-config --extension-dir) let shell_code = `ext_dir=$(php-config --extension-dir)
${extension}_found=0
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}") enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"' echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
echo "${extension} enabled" echo "${extension} enabled"
${extension}_found=1
fi\n`; fi\n`;
linux += shell_code; linux += shell_code;
darwin += shell_code; darwin += shell_code;
});
} }
/* /*
Install and enable extensions Install and enable extensions
@ -86,7 +88,9 @@ function addExtension(extension_csv, version) {
// else add script to attempt to install the extension // else add script to attempt to install the extension
if (os_version == 'linux') { if (os_version == 'linux') {
linux += linux +=
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' + 'if [ $' +
extension +
'_found -eq 0 ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
version + version +
'-' + '-' +
extension + extension +
@ -94,7 +98,7 @@ function addExtension(extension_csv, version) {
version + version +
'-' + '-' +
extension + extension +
'"\n'; '"; fi\n';
} }
else { else {
// check if pecl extension exists // check if pecl extension exists
@ -109,19 +113,24 @@ function addExtension(extension_csv, version) {
extension_version = 'alpha'; extension_version = 'alpha';
} }
windows += windows +=
'if($' +
extension +
'_found -eq 0) { ' +
'try { Install-PhpExtension ' + 'try { Install-PhpExtension ' +
extension + extension +
' -MinimumStability ' + ' -MinimumStability ' +
extension_version + extension_version +
' } catch [Exception] { echo $_; echo "Could not install extension: "' + ' } catch [Exception] { echo $_; echo "Could not install extension: "' +
extension + extension +
' }\n'; ' } }\n';
darwin += darwin +=
'pecl install ' + 'if [ $' +
extension +
'_found -eq 0 ]; then pecl install ' +
extension + extension +
' || echo "Couldn\'t find extension: ' + ' || echo "Couldn\'t find extension: ' +
extension + extension +
'"\n'; '"; fi\n';
} }
else { else {
console.log('Cannot find pecl extension: ' + extension); console.log('Cannot find pecl extension: ' + extension);
@ -172,7 +181,7 @@ function createScript(filename, version) {
if (error) { if (error) {
return console.log(error); return console.log(error);
} }
console.log('The file was saved!'); console.log('The file was saved! \n' + script);
}); });
}); });
} }

View File

@ -27,23 +27,27 @@ async function asyncForEach(array: any, callback: any) {
/* /*
Enable extensions which are installed but not enabled Enable extensions which are installed but not enabled
*/ */
async function enableExtension(extension: string) { function enableExtension(extension: string) {
windows += `try { windows += `try {
$${extension}_found = 0
$ext_dir = Get-PhpIniKey extension_dir $ext_dir = Get-PhpIniKey extension_dir
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll $exist = Test-Path -Path $ext_dir\\php_${extension}.dll
$enabled = php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}" $enabled = php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}"
if($enabled -eq 'no' -and $exist) { if($enabled -eq 'no' -and $exist) {
Enable-PhpExtension ${extension} C:\\tools\\php$version Enable-PhpExtension ${extension} C:\\tools\\php$version
$${extension}_found = 1
} }
} catch [Exception] { } catch [Exception] {
echo $_ echo $_
}\n`; }\n`;
let shell_code = `ext_dir=$(php-config --extension-dir) let shell_code = `ext_dir=$(php-config --extension-dir)
${extension}_found=0
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}") enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"' echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
echo "${extension} enabled" echo "${extension} enabled"
${extension}_found=1
fi\n`; fi\n`;
linux += shell_code; linux += shell_code;
darwin += shell_code; darwin += shell_code;
@ -71,7 +75,9 @@ async function addExtension(extension_csv: string, version: string) {
// else add script to attempt to install the extension // else add script to attempt to install the extension
if (os_version == 'linux') { if (os_version == 'linux') {
linux += linux +=
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' + 'if [ $' +
extension +
'_found -eq 0 ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
version + version +
'-' + '-' +
extension + extension +
@ -79,7 +85,7 @@ async function addExtension(extension_csv: string, version: string) {
version + version +
'-' + '-' +
extension + extension +
'"\n'; '"; fi\n';
} else { } else {
// check if pecl extension exists // check if pecl extension exists
const http = new httpm.HttpClient('shivammathur/php-setup', [], { const http = new httpm.HttpClient('shivammathur/php-setup', [], {
@ -95,19 +101,24 @@ async function addExtension(extension_csv: string, version: string) {
extension_version = 'alpha'; extension_version = 'alpha';
} }
windows += windows +=
'if($' +
extension +
'_found -eq 0) { ' +
'try { Install-PhpExtension ' + 'try { Install-PhpExtension ' +
extension + extension +
' -MinimumStability ' + ' -MinimumStability ' +
extension_version + extension_version +
' } catch [Exception] { echo $_; echo "Could not install extension: "' + ' } catch [Exception] { echo $_; echo "Could not install extension: "' +
extension + extension +
' }\n'; ' } }\n';
darwin += darwin +=
'pecl install ' + 'if [ $' +
extension +
'_found -eq 0 ]; then pecl install ' +
extension + extension +
' || echo "Couldn\'t find extension: ' + ' || echo "Couldn\'t find extension: ' +
extension + extension +
'"\n'; '"; fi\n';
} else { } else {
console.log('Cannot find pecl extension: ' + extension); console.log('Cannot find pecl extension: ' + extension);
} }
@ -150,7 +161,7 @@ async function createScript(filename: string, version: string) {
if (error) { if (error) {
return console.log(error); return console.log(error);
} }
console.log('The file was saved!'); console.log('The file was saved! \n' + script);
}); });
} }

View File

@ -20,5 +20,6 @@ fi
composer global require hirak/prestissimo composer global require hirak/prestissimo
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo chmod 777 $ini_file sudo chmod 777 $ini_file
sudo mkdir -p /run/php
php -v php -v
composer -V composer -V