January 24, 2013

Dynamic DNS on Raspberry Pi

With Ni-IP.org and inadyn



  1. Register for an account at no-ip.org.
  2. Install inadyn "apt-get install inadyn"
  3. create a config file in etc called inadyn.conf:
--username xxxx 
--password xxxx
update_period 60000
alias carpi.no-ip.org
dyndns_system default@no-ip.com

Raspberry Pi with 3G and WiFi


Aim: To have a Wireless hotspot in the truck with 3G internet and vehicle tracking
Kit:
  • Raspberry Pi running Raspbian
  • Powered USB Hub
  • Huawei E170 3G Dongle
  • TP-Link TL-WN722N
After several false starts and 10's of hours trying to get various hardware working I settled on the above.

Wireless Setup

apt-get install hostapd dhcpd
nano /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=3GPi
hw_mode=g
channel=11
wpa=2
wpa_passphrase=xxxxxx
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
auth_algs=3
wmm_enabled=1
nano /etc/dhcp3/dhcpd.conf

subnet 10.10.0.0 netmask 255.255.255.0 {
        range 10.10.0.25 10.10.0.50;
        option domain-name-servers 202.37.101.1, 202.37.101.2;
        option routers 10.10.0.1;}
nano /etc/network/interfaces

auto lo

iface lo inet loopback

iface eth0 inet dhcp
 post-up iptables-restore </etc/network/iptables

allow-hotplug wlan0

iface wlan0 inet static 
  address 10.10.0.1 
  netmask 255.255.255.0 

  post-up /etc/init.d/hostapd start ; /etc/init.d/isc-dhcp-server start 
  down /etc/init.d/hostapd stop ; /etc/init.d/isc-dhcp-server stop
Permanently enable IP forwarding in /etc/sysctl.conf:
net.ipv4.ip_forward=1
nano /etc/network/iptables
*nat
:PREROUTING ACCEPT [2:208]
:INPUT DROP [2:208]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -i wlan0 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 4 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 12 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -s [MY IP AT HOME] -j ACCEPT
:OUTPUT ACCEPT [1:108]
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -o ppp0 -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o ppp0 -j MASQUERADE
COMMIT

Managed to get 2MB/s running through it using Plex on the iPad

Setting up 3G



wget "http://www.sakis3g.org/versions/latest/$ARCH/sakis3g.gz" # where $ARCH is either i386 or amd64
gunzip sakis3g.gz
chmod +x sakis3g
./sakis3g --interactive

I have had to make alot of changes to this since I added the GPS as the GPS module moves all the serial ports around. Here is the working config:


USBINTERFACE="0"
USBDRIVER="option"
USBMODEM="12d1:140c"
OTHER="USBMODEM"
MODEM="OTHER"
# Bus 001 Device 006: ID 12d1:140c Huawei Technologies Co., Ltd.
APN=CUSTOM_APN
#2degrees
CUSTOM_APN="direct"
APN_USER="vodafone"
APN_PASS="vodafone"

January 02, 2013

VMWare Server vmdk to ESX

vmkfstools -i <src> <dst>

http://www.corelan.be:8800/index.php/2007/09/11/moving-vmware-serverworkstation-vmdk-to-esx-server/

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1028943

ipv6ip / 6in4 tunnels Ubuntu

Add the following to your /etc/network/interfaces file
———–
auto tun0
iface tun0 inet6 v4tunnel
    address <Tunnel IPv6 Address>
    netmask <IPv6 Subnet Mask>
    endpoint <IPv4 Address of Tunnel Server>
    ttl 255
    up ip link set mtu 1480 dev tun0
    up ip route add ::/0 dev tun0
———–
The local tunnel endpoint will be the IPv4 address of the interface facing the Tunnel Server. You may need to reduce the MTU although PMTU happens automatically. You can use tracepath6 ipv6.google.com to find the lowest MTU in your path.
Also make sure you add the following to your IPv4 IPtables rules:
-A INPUT -s <IPv4 Address of Tunnel Server> -i <WAN interface> -j ACCEPT

VMWare Tools Install CLI

