huawei dongle on openwrt – the fast and easy way

NOTE: this is not about battery operated 4G modems (such as the huwawei E5577 for example), see here for instructions to connect 4G modems via USB to openwrt

This is a 4MB space tp-link router, here are the steps

opkg install kmod-usb-serial kmod-usb2 luci-proto-3g kmod-usb-serial-option usb-modeswitch kmod-usb2 kmod-usb-serial-wwan kmod-usb-serial ppp comgt 

A package required for older releases of openwrt

opkg install sdparm

And the optional package

opkg install usbutils 

Now, reboot the router, then go to the routers LUCI interfaces page, then add an interface

From the drop down, chose UMTS/GPRS

On the next page, you should see one of the devices names /dev/ttyUSB0, in my case there are 2 since the device provides a storage controller, the modem was on USB0 not USB1, your might be different (try both if you have 2)

Now i chose UMTS only so that the modem will always use 3G because edge is good for nothing

Then your APN and username/password as you would on a phone or anywhere else… then save and apply

OpenWRT router with huawei hilink – on a 4MB router

Since this router has around 600 to 700 KBs of free space, running the hi link USB dongle modem should be done with the bare minimum packages
Here are the ones i installed to get mine running

opkg install kmod-usb-net kmod-usb-net-rndis kmod-usb-net-cdc-ether udev usb-modeswitch kmod-usb-serial-option kmod-usb-net

Right after, i rebooted, then running the command,

ifconfig -a

I got a new eithernet device (USB0), on another older hi link dongle it was called eth2.

Then, from within LUCI, you can simply add a new interface using this hardware interface, and set that to DHCP and add it to the WAN segment, You are done, it should be connected now

Please be aware that once you have it running, you might want to get into the dongle’s interface settings, and instruct the dongle to only use 3G (Not GSM/EDGE), i do that by visiting 192.168.8.1 (Hard coded, can not be changed, but depending on the model yours might be different).

Moving files in linux with samba

Well, we all know FTP, HTTP and other protocols would do the trick, but they are not the fastest way. because of setup and other considerations, especially when we are planing to use both windows and linux in the transactions, a low overhead method would be samba, or windows network file sharing

In windows, it is simple, we all know how to share a folder, and we all know how to open a shared folder over the network, in linux it is just as simple.

The detailed explanation of how to setup the samba server and share a folder is already in a post, but from the client side, you can copy a file by simply mounting the shared drive onto the linux server and copy or move files like you would a normal file or folder.

To mount we can simply execute the following

1- Install the client tools to mount the folder
apt-get install cifs-utils

then
mkdir /hds
mkdir /hds/smbmount

mount -t cifs //192.168.15.116/sharedfolder /hds/smbmount -o username=techg,noexec

That’s it, now use CP and MV as you would normally

One problem i faced with this method before was that my WD My Book Live shares would not mount, it threw an error

mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

The logs did not provide much help either

CIFS VFS: cifs_mount failed w/return code = -22

Turns out that the WD MyBook Live has an older version of Debian, and samba on that device had a max-v of 2, so the solution is to connect while specifying which version of samba works

mount -t cifs //192.168.2.116/sharedfolder /hds/smbmount -o vers=2.0,username=techg,noexec

The values for Version can be 2.0 2.1 3.0

Google talk stopped working, make it work again

Google talk stopped working today, but i am so used to it, i don’t think i can live without it.

When i try to login, it says, username and password do not match, (You provided somename).

So here is the plan to make google talk work again.

PLEASE LEAVE A COMMENT IF YOU WOULD LIKE ME TO MAKE THIS SERVICE PUBLIC

The google talk installer is all over the internet, google talk uses XMPP as a protocol

I will be creating a server, and creating a file to make google talk connect to my server

Now i will tell all my friends to register their existing email address with this server and to run the file that changes the server for google talk, and we should be back online again

I will be monitoring my own instance of google talk for incoming and outgoing data so that i can modify the server so that it would become fully compatible since google talk is not 100% XMPP.

I will keep everyone posted on this. Hopefully i will have it working by the end of the day

lead acid batteries – all about

Because i use lead acid batteries on my UPS systems, i will be putting all the relevant information that i need on lead acid batteries here

1- What does 74ah (74 amp per hour mean)
In most cases, it means 3.7ah over 20 hours, so you can draw 3.7 amps for 20 hours before the voltage drops to 10.5V, the equation is not linear, so basically you will be able to draw less than 7.4ah in 10 hours (Less than double for half the time), the rating is usually 20 hours on most batteries, the Bosch car batteries (S3 S4 S5…) are measured for 20 hours for example.

The CCA are usually measured for a 10 second period until the voltage drops to 7.5V (Yes, minimum of 7.5V not 10.5)

Now, sometimes, i connect an inverter and a power supply and a battery together, so that the inverter draws from the power supply, while the battery is technically maintaining its charge, if you can’t control the current, and just want the charge to stay put, something between 12.6 and 12.7 is a good voltage, but to be on the safe side, fully charge your battery, then let it sit for 24 hours, then get a voltage reading, tune your power supply to that voltage, and connect them all together.

Firefox not caching

After spending the day trying to figure out why firefox was not caching images from my website even though chrome seems to honor the caching headers from the server correctly, it turned out that my browser settings were not correct

Somehow, caching was disabled in firefox, to enable it i did the following

visit about:config (fill it into your address bar), this will give you your browser settings

in the top box, type in browser.cache

Make sure both browser.cache.memory.enable and browser.cache.disk.enable are set to true, if they are not, you simply double click it to flip it.

Close this window and try (no need to restart firefox).

nginx rewriting sub domain into a directory internally

To make a long story short, the most efficient way of doing this is simply to change the document root according to the sub domain

So within your server stanza, you can simply do the following

server_name ~^(?.+)\.tech-g\.com$;
    root /var/www_nginx/$sub;

This way, when you add a directory such as myothersite.com inside your nginx web directory, visitors comming to myothersite.com.tech-g.com will end up being served content from the directory /var/www_nginx/myothersite.com

No rewriting URLs needed, and no evil if statements either

MySQL would not install on debian

Had problems with

apt-get install mysql-server
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
Setting up mysql-server-5.5 (5.5.37-0ubuntu0.14.04.1) ...
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 146: logger: command not found
ATTENTION: An error has occured. More info is in the syslog!
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 236: logger: command not found
dpkg: error processing package mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.

So the sollution was to remove mysql completely,

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean

then run

apt-get dist-upgrade

then installing mysql-server again

apt-get install mysql-server