Sutff about my job and comments about personal activities. Take a look to the first idea.

Thursday, June 01, 2017

NetworkManager

When using NetworkManager, it is posible to start a VPN connection after a successful wireless connection.
I have autofs configured on my home directory, so I need to start autofs after VPN connection:
/etc/NetworkManager/dispatcher.d/10autofs

#!/bin/bash
SERVER='172.16.1.1'
# Nothing to do if user does not have requisite binaries.
ping -c 1 $SERVER &>/dev/null
if [ $? -ne 0 ]; then
        # server is down so unmount
        /etc/init.d/autofs stop
else
        # server is up
        /etc/init.d/autofs start
fi
Whenever a VPN or wireless disconnection ocurrs, I've to stop autofs:
/etc/NetworkManager/dispatcher.d/pre-down.d/autofs
#!/bin/bash
interface=$1 
status=$2
if [ "$interface" == "wlan0" ] || [ "$CONNECTION_ID" == "reyesdf-tap" ]; then
        for dir in $(mount | grep "/mnt/auto" | awk '{print $3}' | tail -n +2)
        do
            umount $dir
        done
        sleep 5
        /etc/init.d/autofs stop
fi

References for understanding the scripts:
https://wiki.archlinux.org/index.php/NetworkManager
https://developer.gnome.org/NetworkManager/unstable/NetworkManager.html

Sunday, April 23, 2017

Running Asterisk with different web user

Freepbx 12 install configure "asterisk" user to run apache server... as explained here:
https://community.freepbx.org/t/running-asterisk-with-different-web-user/26812/1

But, as the same post explain, its better to use www-data user to run apache server...
The diagnostic is that everytime  "amportal chown" or "amportal start" is executed, the ownership of files are changed to "asterisk"...

The config files are needed to modify before running freepbx install
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-12.0-latest.tgz
tar xvfz freepbx-12.0-latest.tgz
freepbx/amp_conf/bin/freepbx_engine:AMPASTERISKUSER=www-data
freepbx/install_amp:$runas_uid = "www-data";
freepbx/libfreepbx.install.php: $set['value'] = 'www-data';
freepbx/libfreepbx.install.php: $set['value'] = 'www-data';
cd freepbx
./install_amp --installdb