In vSphere Client, Install/Upgrade VMWare Tools
mkdir /media/cdrom if not exist
mount /dev/cdrom /media/cdrom
cd /tmp
tar xvf /media/cdrom/VM*
cd vmware-tools-distrib
./vmware-install.pl
If the above fails, which it will if you don’t have precompiled kernel modules, make suer to install build-essential first.

Upgrade ESXi 4.0 to 4.1

1. At the console, pressALT-F1.

2. Enter unsupported in the console and then press Enter.

3. Enter the password for the root login.

4. In Vsphere, Put the host in Maintenance mode

5. Download the 4.1 update from VMWare and unzip it to a folder called upgrade and upload it to the host.

6. Connect to the console and change to the directory that the upgrade folder has been uploaded.

7. Run the upgrade command. esxupdate update –m metadata.zip

8. At the console, pressALT-F2. Then reboot

Vehicle Fluid Capacities

http://www.datateck.com.au/Lube/PenriteAus/

80 Series Stuff

Speedo Correction

Kill Multiple processes by name

ps ax | grep “$PROCESS_NAME” | awk ‘{print $1}’ | xargs -i kill {} 2&>/dev/null

MySQL 5 Cluster reference


I will explain how to set up 3 servers, with the following roles:

server-a = management node (IP 10.1.0.10)
server-b = storage and sql node (IP 10.1.0.11)
server-c = storage and sql node (IP 10.1.0.12)

It is easy to have storage and sql nodes on separate servers, but to make this guide easier to follow (and so we don’t need 5 machines), I’ll use 3 servers.

All servers will need to have mysql-server installed. If you need help doing this, have a look at this guide.

Setting up the management node (10.1.0.10)

Default debian/ubuntu installs look for /etc/mysql/ndb_mgmd.cnf for the management node, so we need to create this file, with the following contents:

[NDBD DEFAULT]
NoOfReplicas=2
DataDir= /var/lib/mysql-cluster

# Management Node
[NDB_MGMD]
HostName=10.1.0.10
DataDir=/var/lib/mysql-cluster

# Storage Nodes (one for each node)
[NDBD]
HostName=10.1.0.11
DataDir=/var/lib/mysql-cluster
[NDBD]
HostName=10.1.0.12
DataDir=/var/lib/mysql-cluster

# SQL Nodes (one for each node)
[MYSQLD]
HostName=10.1.0.11
[MYSQLD]
HostName=10.1.0.12


The line beginning NoOfReplicas tells the cluster how many copies of data should be kept.

Now we start the management node, and it will sit waiting for connections from the storage and SQL nodes:
/etc/init.d/mysql-ndb-mgm start


Setting up SQL and data nodes

All we need to do here is make a few changes to /etc/mysql/my.cnf (the mysql config file)

First, add the following 2 lines (using the IP of your management node) inside the [mysqld] section of the config file:
MyISAM
ndb-connectstring=10.1.0.10


And near the bottom of the file there will be a section for [MYSQL_CLUSTER] which you will need to uncomment, and change the ndb-connectstring line to your management nodes IP.

If you are using separate data and sql nodes, the [mysqld] part is relevant to the sql nodes only, and the [MYSQL_CLUSTER] part is relevant to the data nodes only.

Before we start the services, we have to create the /var/lib/mysql-cluster directory and set it to be owned by the mysql user:
mkdir /var/lib/mysql-cluster
chown mysql:mysql /var/lib/mysql-cluster


Now we need to start the node services:
/etc/init.d/mysql restart
(which starts the sql node)
/etc/init.d/mysql-ndb restart
(which starts the data node)


By now, everything should be running, so we connect to the management node (by running ndb_mgm from the command line) and check that the other nodes have connected properly (using the show command):
ndb_mgm> show;
Cluster Configuration
———————
[ndbd(NDB)] 2 node(s)
id=2    @10.1.0.11  (Version: 5.0.51, Nodegroup: 0)
id=3    @10.1.0.12  (Version: 5.0.51, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @10.1.0.10  (Version: 5.0.51)

[mysqld(API)]   2 node(s)
id=4    @10.1.0.11  (Version: 5.0.51)
id=5    @10.1.0.12  (Version: 5.0.51)


This shows that everything has connected properly. If connections are missing, then it’s worth checking /var/log/syslog on the affected server to see if there are any error messages.

Using the cluster

It’s worth noting that any databases already on the servers will continue to work as before. Tables only become part of the cluster when their engine type is changed to ‘MyISAM’ by issuing this command (from a mysql prompt):
alter table tablename engine=MyISAM;


But for now we will create a new database and clustered table, and test that the data is clustered. The cluster setup applies to tables only, not databases, so we first need to create the database on both sql nodes:
create database cluster;


Now, when we create a table inside the cluster database, as long as the engine is MyISAM, the data will be synced across data nodes, which we can test by doing the following (from a mysql prompt on either sql node):
create table clustertest (i int) engine=MyISAM;
insert into clustertest () values (1);
select i from clustertest;


Which should return the single row with the value of 1. Now connect to the other SQL node and try…
insert into clustertest () values (2);
select i from clustertest;


Which should return both rows, which will happen whichever SQL node you connect to as the table is now stored in the cluster.

If you receive an error like:
ERROR 1015 (HY000): Can’t lock file (errno: 4009)


Then it is likely that some of your cluster nodes haven’t started correctly, so its worth checking the management interface again.

Shutting down and restarting the cluster

To shutdown the data nodes and management node, all you need to do is enter the command ‘shutdown’ in the management interface.

To restart, simply run
/etc/init.d/mysql-ndb-mgm start


On the management node, and
/etc/init.d/mysql-ndb start


On the data nodes. The SQL nodes continue running, and can be stopped/started using the standard mysql init script.

That’s it, you’ve now should have a working MySQL cluster. As you have NoOfReplicas=2 in the management config, you should be able to unplug either data node at any time and still have access to all of the clustered tables.

PureFTPD User add/del scripts

ftpadduser:
#!/bin/bash
echo Adding FTP user $1
pure-pw useradd $1 -u virftp -g virftp -D /home/virftpusers/$1
mkdir /home/virftpusers/$1
mkdir /home/virftpusers/$1/media
chown virftp:virftp /home/virftpusers/$1/ -R
mount –bind /mnt/500SATA/media/ /home/virftpusers/$1/media
pure-pw mkdb

ftpdeluser:
#!/bin/bash
echo Removing FTP user $1
pure-pw userdel $1
umount /home/virftpusers/$1/media
rm -r /home/virftpusers/$1
pure-pw mkdb

ESXi Power on VM from Console

Get the VM id:
vim-cmd vmsvc/getallvms
Then power on the vm:
vim-cmd vmsvc/power.on 80

PureFTP config with Virtual Users

AltLog:clf:/var/log/pure-ftpd/transfer.log
BrokenClientsCompatibility:yes
ForcePassiveIP:202.36.220.6
FSCharset:UTF-8
MinUID:1000
NoAnonymous:yes
NoChmod:yes
PAMAuthentication:yes
PassivePortRange:4500 4600
ProhibitDotFilesRead:yes
ProhibitDotFilesWrite:yes
PureDB:/etc/pure-ftpd/pureftpd.pdb
UnixAuthentication:no
VerboseLog:no

Vmware Tools install ESX4.1 / Ubuntu Maverick

wget http://packages.vmware.com/tools/VMWARE-PACKAGING-GPG-KEY.pub
apt-key add VMWARE-PACKAGING-GPG-KEY.pub
nano /etc/apt/sources.list.d/vmware-tools.list
  • Add “deb http://packages.vmware.com/tools/esx/<esx-version>/ubuntu <dist> main restricted”
  • in my case “deb http://packages.vmware.com/tools/esx/4.1u1/ubuntu karmic main restricted”
“The configuration syntax is specific to each operating system version. Replace <dist> with maverick
for Ubuntu 10.10, lucid for Ubuntu 10.04, karmic for Ubuntu 9.10, jaunty for Ubuntu 9.04, intrepid
for Ubuntu 8.10, and hardy for Ubuntu 8.04.
Replace <esx-version> with 3.5u2, 3.5u3, 3.5u4, 3.5u5, 4.0, 4.0u1, 4.0u2, or 4.1, depending on the
ESX/ESXi version.”
apt-get install vmware-open-vm-tools-kmod-generic

IPv6 on Cisco with Snap

DHCPCLIENT#show running-config

version 12.4
!
hostname DHCPCLIENT
!
ipv6 unicast-routing
!
interface Serial0/0
no ip address
ipv6 address autoconfig default

!--- The autoconfig default adds a static ipv6 
!--- default route pointing to upstream DHCP server.

!
ipv6 enable
ipv6 dhcp client pd prefix-from-provider

!--- The DHCP client prefix delegation is 
!--- given the name prefix-from-provider.

!
clock rate 2000000
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
ipv6 address prefix-from-provider ::1:0:0:0:1/64

!--- The first 48 bits are imported from the delegated
!--- prefix (2001:db8:1200) and the ::/64 is the client
!--- identifier that gives the interface Fa0/1 the
!--- global IPv6 address 2001:DB8:1200:1::1/64.

!
ipv6 enable
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
ipv6 enable
ipv6 address prefix-from-provider ::1/64

!--- Similarly, the global IPv6 address 
!--- for fa0/1 is 2001:DB8:1200::1.

!
end

Performance Tuning 80 series Diesel Engine

crazy clark here is a useful write up for you- http://lcool.org/technical/80_series/1h … p_adj.html
This info applies for a 1hdt also. Is your old mans truck a 12 or 24 valve. My 12 valve auto I used to own was exactly like what you explain, could hardly even break into a roundabout it was so sluggish. Its the offboost characteristics that do this. I took it to wopass and he transformed it very quickly into a completey differant truck, it would launch off the line even with a big trailer. Take note of the bit in the link talking about turning the wheel under the offboost comp. We turned mine 5 clicks but its totally up to you and depends where your starting point is also. This is the adustment that makes the big differance. Its quite fine and hard to feel so be carefull and take your time remembering what you have done. Take small adjustments and then drive. You will know when you have it because all of a sudden it will be a very differant truck. I also bought a 4wd bits intercooler and upped boost to 16 psi and gave the mainset a little bit more fuel. I have found on my 24 valve that I now have, that simply removing the emmisions stuff and installing an intercooler it has had much the same affect, as the 24 valve model comes with emmision gear that the 12 valve doesnt. The emission gear controls to some extent the offboost, therefore removing it makes a very noticable gain, easiest way to get rid of it is contact warren and buy a top mount. Either way I recommend intercooling. If you have the 24 valve model remove the emmision gear before you adjust anything, you may not need to. Its good he has a 3 inch exhaust that will help with egts. The aim of tuning is to get a puff of black smoke offboost, but it should clear once its making full boost. Lots of black smoke at full throttle is not what you want. Remember that high egts are bad, having said that small offboost adjustments are pretty safe on these engines and have run mine hard for years, dont be too gready on the main set adjustment screw only give it a little, and if you up boost you will want a 1/4 to 1/2 turn on that. Here is another link just look at the photos shows what to look for http://www.tlocuk.co.uk/forums/viewtopi … a75d7e12e5

Links

Tubing Coping Calculator

http://metalgeek.com/static/cope.pcgi

LSI MEgaRaid Driver


http://www.58support.nec.co.jp/global/download/421351-B01/index.html
wget http://www.58support.nec.co.jp/global/download/421351-B01/vmware-esx-provider-lsiprovider.zip

Truck related


Pi Power Control Notes



A Raspberry Pi Remote Mains Switcher, to switch these
with one of these
using the awesome reverse engineering detailed here

Installation

Requires WiringPi-Python
git clone https://github.com/WiringPi/WiringPi-Python.git cd WiringPi-Python/ git submodule update --init sudo apt-get install python2.7-dev sudo apt-get install python-setuptools sudo python setup.py install 

Running

Needs to be run as root -
sudo python raspwitch.py --channel 1 --button 3 --gpio 8 on 
When compiling today’s code form git repository gcc has problem finding wiringPi.h on my Raspbian wheezy:
CODE: SELECT ALL
WiringPi/wiringPi/piNes.c:25:22: fatal error: wiringPi.h: No such file or directory
You just need to edit piNes.c and change first include line into:
CODE: SELECT ALL
#include "wiringPi.h"
That fixes the problem.