Friday 22 October 2010

Backups on Ubuntu One

Ubuntu One
2GB Might not seem like much, but is actually enough to store a few documents. There are some primitive command line utilities that can be used to perform some basic tasks. Once a folder has been created on the server, then simple commands can be used to keep them synchronised between machines that have subscribed to them. It is sort of tricky as the default behaviour is to subscribe to all folders. And as subscription requires a folder Id, unsubscribing to a folder before it gets synchronised is a bit of a pain.
Installation
Installation is very easy with:
apt-get install ubuntuone-client ubuntuone-client-tools
An example
Here is a simple Ubuntu One example to show how to:
  • start server and connect:
    u1sdtool --start
    u1sdtool --connect
    Then show current status with:
    u1sdtool --status
  • link a local folder to the server:
    u1sdtool --create-folder=[local_fully_qualified_path]
    Then to list folders on server:
    u1sdtool --list-folders
  • subscribe or unsubscribe from a folder on the server:
    First you need to get the Id of the folder. The simplest way to do this is to get a list of the folders. This will give you a folder and its associated folder id. This folder id is then used by the subscribe commands:
    u1sdtool --(un)subscribe-folder=[folder_id]
  • refresh a folder:
    This uses the folders path:
    u1sdtool --refresh=[local_fully_qualified_path]
  • disconnect and stop server:
    u1sdtool --disconnect u1sdtool --quit
All of this can be a bit tedious. Furthermore, it may take sometime to fully synchronise the folders. There are some options to show status, waiting and current transfers. Ubuntu One has some tools to help. Using ubuntuone-launch to start the daemon. Then use ubuntuone-preferences to start a passive synchronisation process. You can leave it running until it idles. You must be running Gnome services otherwise you'll get an error reporting:
gnomekeyring.IOError
If you are running Gnome and still get this error, then try:
gnome-keyring-daemon; ubuntuone-launch; ubuntuone-preferences

[Update] Ubuntu Netbook Remix - Tethering to iPhone

UNR 10.10 - Update on Tethering to iPhone
Like a few others, upgrading to Maverick Meerkat killed iPhone tethering. Actually I found that this occurred on most kernel upgrades. Luckily, the fix is simple. Recall, that normal installation is simply:
Set repositories:
sudo add-apt-repository ppa:pmcenery/ppa
sudo apt-get update
Then install the drivers:
sudo apt-get install gvfs ipheth-dkms ipheth-utils
Now, on an upgrade these are already installed, and even a re-installation failed:
sudo apt-get install --reinstall gvfs ipheth-dkms ipheth-utils
Though, this normally works on a kernel upgrade.
Instead, un-install then re-install. If the kernel isn't updated on the re-installation the chances are it hasn't worked.
sudo apt-get remove gvfs ipheth-dkms ipheth-utils
sudo apt-get install gvfs ipheth-dkms ipheth-utils

Saturday 9 October 2010

[Update] A Simple Reminder System

This is an update to my last post A Simple Reminder System
Scanning the technical news I recently came across: gcalcli. Can this be used with my reminder system? Well, yes it can! Very simply in fact. It took a short Bourne shell script which reads calendar entries forward from today, then post them to Google Calendars. This is the script:
#!/bin/sh
# Update Google calendar with local calendar.
#
# $Id: syncgcal.sh 706 2010-10-09 05:28:44Z frank $
echo -n 'Reading calendar events ...'
forwardDate=`/bin/date --date="+7 days" "+%Y%m%d"`
/usr/bin/calendar -t $forwardDate | while read entry
do
   /usr/bin/gcalcli quick "$entry"
done
echo ' done!'
exit 0
The trick used here is to check upcoming events for a fixed number of days forward.  If you use calendar -A then you'll get events repeated. This is a compromise: checking only a fixed number of days forward and posting items for that date only. What would be better, would be to identify changed entries and just posting them. To do this you need to have a additional data store of posted events and lots more code. Maybe next time. I will trial the current set-up and see how it goes.

The gcalcli command uses a Python style configuration file of ~/.gcalcli. This is where you can record user, password and calendar defaults for your Google calendar. Not surprising as gcacli is written in Python.
Finally, add a cron table entry:
@daily ~/bin/syncgcal | /usr/bin/mail -e -s "Google calendar updates" your_user@localhost
This will daily invoke calendar updates. The results are locally emailed back to you, which is useful for testing.

Saturday 2 October 2010

A Simple Reminder System

This is a continuation of my post on running a paperless office.
Ever faced with the problem of constantly forgetting important events, missing bill payments or forgetting anniversaries? Don't want to publish billing information onto an online calendar? This  simple email reminder system seemed the most versatile. This is how it works:
The solution centres upon the calendar(1) command from the bsdmainutils package. It takes a simple formatted text file as input, and displays events within a user specified number of days forward from today. The format is really easy maintain a list of birthdays, or of bills requiring payment. Create a file called ~/.calendar/calendar. The file will contain entries like:
#ifndef _calendar_frank_
#define _calendar_frank_
LANG=en_AU
#include <calendar.australia><calendar.australia>
#include <calendar.birthday><calendar.birthday>
#include <calendar.reminder><calendar.reminder>
#endif
And this is what a the calendar.australia file looks like:
/* Australian holidays $FreeBSD$ */
#ifndef _calendar_australia_
#define _calendar_australia_
LANG=UTF-8
/* Australia */
Jan 26 Australia Day Holiday (Australia, except NSW, Vic)
Mar/SunLast Daylight Savings Time ends in ACT, NSW, SA, TAS and VIC.
Apr 25 Anzac Day (Australian and New Zealand Army Corps) Day (Australia)
Jun/MonSecond Queen's Birthday Holiday (Australia, except WA)
Oct/SunLast Daylight Savings Time starts in ACT, NSW, SA and VIC.
/* Victoria */
3/MonSecond Labour Day (Vic)
Nov/TueFirst Melbourne Cup (Vic)
#endif
In the same fashion, the calendar.reminder is formatted with a month, day and finally a description. The descriptions follow a standard pattern so that you can quickly identify billing information. It also means that the reported entries are standardised.  My suggested formatting is:
Mon dd Bill Title: bill code, Reference: 9999, Amount: $000.00, Receipt:
When the bill is paid, append the receipt id, then comment out the line.  Commenting it out prevents you being reminded for a bill you've already paid:
/* Feb 23 Telephone: TLS123, Reference: 456, Amount: $11.30, Receipt: 7890123 */
So a single reminder file contains current and historic information. Which is useful if you wish to see how bills change over time. 
Finally, to activate an automatic reminder via email, add the following entries to crontab(5). The following will give me warning of events 7 days in advance:
@reboot /usr/bin/calendar -A 7 | mail -e -s "Reminders from Calendar" name@localhost
@daily /usr/bin/calendar -A 7 | mail -e -s "Reminders from Calendar" name@localhost
That is all there is too it!  Enjoy!  Please let me know if you have any suggestions or corrections.