________________________________________________
Script: etc/rc.d/bluetoothmodem
#!/bin/sh
#
hcid
modprobe bluetooth
modprobe l2cap
modprobe rfcomm
modprobe hci_usb
mknod -m 666 /dev/rfcomm0 c 216 0
sleep 1
# in the following line change mac address and channel number for your phone
rfcomm bind /dev/rfcomm0 00:11:22:33:44:55 8
rxvt -bg “yellow” -geometry 134×20 -title “GPRS LOG” -e tail -n 20 -f /var/log/gprs.log &
pppd call 3g &
echo $DISPLAY
export DISPLAY=:0.0
# Kill MyKrodot Connetion
gxmessage -center -wrap -title “MyKroDot Connection” -buttons “EXIT” “MyKroDot is connecting. Click EXIT to disconnect MyKrodot”
killall startrdc
killall rdesktop
killall pppd
rfcomm release /dev/rfcomm0
killall hcid
killall ping
killall tail
killall openvpn
killall inadyn
_________________________________________________________
script /etc/rc.d/startrdc
#!/bin/sh
#
# startrdc
# Startup script for RDC
#
exec 1>>/var/log/rdc.log 2>&1
now=`date ‘+%d%m%y-%H:%M’`
echo -e “RUNNING STARTRDC $now ”
echo -e
# Status Functions
function status_xwin
{
echo -e “function status_xwin”
local rv=
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function wait_for_xwin
{
echo -e “function wait_for_xwin”
local rv=
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
while [ ! "$rv" != "0" ] # loop until X is up
do
echo -n ” XWIN true should be 0: $rv”
rv=`grep true /etc/.XLOADED | wc | awk ‘{print $1}’`
echo -e “Waiting for X to start = $rv”
sleep 1
continue
done
echo -e “Return Value = $rv”
return $rv
}
function wait_for_vpn
{
echo -e “function wait_for_vpn”
local rv=
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
while [ ! "$rv" != "0" ] # loop until X is up
do
echo -n “wait_for_vpn = $rv”
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
echo -e “Waiting for VPN to start = $rv”
sleep 1
continue
done
echo -e “Return Value = $rv”
return $rv
}
function status_pppd
{
echo -e “function status_pppd”
local rv=
rv=`ps | grep pppd | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_hcid
{
echo -e “function status_hcid”
local rv=
rv=`ps | grep hcid | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_rfcomm
{
echo -e “function status_rfcomm”
local rv=
rv=`ps | grep rfcomm | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_internet
{
echo -e “function status_internet”
local rv=
#rv=`ps | grep pppd | wc | awk ‘{print $1}’`
rv=`netstat -i | grep ppp | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_ping_internet
{
echo -e “function status_ping_internet”
local rv=
rv=`ping -c 1 4.2.2.1 | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_dns
{
echo -e “function status_ping_yahoo”
local rv=
rv=`ping -c 1 yahoo.com | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_dyn_dns
{
echo -e “function status_dyn_dns”
local rv=
rv=`ps | grep inadyn | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_openvpn_daemon
{
echo -e “function status_openvpn”
local rv=
rv=`ps | grep openvpn | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_openvpn_tun
{
echo -e “function status_openvpn”
local rv=
# rv=`ps | grep openvpn | wc | awk ‘{print $1}’`
rv=`netstat -i | grep tun | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_ping_vpn
{
echo -e “function status_ping_vpn”
local rv=
# rv=`netstat -i | grep tun | wc | awk ‘{print $1}’`
#10.3.0.6 is your servers TUN adapter address
rv=`ping -c 1 10.3.0.6 | grep from | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
function status_rdc
{
echo -e “function status_rdesktop”
local rv=
rv=`ps | grep rdesktop | wc | awk ‘{print $1}’`
echo -e “Return Value = $rv”
return $rv
}
# Start Functions
function start_dyn_dns
{
echo -e “\n Function start_dyn_dns”
echo -e “\n call status_dyn_dns”
status_dyn_dns
rv=$?
echo -e “status_dyn_dns: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n Starting inadyn dynamic DNS”
/usr/local/inadyn/inadyn.sh &
echo -e “\n start_dyn_dns to Test to see if inadyn started”
sleep 2
start_dyn_dns
elif [ ! "$rv" != "1" ]; then
echo -e “\n Starting inadyn dynamic DNS”
/usr/local/inadyn/inadyn.sh &
echo -e “\n start_dyn_dns to Test to see if inadyn started”
sleep 2
start_dyn_dns
fi
}
function start_bluetoothmodem
{
echo -e “\n function start_bluetoothmodem”
echo -e “\n ping the internet to see if we are connected”
status_ping_internet
rv=$?
echo -e “\n status_ping_internet: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n calling status_hcid from start_bluetoothmodem”
status_hcid
rv=$?
echo -e “\n status_hcid: Returned value: $rv”
if [ ! "$rv" != "0" ]; then
echo -e “\n Running /etc/rc.d/bluetoothmodem”
/etc/rc.d/bluetoothmodem >> /var/log/gprs.log &
elif [ ! "$rv" != "1" ]; then
echo -e “\n Running /etc/rc.d/bluetoothmodem”
/etc/rc.d/bluetoothmodem >> /var/log/gprs.log
fi
fi
}
function fix_dns
{
echo -en
}
function start_vpn
{
echo -e “function start_vpn”
/etc/openvpn/openvpn –config /etc/openvpn/mikro1.ovpn > /var/log/openvpn.log &
}
function start_rdc
{
echo -e “\n Test VPN then START RDC”
wait_for_xwin
status_ping_internet
wait_for_vpn
/usr/bin/rdesktop -a 16 -f -z -x m -E -P -N 10.3.0.6 &
echo -e “Started rdesktop”
}
# Here is the program
function connect_mykro
{
echo -e “\n\r**********************************************************************”
echo -e “***********************RUNNING CONNECT_MYKRO $now ************************”
# start_bluetoothmodem
echo -e “\n Call start_rdc”
echo -e “\n Call start_dyn_dns”
# start_dyn_dns
echo -e “\n Call start_vpn”
start_vpn
echo -e “\n Call start_bluetoothmodem”
start_rdc
status_ping_internet
pinginternetstatus=$?
echo “pinginternetstatus: $pinginternetstatus”
status_ping_vpn
vpnstatus=$?
echo “vpnstatus: $vpnstatus”
status_hcid
hcidstatus=$?
echo “hcidstatus: $hcidstatus”
status_rdc
rdcstatus=$?
echo “rdcstatus: $rdcstatus”
status_dyn_dns
dyndnsstatus=$?
echo “dyndnsstatus: $dyndnsstatus”
status_openvpn_tun
tunstatus=$?
echo “tunstatus: $tunstatus”
}
export DISPLAY=:0.0
rxvt -bg “light blue” -geometry 134×20 -title “RDC LOG” -e tail -n 20 -f /var/log/rdc.log &
rxvt -bg “red” -geometry 134×20 -title “PING REMOTE HOST” -e ping 10.3.0.6 &
# /etc/rc.d/KillAllMykrodot &
connect_mykro
exit
#End!
____________________________________________________
Script: /etc/ppp/peers/3g
noauth
connect “/usr/sbin/chat -v -f /etc/ppp/chatscripts/3gchat”
#Use /dev/rfcomm0 for bluetooth modem
#/dev/rfcomm0
#/dev/ttyS2 is my Sierra Wireless Aircard PCMCIA PC Card
/dev/ttyS2
# 115200
460800
defaultroute
noipdefault
user ISP@CINGULARGPRS.COM
password CINGULAR1
usepeerdns
nodetach
debug
crtscts
receive-all
novj
nodeflate
noccp
_______________________
Script: /etc/ppp/chatscripts/3gchat
ABORT ERROR
ABORT RING
ABORT BUSY
ABORT VOICE
ABORT “NO CARRIER”
ABORT “NO ANSWER”
#ABORT “NO DIALTONE”
REPORT CONNECT
“” “ATZ”
OK ‘AT+CGDCONT=1,”IP”,”wap.cingular”,”",0,0′
OK ATD*99***1#
TIMEOUT 60
CONNECT \c
__________________________________________
add this to etc/ppp/ip-up
PATH=/usr/bin:/usr/sbin:/usr/X11R7/bin:/sbin:/bin
export PATH
rxvt -bg “green” -geometry 134×20 -title “ping 4.2.2.1″ -e ping 4.2.2.1 &
killall inadyn
sleep 1
/usr/local/inadyn/inadyn.sh &
/root/.etc/rc.d/startrdc >/var/log/rdc.log &
______________________________
Script: /etx/ppp/ip-down
#!/bin/sh
#
/etc/rc.d/KillAllMykrodot &
_______________________________
Script /etc/rc.d/KillAllMykrodot
#!/bin/bash
#
# Kill MyKrodot Connetion
#
#
# export DISPLAY=:0.0
killall startrdc
killall rdesktop
rfcomm release /dev/rfcomm0
killall hcid
killall ping
killall tail
killall openvpn
killall inadyn
sleep 3
echo “Call bluetoothmodem”
/etc/rc.d/bluetoothmodem > /var/log/gprs.log &
________________________
Script: /etc/rc.local
#!/bin/sh
# Mikrodots, Inc. 2007
ln /bin/busybox /sbin/ip
# /etc/rc.d/bluetoothmodem >> /var/log/gprs.log &
# /usr/local/inadyn/inadyn.sh >> /dev/console
# /etc/openvpn/openvpn –config /etc/openvpn/mikro1.ovpn >> /var/log/openvpn.log &
modprobe evdev
__________________________________
No user commented in " Scripts "
Follow-up comment rss or Leave a TrackbackLeave A Reply