File tree Expand file tree Collapse file tree 3 files changed +65
-71
lines changed
Expand file tree Collapse file tree 3 files changed +65
-71
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ json_list() {
2828 fi
2929 done
3030
31- echo " { "
31+ echo " [ "
3232 for type in $( echo $DB_SYSTEM | sed -e ' s/,/\n/' ) ; do
3333 if [ -e " $VESTA /conf/$type .conf" ]; then
3434 for str in $( cat $VESTA /conf/$type .conf) ; do
3535 eval $str
36- echo -n ' " ' $HOST ' ": {
36+ echo -n ' {
3737 "HOST": "' $HOST ' ",
3838 "TYPE": "' $type ' ",
3939 "CHARSETS": "' $CHARSETS ' ",
@@ -54,7 +54,7 @@ json_list() {
5454 done
5555 fi
5656 done
57- echo ' } '
57+ echo ' ] '
5858}
5959
6060# SHELL list function
Original file line number Diff line number Diff line change 4646 $ v_dns_cluster = 'yes ' ;
4747}
4848
49- // List MySQL hosts
50- exec (VESTA_CMD ."v-list-database-hosts mysql json " , $ output , $ return_var );
51- $ v_mysql_hosts = json_decode (implode ('' , $ output ), true );
49+ // List Database hosts
50+ exec (VESTA_CMD ."v-list-database-hosts json " , $ output , $ return_var );
51+ $ db_hosts = json_decode (implode ('' , $ output ), true );
5252unset($ output );
53- foreach ($ v_mysql_hosts as $ key => $ value ) {
54- $ v_mysql = 'yes ' ;
55- }
56-
57- // List PostgreSQL hosts
58- exec (VESTA_CMD ."v-list-database-hosts pgsql json " , $ output , $ return_var );
59- $ v_pgsql_hosts = json_decode (implode ('' , $ output ), true );
60- unset($ output );
61- foreach ($ v_pgsql_hosts as $ key => $ value ) {
62- $ v_pgsql = 'yes ' ;
63- }
53+ $ v_mysql_hosts = array_values (array_filter ($ db_hosts , function ($ host ){return $ host ['TYPE ' ] === 'mysql ' ;}));
54+ $ v_mysql = count ($ v_mysql_hosts ) ? 'yes ' : 'no ' ;
55+ $ v_pgsql_hosts = array_values (array_filter ($ db_hosts , function ($ host ){return $ host ['TYPE ' ] === 'pgsql ' ;}));
56+ $ v_pgsql = count ($ v_pgsql_hosts ) ? 'yes ' : 'no ' ;
57+ unset($ db_hosts );
6458
6559// List backup settings
6660$ v_backup_dir = "/backup " ;
You can’t perform that action at this time.
0 commit comments