Swapping all Users' php1_select and php2_select

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » CustomBuild » ./build php

Swapping all Users' php1_select and php2_selectLast Modified: Sep 1, 2017, 5:41 pm
As php versions progress, you'll usually set the newer php version in php2_release in the options.conf, and the older/more stable version of php1_release in php1_select.

In some cases, you might need to flip all User php sections, such that their domain.com.conf file swaps the php1_select and php2_select values, also accounting for the fact that some domain.com.conf files may not have any values set.

Here's a quick script that scan swap the existing php1_select and php2_select values with each other, and for anyone without a setting, it will flip from the default to php1_select=2.
I would recommend you backups all /usr/local/directadmin/data/users/*/domains/*.conf files before testing this script.

#default to swap if nothing present.
#to flip back to make php1_select=1 the default, set PHP1=2, PHP2=1.
#PHP1/PHP2 are not affected by conf files which already have values, as they're just swapped.

for i in `ls /usr/local/directadmin/data/users/*/domains/*.conf`; do
       HAS_SELECT=`grep -c php1_select $i`
       if [ "${HAS_SELECT}" = "0" ]; then
               echo php1_select=${PHP2} >> $i
               echo php2_select=${PHP1} >> $i

       #we do have it, read and flip values.
       D_PHP1=`grep php1_select $i | head -n1 | cut -d= -f2`
       D_PHP2=`grep php2_select $i | head -n1 | cut -d= -f2`

       #swap 1to2 2to1
       perl -pi -e "s/^php1_select=.*/php1_select=${D_PHP2}/" $i
       perl -pi -e "s/^php2_select=.*/php2_select=${D_PHP1}/" $i
exit 0;

and follow it up with a rewrite:

cd /usr/local/directadmin/custombuild
./build update
./build rewrite_confs

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST