Thursday, 6 June 2013

Connecting to 3G using wvdial in Linux

I always keep losing my config files for wvdial and have to go through everything to figure out how to get it working again... Below is my config file tested on the South African Cell C and Vodacom networks (you'll probably need to change the Modem device though to match yours):


[Dialer Defaults]
New PPPD = yes
Phone = *99#
Username = usually
Password = ignored
Stupid Mode = 1
Dial Command = ATDT
Modem = /dev/ttyACM0
Baud = 460800
Init2 = ATZ
Init3 = AT+CGDCONT=1,"IP","Internet"
ISDN = 0
Modem Type = Analog Modem

If your sim card requires a pin before use, you can try adding the line:

Init4 = AT+CPIN=replace_with_your_pin

To do a modeswitch if your device appears as a stupid compact disc device:

1. lsusb and find the device
   Mine for eg:  Bus 001 Device 010: ID 12d1:1436 Huawei Technologies Co., Ltd. 
2. Your vendor/product ID's should be the ones before the name, eg in mine. 12d1:1436
    usb_modeswitch -v 12d1 -p 1436

If all looks good a simple of wvdial should work or let you know if you need to tweak a bit more...


Sunday, 2 June 2013

Need Linux login e-mail notifications?


Need a fast way to receive notifications of logins to your Linux server?

Append the following to: /etc/profile

/usr/local/login

Create a file /usr/local/login and change the permissions: chmod 755 /usr/local/login

You will need to install mutt, apt-get install mutt on Debian/Ubuntu should work fine, once done paste the following in the /usr/local/login file (change the e-mail address):


#!/bin/bash
#
# Login script, append full script path to /etc/profile, requires mutt            
# By ONMS.Net


email_to="support@drakepeak.net"

report_date=$(date -R)
server_ip=$(ifconfig eth0 | grep inet | head -n 1 | sed 's/:/ /g' | awk '{ print $3 }')
whoisloggedin=$(who)
message="Login Date: $report_date - Users currently logged in: $whoisloggedin"
echo $message | mutt -s "Login detected to server $server_ip" $email_to

I'll be adding a script soon to allow for login data reporting to onms.net, this should allow for easier e-mails and sms notifications of server logins.

Apache compile fails due to OpenSSL

I love (and sometimes hate) source compiling packages, it's like driving a manual car versus cruising along in an automatic, the control is truly awesome! While busy compiling Apache I got the following nasty error:

libssl.a(s2_srvr.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

It seems to happen when your running a 64 bit Linux distro, to solve this horrid message you need to unfortunately recompile openssl, in my case openssl-1.0.1e using the following command (change your prefix if need be):

./config --prefix=/usr/local/openssl -fPIC no-gost no-shared no-zlib

After that the Apache compile works without any issues, hope it helps someone else!