| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/bin/bash
- # info: list default PHP version used by default.tpl
- # options: [FORMAT]
- #
- # example: v-list-default-php
- #
- # List the default version used by de the default template
- #----------------------------------------------------------#
- # Variables & Functions #
- #----------------------------------------------------------#
- # Argument definition
- format=${1-shell}
- # Includes
- # shellcheck source=/etc/hestiacp/hestia.conf
- source /etc/hestiacp/hestia.conf
- # shellcheck source=/usr/local/hestia/func/main.sh
- source $HESTIA/func/main.sh
- # load config file
- source_conf "$HESTIA/conf/hestia.conf"
- # JSON list function
- json_list() {
- i=1
- objects=$(echo "${versions[@]}" |wc -w)
- echo '['
- for version in "${versions[@]}"; do
- if [ "$i" -lt "$objects" ]; then
- echo -e "\t\"$version\","
- else
- echo -e "\t\"$version\""
- fi
- (( ++i))
- done
- echo "]"
- }
- # SHELL list function
- shell_list() {
- echo "VERSION"
- echo "--------"
- for version in "${versions[@]}"; do
- echo "$version"
- done
- }
- # PLAIN list function
- plain_list() {
- for version in "${versions[@]}"; do
- echo "$version"
- done
- }
- # CSV list function
- csv_list() {
- echo "VERSION"
- for version in "${versions[@]}"; do
- echo "$version"
- done
- }
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- declare -a versions;
- # List through /etc/php
- for version in /etc/php/*/fpm/pool.d/www.conf; do
- ver=$(echo "$version" | awk -F"/" '{ print $4 }');
- versions+=("$ver")
- done
- # Listing data
- case $format in
- json) json_list ;;
- plain) plain_list ;;
- csv) csv_list ;;
- shell) shell_list ;;
- esac
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- exit
|