ARD Mediathek offline viewing on Ubuntu

Since I am a bit of a sucker for German “Krimis” as well as some their excellent documentaries I like to watch ARD Mediathek IPTV. However there are several problems with this when you live at the opposite side of the world. ARD has a block for any films that are 15+ years outside of 20.00h-6.00h GMT+1. Which makes it pretty much impossible to watch at a reasonable time in Australia. I also like to watch these things on the plane which requires download of the media files.

Install JSON Parser

sudo apt-get install jq

Download script

wget https://github.com/leogaggl/media/raw/master/download_mediathek.sh
chmod +x download_mediathek.sh

Usage

./download_mediathek.sh -f save_as_filename.mp4 -q 3 MEDIATHEK-URL

The -f and -q parameters are optional.
-f filename.mp4 (or full path + filename to save in different directory). Defaults to original filename
-q quality setting from 0 to 3 (where 0 is lowest and 3 highest quality). Defaults to highest quality

Please leave a comment if you find any issues or log an issue on GitHub.

NOTE (2014-07-06): If you are only interested in the Tatort series I suggest you look at this script by Felix Knecht (see comment below)

Ubuntu 14.04 Amazon EC2 Cloud Desktop using LXQT

Using Amazon EC2′s free usage tier to host your own cloud desktop is a very economical way to to have a desktop at hand anytime you can not be near one. Since I quite often use Chromebooks these days when on the road this is a particular handy way should I need a full desktop for certain tasks.

Since Ubuntu 14.05 is my default desktop on my normal hardware I obviously want to have my cloud desktop running the same underlying OS. However I don’t think running Unity as the desktop interface would be appropriate via a low-bandwidth remote desktop connection. For this reason I chose LXQT. If you need total stability you probably should go for the more mature LXDE instead, but I have already tried LXQT on an old EEE PC and was very impressed by the speed and low resource usage.

Provision Ubuntu 14.04 LTS EC2 Instance

EC2 Choose Image

Instance details

  1. Connect to AWS Console and go to EC2 Service
  2. Choose OS Image: “Ubuntu Server 14.04 LTS” (see screenshot)
  3. Choose a “Micro Instance” if you want to use Amazon’s Free Usage Tier
  4. Choose Instance details – the defaults will generally be fine
  5. Add Storage (I generally add a separate Volume for /home but default should do)
  6. Tag instance (just give it a name to that makes sense to you in the console if you have more than one)
  7. Configure Security Group – I only set SSH which is the default (see Firewall config below). Add any other ports needed
  8. Review & Launch the instance. You need to choose your RSA Access Keys in this step. If you haven’t got any and download. DO NOT LOOSE the private keys or you will not be able to connect.

Setup Desktop & VNC

Connect via SSH to the EC2 Instance you just created (using the IP in the control panel and your RSA Key)

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:lubuntu-dev/lubuntu-daily
sudo add-apt-repository ppa:gilir/q-project
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lxqt-metapackage lxqt-panel vnc4server

Start VNC server under the desired user account. This will create the desired configuration files. Kill after the startup process is finished.

vncserver
#after successful start
vncserver -kill :1

Edit xstartup files

vim ~/.vnc/xstartup
Paste the following:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
exec openbox-session &
startlxqt &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &

Create startup script

sudo vim /etc/init.d/vncserver
Paste the following:
#!/bin/bash
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: VNC Server Startup Script
# Description: Author: Leo Gaggl (www.gaggl.com)
### END INIT INFO
unset VNCSERVERARGS
VNCSERVERS=""
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$"VNC server"
start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Starting $prog: "
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
DISP="${display%%:*}"
export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"
su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $"Shutting down VNCServer: "
for display in ${VNCSERVERS}
do
export USER="${display##*:}"
if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then
echo -n "${display} "
unset BASH_ENV ENV
export USER="${display##*:}"
su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1
fi
done
echo -e "\n"
echo "VNCServer Stopped"
}
case "$1" in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

Mark the startup script as executable and create the config file for the startup script.
sudo chmod +x /etc/init.d/vncserver
sudo mkdir /etc/vncserver
sudo vim /etc/vncserver/vncservers.conf

Paste the following:
VNCSERVERS="1:USERNAME"
VNCSERVERARGS[1]="-geometry 1024x768"

update-rc.d vncserver defaults 99

Start the VNC Server

