Upstart script with command in screen as specified user

My brother runs his own minecraft server. He would like to have it started after boot up, inside a screen, as his own user. The way, he can reattach the screen and do administration on the minecraft server. The server runs a minimal install of Debian.

Add this to rc.local

# Upstart for minecraft server
# change directory
cd /home/minecraft
# start server inside screen as user minecraft
su minecraft -c "screen -d -m java -Xms950M -Xmx950M -jar minecraft_server.jar nogui"

Make rc.local executable

chmod +x /etc/rc.local

If “-d -m” is omitted in the screen command, it will try to attach to a tty. This will fail, either because it does not have access to root’s tty, or because no tty exists.

HP LaserJet 1020 Ubuntu 10.04 Lucid Lynx

Same story as always; updating system breaks printing with CUPS. Not sure why, but seems like when using foomatic, no firmware is uploaded to printer.

Remove printer from cups.
Install hplip:

sudo apt-get install hplip hplip-data hplip-gui
sudo hp-setup
sudo hp-plugin

If “sudo hp-plugin” fails, look for in /root, and run it with “sudo /root/”. After it completes, check that you’ve got firmware files in /usr/share/hplip/data/firmware. Then run hp-firmware:

sudo hp-firmware

If successful, you should now here the printer fires up.

Automated encrypted backup with Back In Time

Install encfs and zenity:

apt-get install encfs zenity

Create encrypted directory:

cd /whole/path/to
mkdir .backintime_encfs
mkdir backintime
encfs /whole/path/to/.backintime_encfs /whole/path/to/backintime

If you would like support for hard links(backintime incremental backups), choose the standard mode, not paranoia mode.

Script to mount and run backup:

# Script to mount encrypted directory and run backup.
extpass="zenity --title 'Encrypted backup' --entry 
--text 'Please type password for encrypted backup storage' --hide-text"

#set display for password prompt
export DISPLAY=:0.0
#check if directories exists
if [ -d $enc_path/$enc_directory ] && [ -d $enc_path/$directory ]
  # check if encrypted directory already is mounted
  mountpoint $enc_path/$directory > /dev/null
  if [ "$?" != "0" ]; then
    encfs --extpass="$extpass" $enc_path/$enc_directory $enc_path/$directory
  # check if mount was successful
  mountpoint $enc_path/$directory > /dev/null
  if [ "$?" = "0" ]; then
     echo "Running backup..."
     nice -n 19 /usr/bin/backintime --backup-job >/dev/null 2>&1
     # optional umount of encrypted storage:
     # fusermount -u $enc_path/$directory
     exit 0
    echo "Unable to mount encrypted directory"
    exit 1
  echo "Encrypted directory not found"
  exit 1

Disable schedule in Back In Time, and add script to crontab:

crontab -e
# add this line and save
@hourly /usr/local/bin/encrypted_backup_script


NFS4, hard links and backintime

After a kernel update, I noticed my backups in backintime took very long time. The backups also didn’t increment, every single backup used the same space -> several GB. Incremental backups should only take some MB, the amount of data that have been changed.

First I thought this was a bug in BIT, then zfs-fuse, but the error was in NFS4. When logged in to the server, I could create hard links. NFS4 could not do hard links. If I changed mount options to NFS3, hard links worked. But I don’t want to use NFS3 since NFS4 got username/id linking, so you don’t need the same userids on all of your systems. Seems like this is also why hard links didn’t work. Not sure if the error is because the new kernel does not enable idmapd by default, or if /etc/default/nfs-common was changed in the update. Anyhow, be sure that NEED_IDMAPD equals to yes in /etc/default/nfs-common on both server and clients.


Changing margin in the middle of Latex-document

Linux Mint 10 includes geometry.sty version 4.2. In geometry.sty version 5, you get some extra snacks, like changing page layout mid-way.

Install the latest version:

tex geometry.dtx
tex geometry.ins
sudo mv /usr/share/texmf-texlive/tex/latex/geometry/geometry.sty /usr/share/texmf-texlive/tex/latex/geometry/geometry.sty.old
sudo cp geometry.sty /usr/share/texmf-texlive/tex/latex/geometry

Latex code:



matlab and Linux Mint 10

Matlab 7.11(R2010b) did not play well with my Linux Mint. First off, it would not recognize special characters in my language (æøå – Norwegian). This is because Matlab does not recognize utf8 in small caps.

LANG=nb_NO.UTF-8 matlab

Second, Matlab would not start from a desktop shortcut. Found solution here:

LANG=nb_NO.UTF-8 matlab -desktop

Or put it in a file and make it executable:

sudo su
echo -e '#!/bin/bashnLANG=nb_NO.UTF-8n/opt/MATLAB/R2010b/bin/matlab -desktop' > /usr/local/bin/matlab
chmod +x /usr/local/bin/matlab

Dell Inspiron 1525 – Power Adapter not recognized

My Dell Inspiron stopped charging battery some months ago. BIOS stated that the power adapter could not be found. Still, the machine was powered by the mains, but not charging battery. I ordered me a new power adapter from ebay, arrived today, but machine still not charging.

I googled, and a Dell support article recommended updating BIOS. Still nothing. Googled some more and found this:

Seems to be a communication problem between the charger and the mother board. The communication goes over the thin middle pin inside the power jack.

I disassembled the computer, taking out the power jack board. Ohmed between the middle pin, and the contact going to the mother board. No contact with any pins. Re-soldered the middle pin of power jack. Ohmed again, with contact between power jack middle pin and the connector. Reassembled. Battery charging again!

You could also buy new power jack boards on ebay: