Sunday 27 October 2013

New setup for my raspberry pi

As I described in an earlier post, I have an raspberry pi, which I was running a vpn service, ssh and mumble on. This was working for roughly half a year, though Arch Linux somehow stopped working after not updating properly.

I tried to reinstall everything, though since Arch Linux does not work with BerryBoot I guess it was no surprise.

There has been an update to Debian, so I decided to do the easier step of installing Debian using BerryBoot (over vnc as described in my last post), which worked perfectly.

I could then connect to the server via ssh, user pi, password raspberry.
Change the password with passwd when you have logged in.
Setting up mumble was easily done by
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mumble-server
sudo dpkg-reconfigure mumble-server
sudo iptables -I INPUT -p tcp --dport 64738 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 64738 -j ACCEPT
sudo iptables-save > /etc/iptables/iptables.rules

Remember to forward traffic on port 64738 through your router. The server can be administrated thorough mumble client by setting user name to SuperUser and using the password set above in the reconfigure.
Then I set up the VPN server according to the description from Debian, though with a different config file.
port 1194
proto udp
dev tun
ca      /etc/openvpn/easy-rsa/keys/ca.crt    # generated keys
cert    /etc/openvpn/easy-rsa/keys/server.crt
key     /etc/openvpn/easy-rsa/keys/server.key  # keep secret
dh      /etc/openvpn/easy-rsa/keys/dh2048.pem # I used 2048 bit key
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS routerIP" # Put your router IP in here
server 10.9.8.0 255.255.255.0  # internal tun0 connection IP
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo         # Compression - must be turned on at both end
persist-key
persist-tun
user nobody
group nogroup
status log/openvpn-status.log
verb 3  # verbose mode
client-to-client
Remember to also do forwarding of the VPN trafic.
In addition  the router needs to forward port 1194 (UDP) to the raspberry pi.

If you want to access the vpn server on your android phone you need to generate the key with
./build-key-pkcs12 keyname
From /etc/openvpn/easy-rsa
The resulting keyname.p12 file contains the key and certificate and is the only file you need to transfer to your phone. See this page.


Now you hopefully have a working server.

Saturday 26 October 2013

Not working anymore: My first post is about .... My new Raspberry PI setup, running OpenVPN, ssh and murmur (mumble server)

 This will be my first blog post ever :O, so bear with me in this experiment.

I bought a Raspberry PI a year ago, though it took me nearly 8 months to start it for the first time.

My current setup is what one would call, unnecessary complicated.
Due to the lack of a 4 GB SD card I decided to install the OS on a 4GB USB stick and use a 512 MB SD  card. Also I don't want to connect it to a screen, so I decided to install BerryBoot on the SD card and enable vnc remote management (with the router handing out a static IP) headless BerryBoot.

This worked very well, and allowed me to install Debian on the USB stick.

I got Debian running with remote login via ssh and murmur. Though it didn't want to upgrade properly and I couldn't get openvpn to work properly.

Therefore I deleted the Debian installation and installed Arch Linux through Berryboot (image from http://archlinuxarm.org/platforms/armv6/raspberry-pi), using these instructions which in short and updated are:

sudo kpartx -av archlinux-hf-2013-07-22.img
sudo mount /dev/mapper/loop0p5 /mnt
cd /mnt
sudo rm lib
sudo mv usr/lib lib
cd usr
sudo ln -s ../lib lib
cd /tmp
sudo mksquashfs /mnt Arch_Linux.img240 -comp lzo -e lib/modules
sudo umount /mnt 
sudo kpartx -d /dev/loop0


I made the Arch_Linux.img240 image on my Linux Mint system and copied it to a different USB stick, such that I could use the custom operating system in BerryBoot option.

This worked perfectly and I now had a system running Arch Linux.
I got rid of the root user, and added a normal user with access to run sudo.

Now I went ahead and installed murmur (mumble server) which runs, though it gives a warning at startup related to the qt4 package:

Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)"

In order to get it to work with openvpn, iptables needs to be configured:

sudo iptables -I INPUT -p tcp --dport 64738 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 64738 -j ACCEPT
sudo iptables-save > /etc/iptables/iptables.rules

The last line is to save the rules such that they are persistent on reboot.

Openvpn was set up according to NyxBox – OpenVPN Server on Raspberry Pi
 

Tuesday 18 June 2013

How to visulise the changes in a LaTeX file or project in mercurial

Using mercurial to keep track of changes and share a LaTeX project is very useful and I've had good use of it writing scientific articles with colleagues. The only problem I've found with this is that it is hard to visualise that changes made.  There is a tool for doing something similar,  latexdiff  though it does not integrate into mercurial. One integration for git can be found at Yngve's blog, though it only works for git.

Therefore I decided to write my own python program, using latexdiff,  for comparing changes across different mercurial revisions or the current change. This python program can be found on SourceForge under the project named Hg Diff Latex.
It requires latexdiff (should come with any normal latex installation) and python. It is designed to work on Linux, Mac and Windows, though I haven't had the time to test it thoroughly on anything else then Linux. It should be set as executable for the commands below to work (if not add python in front)


Help for the program can be found using

diffLatex.py -h

If you want to compare the current version in the repository with a previous one, here number 23, and display it in Okular the command would be

diffLatex.py -r 23 -o main.tex

where main.tex is the main file in you latex document.
If you instead want to use the viewer acroread the command would be

diffLatex.py -r 23 -v acroread main.tex

Comparing the changes currently made to the latest in the repository, and opening in Okular
 
diffLatex.py -o main.tex

A neat thing that can be done is to compare to old versions, old1 and old2, (remember to commit your changes before you do this) :

hg update -r old1 # Changing the repository state to old1
diffLatex.py -r old2 -o main.tex
hg update # To get back to the newest  

Here it doesn't matter if old1 is larger than old2, just keep track of what the colours represent.

If there are any issues or comments I would really  like to hear them either here, or on SourceForge.