Wednesday, January 29, 2014

Package caching for debian based distros

Most of our computers run on linux, actually on debian based distros like ubuntu. To make installing and updating faster we have an apt proxy installed.

An apt proxy fetches files from remote repositories when needed, and caches them for local use. So it also saves bandwidth, which was very important before we had a fiber channel connection.
There are different apt proxies available, like apt-cacher, apt-cacher-ng, squid-deb-proxy or approx, which is the one we are using. It's easy to set up and works very well.

$ apt-get install approx

and the config file is

/etc/approx/approx.conf:

ubuntu    http://archive.ubuntu.com/ubuntu
ubuntu-extras    http://extras.ubuntu.com/ubuntu
ubuntu-partner    http://archive.canonical.com/ubuntu
ubuntu-security    http://security.ubuntu.com/ubuntu
debian    http://ftp.debian.org/debian
debian-security    http://security.debian.org/debian-security


Usually you only need to add your repositories. Of course there are other things that can be changed, like the port, or debugging. Just see $ man approx
Once it's running you can set up the client side.

So edit /etc/apt/sources appropriately. It could look like this:

deb http://proxy:9999/ubuntu precise main restricted multiverse universe
deb http://proxy:9999/ubuntu precise-security main restricted multiverse universe
deb http://proxy:9999/secure precise-security main restricted multiverse universe
deb http://proxy:9999/partner precise partner

Then run
$ apt-get update

That's mainly it. By the way, there are two apt related packages, that are very helpful.

apticron - it keeps you informed by email, if updates are available.
cron-apt - it downloads packages to your machine, and even installs them if you configure it that way.

Monday, January 20, 2014

Backing up and restoring a cubieboard nand installation

Last time, I showed you how to run chrome browser on cubieboard in kiosk mode.

As we have several TVs with a cubieboard, I did not want to go through all these steps again and again. There is a rather simple way of cloning a nand image.

You will need a micro-SD card and install any linux on that. I used http://cubian.org/downloads/ for that.

So download the appropriate image, unzip it and install it on your sd card using:

dd if=cubian.img of=/dev/YOUR_DEVICE bs=4096; sync

Once done, put the SD card into your cubieboard and boot. The default credentials are cubie/cubie.

To create an image run:
dd if=/dev/nand conv=sync,noerror bs=64K | gzip -c -9 > /nandimg.gz



Later you can restore that image using on a new board
gunzip nandimg.gz; dd if=/nand.img conv=sync,noerror bs=64K of=/dev/nand

Be aware that you need to change a few settings if you are reusing this image on several boards:
hostname - /etc/hostname and or /etc/hosts
hwaddress - /etc/network/interfaces

Wednesday, January 15, 2014

Using the cubieboard (A10) to display class schedules and updates using chromium-browser in kiosk mode



First of all download an A10 image


The next step is to download and install LiveSuit (http://linux-sunxi.org/LiveSuit), which is an application to flash the NAND.


Start LiveSuite, select the downloaded image and press the FEL key when powering up (the FEL key is the one under the USB OTG port), The CPU automatically enters FEL mode. Livesuit will start to write the image to Nand on board.


After that, you will be able to log into your cubieboard, with the appropriate credentials. In my case linaro/linaro.
Depending on the image you used, you need to resize some partitions


sudo resize2fs /dev/nandc
sudo resize2fs /dev/nandd
sudo resize2fs /dev/nande
sudo resize2fs /dev/nandf


Now we are ready make changes and install software. These are the changes I made


1.) Change default password and root password using passwd
2.) Edit /etc/network/interfaces and set a fixed hardware address
           auto eth0
iface eth0 inet dhcp
   hwaddress ether xx:xx:xx:xx:xx:xx
You could use a generated mac address, which ifconfig will display.


3.) To enable autologin edit /etc/lightdm/lightdm.conf and add
autologin-user=<YOUR USER>
autologin-user-timeout=0


In a terminal run
sudo groupadd autologin
sudo gpasswd -a linaro autologin


4.) Install/uninstall software
sudo apt-get update
sudo apt-get install unclutter xvkbd -y icedtea-6-plugin vino x11-xserver-utils vino openssh-server
sudo apt-get remove xscreensaver


5.) To change the locale settings, run the following commands in a terminal
sudo locale-gen de_DE.UTF-8
export LANG=de_DE.UTF-8
export LC_ALL=de_DE.UTF-8
sudo update-locale
sudo dpkg-reconfigure locales


6.) reconfigure the time zone
sudo dpkg-reconfigure tzdata


7.) Modify your autostart. vi /etc/xdg/lxsession/Lubuntu/autostart


@lxpanel --profile Lubuntu
@pcmanfm --desktop --profile lubuntu
@/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
@xset s off
@xset s 0 0
@xset -dpms
@xset s noblank
@ntpdate 0.de.pool.ntp.org
@/usr/lib/vino/vino-server &
@chromium-browser --kiosk --incognito --disable-translate --allow-outadated-plugins --disk-cache-dir=/tmpfs --always-authorize-plugins http://yourwebsite


The xset stuff is there to disable any screen saving mode.
ntpdate updates your time. As an alternative you coud install ntp daemon (apt-get install ntp)
vino-server is a vnc-server, so i can have a remote look at the screen.
An alternative to vino is x11vnc (apt-get install x11vnc), which did not work due to a bug. (It crashed on connect).
The last line starts the browser in kiosk mode and opens a certain website.



8.) If you are using vino, make sure you set appropriate preferences using
vino-preferences


9.) I also had some issues with screen resolution, so i created a xorg.conf in /etc/X11
Section "Monitor"
       Identifier      "Monitor0"
       ModelName    "Monitor Model"
       DisplaySize     240 320
       Option          "DPMS" "false"
       Option       "UseEDID" "false"
EndSection
Section "Device"
       #Option "ShadowFB"      "true"
       Identifier  "Card0"
       Driver      "fbdev"
       Option  "fbdev" "/dev/fb0"
EndSection
Section "Screen"
       Identifier      "Screen0"
       Device     "Card0"
       Monitor     "Monitor0"
    DefaultDepth    24
    SubSection "Display"
           Depth           24       
       Modes   "1280x1024"
    EndSubSection
EndSection

10.) Last thing I did, was create a crontab, which shuts down the cubieboard, a few minutes, before the TV-screen turns off. As the board is hooked up to the TV usb, the TV will turn on the cubieboard again in the morning. Yes, the TV has a timer function, so it turns itself on automatically.