2011-11-19

FreeBSD 9.0RC1 to RC2 upgrade

Finally had a little bit of time to deal with my laptop at home. As FreeBSD 9.0RC is out, I thought I'd give this a try by updating from 9.0 RC1.
Normally this works quite easily on FreeBSD by running the freebsd-update utility, but this time it failed.

So to get it work, see here.

In short:
# sed -i '' -e 's/=_/=%@_/' /usr/sbin/freebsd-update
# freebsd-update upgrade -r 9.0-RC2
 



2011-10-27

Import git to perforce

Import git to perforce

At work I have to use painforce, although I don't like it. So I decided to use it as kind of  a master repository for my git stuff. git-p4 is a python script that does most of what I want, however I wanted to keep the original commit date and hash. So here's a little patch to achieve this.
 
--- /usr/local/home/bjoern.henkel/git-p4.org    2011-10-27 11:56:05.351331262 +0900
+++ /usr/libexec/git-core/git-p4        2011-10-27 16:24:12.623302361 +0900
@@ -413,6 +413,14 @@
            continue

        logMessage += log
+
+    # I want to keep the original date when importing from git
+    logMessage += "\n"
+    logMessage += "Original commit date: "
+    cmd = 'git show -s --pretty="%ai (%ar) " ' + commit
+    logMessage += read_pipe(cmd)
+    logMessage += "commit: %s" % commit
+
     return logMessage

 def extractSettingsFromNotes(commit):

gitk in cygwin (with cygwin-ports)

gitk in cygwin (with cygwin-ports)

Recently I had problems with gitk not working. Turns out the fix for this is rather easy, see the diff below:

--- /home/bjoern.henkel/gitk.org        2011-10-26 15:44:27.096698500 +0900
+++ /usr/bin/gitk       2011-10-26 15:44:57.143573500 +0900
@@ -2367,7 +2367,7 @@
        }
     }

-    if {[info exists geometry(state)] && $geometry(state) eq "zoomed"} {
+    if {[info exists geometry(state)] && $geometry(state) eq "normal"} {
         wm state . $geometry(state)
     }

2011-10-18

Changing /etc/fstab with puppet and augeas

Changing /etc/fstab with puppet and augeas

Puppet Augeas documentation

My case: Add tmpfs

Trying with augtool, and breaking my head on how to add an entry at the end of the file, I realized eventually figured out, that you don't have to care at all with augeas, just add a 01 prefixed value and it will be added to the end.

So to add I use:

defvar fstab /files/etc/fstab
set $fstab/01/spec tmpfs
set $fstab/01/file /dev/shm
set $fstab/01/vfstype tmpfs
set $fstab/01/opt defaults
set $fstab/01/dump 0
set $fstab/01/passno 0
save

But what if the entry already exists?
Since in fstab the entries are just numbered, it took a while to figure out how to use the last() function.

This should work (e.g. change option)

set $fstab/*[spec = 'tmpfs'][file = '/dev/shm']/opt size
set $fstab/*[spec = 'tmpfs'][file = '/dev/shm']/opt/value 12G

This will only change/add the option size=12G, where spec equals 'tmpfs' AND file equals '/dev/shm'.

Then, all left to do was finding a rule for puppet to not add a new line on each run, that's done quite easily with 'match':

match *[spec='tmpfs'][file = '/dev/shm']

So in puppet it looks like this:

    augeas{"Add tmpfs for case ${caseusername}@${hostname}":
        context => "/files/etc/fstab",
        changes => [
            "set 01/spec tmpfs",
            "set 01/file /dev/shm",
            "set 01/vfstype tmpfs",
            "set 01/opt size",
            "set 01/opt value ${shmem}",
            "set 01/dump 0",
            "set 01/passno 0",
            ],
        onlyif => "match *[spec='tmpfs'][file = '/dev/shm'] size == 0",
    }

    augeas{"change tmpfs size for ${caseusername}@${hostname} to ${shmem}":
        context => "/files/etc/fstab",
        changes => [
            "set *[spec = 'tmpfs'][file = '/dev/shm']/opt size",
            "set *[spec = 'tmpfs'][file = '/dev/shm']/opt/value ${shmem}",
            ],
        require => Augeas["Add tmpfs for case ${caseusername}@${hostname}"],
    }

2011-10-11

64-bit or not

Creative way of figuring out if a system is 64-bit or not, for people who don't believe in "uname".
have_64bit_userland() {
  file -L /bin/sh | grep -q 64-bit
}

2011-09-24

Upgrading the sheevaplug

Upgrading the sheevaplug
Had to upgrade my parents plug.
The whole thing, uboot, distro, etc.
Thanks to this awesome guide everything went very smoothly.

2011-09-23

flexget + transmission + tvtorrents + CentOS 5

flexget + transmission + tvtorrents + CentOS 5
Part I: Get transmission installed

Add repository

in /etc/yum.repos.d/geekery,repo add:
[geekery]
name = geekery repository
baseurl = http://geekery.altervista.org/geekery/el5/$basearch
enabled = 1
protect = 0
gpgkey = http://geekery.altervista.org/download.php?filename=GEEKERY-GPG-KEY
gpgcheck = 1

install packages

sudo yum install transmission transmission-daemon transmission-cli transmission-common

Config

  • in /etc/sysconfig/transmission-daemon add the following line: (Change IP, passwords and path to what fit:s your need)
DAEMON_ARGS="-b -t -a \"192.168.*.*\" -e /var/log/transmission/transmission.log -u user -v password -w /incoming"
  • setup correct permissions for the download directory (/incoming)
$ sudo mkdir /incoming
$ sudo chown transmission:users /incoming
$ sudo chmod 770 /incoming
  • start the daemon
$ sudo service transmission-daemon start

Access through browser

Remote GUI

  • Get the binary here.
  • extract and run.

Alternatively Java GUI


Part II: Configure flexget
See the previous post to see how to get it installed on CentOS.

Requirements

I had to manually update the version of transmissionrpc:
sudo easy_install-2.6 transmissionrpc

Configuration

As the feeds on tvtorrent are already limited to the series you select, it is OK, to just get everything in the feed. Flexget will take care of not downloading duplicates (different quality). By default it will prefer the better quality.
Add the following to ~/.flexget/config.yml
feeds:
  feed_name:
    rss: <Your rss feed here>
    download: ~/torrents
    all_series: yes
    transmission:
      host: 192.168.0.5
      port: 9091
      username: bon
      password: <password>

Testing

You can check your settings for syntax by running:
flexget -v --check
For a dry-run, run:
flexget -v --test
If everything works OK, just put it in a cron-job to run every now and then.