Monitor Default Php

Discussion in 'Tips/Tricks/Mods' started by ahrasis, Nov 21, 2019.

  1. ahrasis

    ahrasis Well-Known Member

    I found that default php7.2 for ubuntu 18.04 may be changed by updating php7.3 thus may caused problem for ISPConfig and other programs relying on default php7.2. So I tried this script with monit:
    Code:
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides: Check default php
    # Required-Start:  $local_fs $network
    # Required-Stop:  $local_fs
    # Default-Start:  2 3 4 5
    # Default-Stop:  0 1 6
    # Short-Description: Check default php
    # Description: Check default php
    ### END INIT INFO
    
    OUTPUT=`php -v | head -n 1 | cut -d ' ' -f 2 | cut -f1-2 -d'.'`
    if [ $OUTPUT = 7.2 ]; then exit 0; fi
    exit 1
    
    Code:
    check program default-php with path /usr/share/dphp/dphp.sh
     if status != 0 then exec "/usr/bin/update-alternatives --set php /usr/bin/php7.2"
    
    It seems working for now but if you see any things that can be improved in the aboves, do reply with your suggestion.
     
    till likes this.

Share This Page