mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 22:04:00 -07:00
v-list-php
This commit is contained in:
parent
22463fd0f1
commit
7274147d36
1 changed files with 76 additions and 0 deletions
76
bin/v-list-php
Normal file
76
bin/v-list-php
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: list of installed php versions
|
||||||
|
# options: [FORMAT]
|
||||||
|
#
|
||||||
|
# The function for obtaining the list of installed PHP versions.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
format=${1-shell}
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
# JSON list function
|
||||||
|
json_list() {
|
||||||
|
counter=$(echo "$phpversions" | wc -l)
|
||||||
|
i=1
|
||||||
|
echo '['
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
if [ "$i" -lt "$counter" ]; then
|
||||||
|
echo -e "\t\"$phpversion\","
|
||||||
|
else
|
||||||
|
echo -e "\t\"$phpversion\""
|
||||||
|
fi
|
||||||
|
(( ++i))
|
||||||
|
done
|
||||||
|
echo "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
# shell list function
|
||||||
|
shell_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# PLAIN list function
|
||||||
|
plain_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# CSV list function
|
||||||
|
csv_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Defining system phpversions
|
||||||
|
phpversions=$(find /etc/php/ -type d -name 'fpm' | sed "s|/etc/php/||" | sed "s|/fpm||" | sort)
|
||||||
|
|
||||||
|
# Listing data
|
||||||
|
case $format in
|
||||||
|
json) json_list ;;
|
||||||
|
plain) plain_list ;;
|
||||||
|
csv) csv_list ;;
|
||||||
|
shell) shell_list ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit
|
Loading…
Add table
Add a link
Reference in a new issue