sudo /etc/init.d/vncserver start

Firewall configuration

By default VNC will use port 9501 (and subsequent ports for each session). Since VNC password authentication is generally very weak I personally do not expose this port through the firewall. I use SSH port forwarding to tunnel the VNC port through SSH (encrypted) which means only the SSH port is open and can be properly secured.

ssh -L 5901:localhost:5901 -i /path/to/your/aws/keyfile.pem YOUR.EC2.IP.ADDRESS

You should then be able to access VNC via localhost:

VNC Viewer

Hopefully you should see the LXQT Desktop:

Ubuntu LXQT

Upgrading Nokia X to CyanogenMod 11 (via Ubuntu)

The Nokia X seems to be a nice piece of hardware for just around $125 AUD. Nothing spectacular in terms of computing power, but much better build quality than your average cheap Chinese Android clone. I have always been a fan of Nokia hardware until they decided to commit suicide by firstly adding CEO Stephen Elop and ditching all of their software for Windows Mobile.

The problem with the device out of the box is that is has a horribly butchered version of Android. And by horribly I mean way worse than the usual bloat and crapware that poor Samsung, HTC or Sony users are normally subjected to. Hopefully this is only Nokia’s first step to a more open platform, but I wouldn’t hold my breath on that one.

Before committing to buy this device I made sure that I could flash it to CyanogenMod as soon as it arrives. Sidenote: I purchased from Mobicity AU – which turned out to be a big mistake. Do yourself a favour and go somewhere else unless you have weeks to wait.

Nokia X - CyanogenMod 11

Boot Mode – Nokia X

Nokia Recovery Mode:

1. Turn off your device
2. Press Volume + and Power Button 15 seconds

Dependencies

If you haven’t got the Android SDK or tools yet you need to install

sudo apt-get install android-tools-adb android-tools-fastboot

USB Configuration

sudo vim /etc/udev/rules.d/51-android.rules
#add the following line
SUBSYSTEMS=="usb", ATTR{idVendor}=="0421", MODE="0666", OWNER="plugdev"
sudo service udev restart

vim ~/.android/adb_usb.ini
#add at the end of the file
0x2207

sudo adb kill-server
sudo adb devices

Rooting the device

Download ClockWorkMod Recovery (or TWRP if you prefer).

http://forum.xda-developers.com/showthread.php?t=2703708

Check USB debugging in “Settings –> Developer Options” (it seems that the NokiaX has debugging enabled out of the box)

Boot into Recovery (see above)

sudo adb reboot bootloader
sudo fastboot -i 0×0421 flash recovery cwm-6048-normandy.img
sudo fastboot reboot

Installing CyanogenMod 11

Please note that currently this is not an official CM release but an unofficial port, however CM has already committed to taking this device onboard as an officially supported one in the near future.

EDIT 2014-06-17: WIFI is currently not working which should be a showstopper for day-to-day use.

Boot into Recovery (see above) – this should now be CWM Recovery rather than the previous Android Recovery.

Download files:
CM 11 ROM for Nokia X (Android 4.4.2)
Google Apps for CM 11

In CWM recovery, select “Data Wipeout / Factory reset” option and wipe the data.
Select “Wipe Dalvik cache” from the Advanced Option
Select “Install ZIP –> Install ZIP from sideload”

sudo adb sideload cm-11-20140426-UNOFFICIAL-normandy.zip

Select “Reboot system now”

Note: the reboot can take about 1 minute to get started due to a bug in the current CWM Recovery.

Enjoy !

Upgrade Rikomagic MK902 Android MiniPC from Ubuntu

If there would be an Oscar for the WORST firmware upgrade procedure (and associated drivers, documentation and general quality of software) Rikomagic should win this by a country mile !

Rikomagic MK902

Since all the information I found on the interwebs said Linux was not supported I ended up borrowing friends notebooks (as I don’t own any Windows machinery anymore). My main Toshiba Ultrabook seemed to have issues with picking up the USB from a Windows Virtual Machine). After not being able to get the absolute crap USB drivers that come with the firmware download with any of the machines (Vista & Win7_64) I was ready to throw in the towel and put the purchase of this unit (in hindsight I would not do it again anyway) down as a total waste.

I tried a last search on upgrading using Linux it turns out there was a very recent Rockchip Linux Upgrade Tool release.

Download Upgrade Tool

