Update ddclient

An older script that I use on OpenBSD to update ddclient hostnames. The script should run with minor modifications on Linux.

#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin

IPFILE=/root/scripts/ipcheck.ip
INTF=tun0
MAILRCPT="yourmail"
MAILSUBJECT="DDclient update"

IP=`ifconfig $INTF | grep "inet " | grep -v inet6 | awk '{print $2}' |
sed 's/addr://'`

if [ -f $IPFILE ]; then
 OLDIP="`cat $IPFILE`"
fi

if [ "$IP" != "$OLDIP" ]; then
 echo $IP > $IPFILE
 /usr/bin/logger -t ipcheck_ddclient new IP address -- changed to $IP
 /sbin/ifconfig -a | mail -s $MAILSUBJECT $MAILRCPT
 /usr/local/sbin/ddclient -daemon=0 -syslog -use=ip -ip=$IP
fi

If you are unable to get your public IP from a local interface then you can use dyndns.org.

wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

Use Dropbox with encrypted volume for backups

I use Dropbox to have online backups of my files. Dropbox already provides a good set of protection mechanisms (Two-step verification, …). If you need an additional level then Boxcryptor is worth having a look.

Unfortunately Boxcryptor is not available on Linux but it is compatible with encfs. The blog of Boxcryptor has a post describing in details how you can setup encfs on Ubuntu.

The blog post lacks some useful additional details.

Have encfs available for every user

By default only root users are allowed to use encfs. You can allow non-root users to use encfs.

Modify the /etc/fuse.conf file so that the last line “user_allow_other” does NOT have a leading hash. Save and exit. You do not need to reboot.

Add the non-priv user to the group fuse

You can then use encfs:

$ encfs /home/joeuser/encrypted_data /home/joeuser/decrypted -- -o allow_other

Sync files automatically

I sync my files via rsync from crontab. Before running the rsync I verify if the encrypted volume is mounted.

#/bin/bash

if ! mount | grep encfs >/dev/null; then
 echo "ENCFS not mounted"
else
 rsync -artvuc --delete /home/joeuser/files/ /home/joeuser/decrypted/files
fi

Upgrading Redmine 1.3 to 2.2

The documentation of Redmine describes the upgrade process. I upgraded from Redmine 1.3.1 to Redmine 2.2.2. On an older Ubuntu (10.04.4 LTS) the upgrade steps described in the documentation were not sufficient.

Extract the latest redmine file in your web root. I use a symlink pointing redmine to the latest version. This allows you to keep different version and provides an easy way to switch between versions. You then have to copy the different configuration files (database, configuration) from the ‘old’ setup to the ‘new’ setup. Do not copy the settings.yml file.

cp redmine-1.3.1/config/database.yml redmine/config/
cp -r redmine-1.3.1/files redmine/

The first error message is because of bundle.

rake aborted!
no such file to load -- bundler/setup
gem install bundler
bundle install

The bundle command failed because of libmagick problems. It was not a requirement for older Redmine versions but without the package (and the libraries) I couldn’t get the upgrade to continue.

checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
apt-get install librmagick-ruby
apt-get install libmagick9-dev

Restart the bundle install.

bundle install

Perform the ‘normal’ migration steps.

rake generate_secret_token
rake db:migrate RAILS_ENV=production
rake redmine:plugins:migrate RAILS_ENV=production 
rake tmp:cache:clear
rake tmp:sessions:clear

Restart Apache (and Passenger). The next error was Ruby (browser) complaining that there was no dispatch file.

no such file to load -- dispatcher

To solve this you have to upgrade Passenger manually.

gem install passenger
passenger-install-apache2-module

Change these configuration files

in /etc/apache2/mods-enabled/passenger.load
  LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.19/ext/apache2/mod_passenger.so

in /etc/apache2/mods-enabled/passenger.conf
  PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.19
  PassengerRuby /usr/bin/ruby1.8

Restart Apache and Passenger. Log in to Redmine and go to the Administration part and review the roles and configuration.

Have Redmine installed for you

I can help you if you need help installing or maintaining Redmine.