#!/bin/bash
#
# (c) Asep Andria I.W., ST.
# Email : <asep.andria@gmail.com>
# Mobile : +6285659969486
# ----------------------------------
# Check mysql.sock
# ----------------------------------
MYSQL_SOCK_DIR="/opt/lampp/var/mysql";
MYSQL_SOCK_NAME="mysql.sock";
if [ ! -x "$MYSQL_SOCK_DIR/$MYSQL_SOCK_NAME" ]; then
echo "Can not found $MYSQL_SOCK_NAME in $MYSQL_SOCK_DIR"
echo "Please check if MySQL Server is running or change the location of $MYSQL_SOCK_NAME"
echo "Exiting..."
exit 1
fi
# ----------------------------------
# Linking mysql.sock
# ----------------------------------
MYSQL_SOCK_LINK_DIR="/var/run/mysqld";
MYSQL_SOCK_LINK_NAME="mysqld.sock";
if [ ! -x "$MYSQL_SOCK_LINK_DIR/$MYSQL_SOCK_LINK_NAME" ]; then
echo "Can not found $MYSQL_SOCK_LINK_NAME in $MYSQL_SOCK_LINK_DIR"
echo ""
echo "Trying to linking $MYSQL_SOCK_DIR/$MYSQL_SOCK_NAME to $MYSQL_SOCK_LINK_DIR/$MYSQL_SOCK_LINK_NAME ..."
/bin/ln -s "$MYSQL_SOCK_DIR/$MYSQL_SOCK_NAME" "$MYSQL_SOCK_LINK_DIR/$MYSQL_SOCK_LINK_NAME"
if [ ! -x "$MYSQL_SOCK_LINK_DIR/$MYSQL_SOCK_LINK_NAME" ]; then
echo "Failed to linking $MYSQL_SOCK_DIR/$MYSQL_SOCK_NAME to $MYSQL_SOCK_LINK_DIR/$MYSQL_SOCK_LINK_NAME"
exit 1
else
echo "Success to linking $MYSQL_SOCK_DIR/$MYSQL_SOCK_NAME to $MYSQL_SOCK_LINK_DIR/$MYSQL_SOCK_LINK_NAME"
fi
fi
# ----------------------------------
# gnokii smsd path
# ----------------------------------
SMSD_PATH="/usr/local"
while true
do
killall smsd >/dev/null 2>&1
sleep 3
$SMSD_PATH/sbin/smsd -u usersms -d sms -c localhost -m mysql >/dev/null 2>&1 &
sleep 1m
done
Sometimes the mysql.sock location is differ from the os/machine to other. So, in the script above i tried to find the mysql.sock location. If exist ignore it but if not exist create a link one. We need this mysql.sock because gnokii didn't work if gnokii didn't find the mysql socket. Of course this script useful when you want to combine gnokii with MySql database.
Hope this script giving you a new inspiration.
1 comment:
Thank you Andria for this script . i will try it because i have many problem with gnokii-smsd start and stop. If you get some little time i really need your help to configure my SMS gateway with Gnokii and PlaySMS.
Regards
Chris
Post a Comment