http://dl.radxa.com/rock/tools/linux/Linux_Upgrade_Tool_v1.16.zip

Dependencies

If you haven’t got the Android SDK or tools yet you need to install

sudo apt-get install android-tools-adb android-tools-fastboot

USB Configuration

sudo vim /etc/udev/rules.d/51-android.rules
#add the following line
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2207", MODE="0666", GROUP="plugdev"

Restart udev
sudo udevadm control --reload-rules

vim ~/.android/adb_usb.ini
#add at the end of the file
0x2207

Restart the adb server

adb kill-server
adb start-server

You should be able to test with
adb devices

The output should be like the following:

adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
0123456789ABCDEF recovery

Please note: for adb to recognise the device it needs to be booted in recovery mode (as per the instructions in the so-called “documentation” from Rikomagic).

Boot into recovery mode

  1. Plug in USB Male-to-Male connector into the port marked “Slave” – not the other 3 hubs
  2. Press the “Reset” button using a paper-clip or similar pointy object (I used a letter opener which at times I would have loved to use on whoever came up with the crap Windows-only drivers and wasted hours of my life I will not get back… :P )
  3. After 3-5 seconds release reset button and plug the other end of the USB Male-to-Male connector into the Ubuntu box.

Upgrading

This bit took me a little while to work out. Turns out the device was in recovery mode and for the firmware upgrade process needs to be in bootloader mode.

Boot Device in Recovery Mode

Set the device into bootloader mode with adb.

adb reboot bootloader

Testing the bootloader mode

sudo ./upgrade_tool

./upgrade_tool List of rockusb connected
DevNo=1 Vid=0×2207,Pid=0x310b,LocationID=10c Loader
Found 1 rockusb,Select input DevNo,Rescan press ,Quit press :

Run the final upgrade of the downloaded image.

sudo ./upgrade_tool uf RKM_MK902_4.4.2_20140515.img

Helpful Resources

Thanks to the respective authors !

http://wiki.radxa.com/Rock/flash_the_image#Linux
http://www.cnx-software.com/2013/11/19/how-to-flash-rockchip-rk3066-rk3188-firmware-in-linux/
http://linux-rockchip.info/mw/index.php
http://www.rockchipfirmware.com/developer-tools

NOTE: If you haven’t bought this device yet and you are thinking of it – my advise is have another look somewhere else unless you have a lot of time AND are a very patient person …..

Install Google Earth on Ubuntu 14.04

Trying to install Google Earth on Ubuntu. You could just download the .deb file and run dpkg command, however I prefer to use it via a repo to make sure upgrades are installed as part of the system upgrades.

Google Earth

Google Earth Screenshot

http://www.google.com/earth/download/ge/

Google Keys

Note: this should not be necessary if you have use the GoogleTalk plugin or similar package from the Google DEB Repo

cd /tmp/
wget https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo apt-key add linux_signing_key.pub
rm linux_signing_key.pub

Add Google Earth Repo

sudo vim /etc/apt/sources.list.d/google.list
#add the following line
deb http://dl.google.com/linux/earth/deb/ stable main

sudo apt-get update
sudo apt-get install google-earth-stable

NOTE: While this should be enough on 32bit versions of Ubuntu 14.04 unfortunately it turns out that there is a dependency problem with the 64bit version

Fix 64bit dependency issues

sudo apt-get install libc6:i386 lsb-core

The problem is even after the installation of the i368 libraries the .deb file from Google will still not install on 14.04 due to the missing dependency ia32-libs (which was removed). My solution was to download the 64bit .deb file from the link above and extract to a temporary folder and repackage on current system (without ia32-libs). If you find a more efficient way please let me know in the comments.

cd ~/tmp
wget http://dl.google.com/dl/earth/client/current/google-earth-stable_current_amd64.deb
mkdir google-earth-stable_current_amd64
mkdir google-earth-stable_current_amd64/DEBIAN
dpkg-deb -x google-earth-stable_current_amd64.deb google-earth-stable_current_amd64/
dpkg-deb -e google-earth-stable_current_amd64.deb google-earth-stable_current_amd64/DEBIAN
dpkg -b google-earth-stable_current_amd64
sudo dpkg -i google-earth-stable_current_amd64.deb
rm -rf google-earth-stable_current_amd64*

You should now be able to run

google-earth

Android SDK issues on Ubuntu 14.04 64bit

