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

Wednesday, January 28, 2015

Android: How to Delete synced Contacts

If you wish to delete all contacts from your Android device, without deleting from gmail...

1. Disable syncing by going to Settings > Accounts & sync. Select your Google account and uncheck Contacts. If you sync contacts with other apps such as Facebook or Twitter, be sure to disable syncing for those apps as well.

2. Go to Settings > Applications > Manage applications > All > Contacts Storage and select Clear data.
Note: This will also clear other data like your recent calls and Favorites

Thanks to  Mitch Bartlett for his post of Android: How to Delete All Contacts

Tuesday, December 23, 2014

Dongle gsm

Asterisk huawei 3g dongle
https://code.google.com/p/asterisk-chan-dongle/

All the instrucctions specifically for asterisk 11 are here:
http://zaliasrobotas.blogspot.mx/2013/10/chandongle-do-not-compile-with-asterisk.html

Tuesday, October 21, 2014

fsck /home

To fsck /home, you need to change /etc/passwd to set user directory to /var/tmp

breyes:x:1000:1000:Beto Reyes,,,:/var/tmp:/bin/bash

After that, you do a list of open files related to /home directory with:
lsof +D /home

I recomend to stop samba service
/etc/init.d/samba stop

Stop dropbox service
dropbox stop

Do a full fsck with:
fsck.ext3 -f /dev/solar_vg/home_lv

after finishing, undo the previous steps