Since the upgrade to Ubuntu 14.04 (Trusty Tahr) I have had issues running the Android SDK Tools. For example this error:

./adb
bash: ./adb: No such file or directory

Check the multi-arch architectures installed on the system.

sudo dpkg --print-architecture

Mine only showed ‘amd64′. Turns out you need to add the i386 architecture and install libc6:i386,libncurses5:i386,libstdc++6:i386 library packages.

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
sudo ./adb

LXQt – extending the life of my trusty old EEE PC (even further)

My old Asus EEE PC 900 is the oldest piece of hardware I own. With an old Intel Atom processor and 1GB of RAM it’s never was the fastest kid on the block (in fact I never considered the Windows XP version of the same unit usable as it was very sluggish). However after owning it for nearly 7 years I am very surprised I can still use it. Granted I only use it occasionally when I am at home, but thanks to LXDE it was still usable. I recently learned that LXDE is merging with the Razor-Qt project (great idea!) to create the combined LXQT – an ultra-low resource window manager.

Warning: LXQt is still considered a work in progress. So probably not a good idea on your prime work machine.

I started with a clean re-install of LUBUNTU LTS 14.04 – to add LXQt you need to add the lubuntu-daily PPA.

sudo add-apt-repository ppa:lubuntu-dev/lubuntu-daily
sudo add-apt-repository ppa:gilir/q-project
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lxqt-metapackage

Log out and log in back to LXQt desktop environment. Voilà !

LXQT Screenshot

LXQT Screenshot

After using it a little while it really is a joy to use and extremely responsive even on such a resource constrained old unit.

Great work !

Synology OpenVPN connection from Android

Connecting securely to your home network has always been a bit of a challenge since common home ADSL routers not normally contain any VPN Servers (those which do contain such are generally PPTP servers which I would hardly call secure these days). Which is probably a good thing as they would be horribly out of date considering the firmware release policies of retail router manufacturers. You could run/maintain your own dedicated server, but for most home networks that is overkill and out of the technical depth of most hobbyists. However NAS Appliances are becoming more useful in home networks for storage and other common tasks. I have had good experiences with Synology NAS devices over a number of years and the latest iteration also has a very useful VPN Server package available based on OpenVPN (as most Synology Apps are common Open Source components).

Server Requirements

This is a very straight forward procedure via the Synology Web UI (http://www.synology.com/en-uk/support/tutorials/459#t3.2)

Synology Openvpn

  1. Installing the VPN Server via Synology Package Manager
  2. Enabling OpenVPN Server
  3. Export the certificate using the button “Export configuration” (openvpn.zip) and extract the CA Certificate file (ca.crt)
  4. Forward UDP Port 1194 from your modem/router to the Synology NAS
  5. Make sure your Diskstation user account has OpenVPN privileges

Android Client Configuration

This part turned out a little more difficult than I expected. Initially I tried the “OpenVPN Connect” app by OpenVPN.net the makers of OpenVPN. However this seems to have no facility to edit the configuration and would not work at all from the imported config file.

The OpenVPN client that works well for me is OpenVPN for Android (https://play.google.com/store/apps/details?id=de.blinkt.openvpn)

  1. Transfer the CA Certificate (ca.crt) extracted in the previous step to the sdcard of your Android device
  2. Install the “OpenVPN for Android” app from the Google Play Store
  3. Open the “OpenVPN for Android” app, touch the + icon in the bottom left corner of the screen to add a profile
  4. Touch “Basic”
    1. Enter profile name and server address (Static IP Address or DynamicDNS of your modem/router)
    2. Touch the Select button for the CA Certificate
    3. Navigate to the file ca.crt on your sdcard and select the file
    4. Fill in the username and password of the Diskstation user with OpenVPN privileges
    5. Touch the back softkey or button of your phone
  5. Touch “IP and DNS”
    1. Check Override DNS settings by Server (Synology’s OpenVPN implementation currently does not support pushing servers)
    2. Google’s public DNS servers are the default and should work for most users)
    3. Touch the back softkey or button of your phone
  6. Touch “Authentication/Encryption”
    1. Uncheck Expect TLS server certificate
    2. Touch the back softkey or button of your phone twice to return to the app’s Profiles overview page
  7. Touch your profile’s name to connect (the icon with the sliders on the right allows to edit the profile)

Voila! Your Android device should now securely connect to your home network!