Categories: , , ,
Posted by: bjb

I apt-get upgraded, and then apt-get using apt-cacher didn’t work any more. It seems if you have a perl IPv6 library installed (IO::Socket::INET6), apt-cacher will assume you have deployed IPv6 and it will make an IPv6 only connection for listening.

To make all your services obtain IPv4 address along with IPv6 ones, as root “echo 0 > /proc/sys/net/ipv6/bindv6only” and edit /etc/sysctl.d/bindv6only.conf to contain 0 rather than 1. Then restart your service(s).

Or if you do have IPv6 running locally, you can change your apt sources.list file (/etc/apt/sources.list) to refer to ipv6-localhost instead of localhost:

deb     http://ip6-localhost:3142/debian.mirror.iweb.ca/debian/ unstable main contrib non-free
deb-src http://ip6-localhost:3142/debian.mirror.iweb.ca/debian/ unstable main contrib non-free

(other distro’s might use another name like localhost6. Look in your /etc/hosts file for the right name.)

Another gotcha: If you install apt-cacher-ng, and you already have apt-cacher running, then apt-cacher-ng will attach to the remaining free interface (the IPv4 one) and apt-cacher will still be running on IPv6. The two packages don’t conflict. Yeargh. I can’t wait to see the cache corruption … Ah, no cache corruption. It starts its own cache — from scratch. Well better that than corruption I guess. But, even better to be running only one of them on all listening ports.

And another gotcha: Installing apt-cacher-ng might end up adding a proxy config to your apt config like so:

/etc/apt/apt.conf:  Acquire::http::Proxy "http://aa.bb.cc.dd:3142";

so then if you use urls as above, you would have specified the proxy twice: once in the url and once in the apt.conf file. Apt then complains with:

Failed to fetch http://aa.bb.cc.dd:3142/volatile.debian.org/debian-volatile/dists/lenny/volatile/contrib/source/Sources.gz  403  URL seems to be made for proxy but contains apt-cacher-ng port. Inconsistent apt configuration?

The fix is to remove the proxy either from apt.conf or from the sources.list entries. Note that the proxy might have been put in /etc/apt/apt.conf.d/01proxy or something like that instead.

Well that was a lot more exciting than I’d hoped for.

Categories: , , ,
Posted by: bjb

The exim4 config file is a bit annoying because it is hard to know what statements are assignments and what statements are conditions. Below, the debug_print, driver, and data statements (in the hub_user route) are assignments, while the domains and check_local_user statements are conditions. Note how the config file designer helpfully mixed them together.

hub_user:
  debug_print = "R: hub_user for $local_part@$domain"
  driver = redirect
  domains = +local_domains
  data = ${local_part}@DCreadhost
  check_local_user

hub_user_smarthost:
  debug_print = "R: hub_user_smarthost for $local_part@$domain"
  driver = manualroute
  domains = DCreadhost
  transport = remote_smtp_smarthost
  route_list = * DCsmarthost byname
  host_find_failed = defer
  same_domain_copy_routing = yes
  check_local_user
.endif

Anyway, to help with debugging exim4 routers, you can use the -bt option to exim4:

blueeyes:~# exim4 -bt bjb bjb@localhost bjb@blueeyes
R: system_aliases for bjb@linuxbutler.ca
R: userforward for bjb@linuxbutler.ca
R: procmail for bjb@linuxbutler.ca
bjb@linuxbutler.ca
  router = procmail, transport = procmail_pipe
R: system_aliases for bjb@localhost
R: userforward for bjb@localhost
R: procmail for bjb@localhost
bjb@localhost
  router = procmail, transport = procmail_pipe
R: system_aliases for bjb@blueeyes
R: userforward for bjb@blueeyes
R: procmail for bjb@blueeyes
bjb@blueeyes
  router = procmail, transport = procmail_pipe
blueeyes:~# 

Note to self: “satellite” mail type is for machines whose mail is forwarded to another machine. Use “smarthost” for machines on which I actually read mail.

Categories: , , ,
Posted by: bjb

Handy quick conversion for timestamps in Nagios or unix logs: time.localtime (time.time);

eg:

bjb@bjb-pc:~/work/redmine/redmine-abitibi/app/views/mailer$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.time
<built-in function time>
>>> time.time ()
1284568746.503253
>>> time.localtime (1284523200)
(2010, 9, 15, 0, 0, 0, 2, 258, 1)
>>> time.localtime (1284520137)
(2010, 9, 14, 23, 8, 57, 1, 257, 1)
>>> 
Categories: ,
Posted by: bjb

Both before and after upgrading byteflow to use django 1.2, one thing that wasn’t working is postimage. The most recent problem was the link to post an image (in the admin page for creating or editing a blog post) was completely missing (whereas before it was present but malfunctioned).

The reason it was missing was that the javascript to create that link, in static/js/postimage.js, failed on line 42, in the showLinkFor function. It failed on

elem.previousSibling.appendChild(document.createElement('br'));.

I fixed it by inserting the link before the blog text instead of after the previous node’s contents:

    //  showLinkFor: function(elem) {
    //      elem.previousSibling.appendChild(document.createElement('br'));
    //      elem.previousSibling.appendChild(this.getLink(elem.id));
    //  },

    showLinkFor: function(elem) {
        var parent = elem.parentNode;
        var mybr = document.createElement('br');
        var myid = this.getLink(elem.id);
        parent.insertBefore (myid, elem);
        parent.insertBefore (mybr, elem);
    },

I have a non-standard URL_PREFIX of bjb/ and postimage didn’t play nice with that. I hard-coded my URL_PREFIX into the postimage.js file:

    getLink: function(id) {
        var link = document.createElement('a');
        link.setAttribute('href', '/bjb/admin/postimage/attach/?for=' + id);
        ...

Not elegant, but it got me past that problem. The next problem was that the list of files was empty. I set the POSTIMAGE_ROOT to point to a directory on the server machine with pictures in it, and then the list was not empty.

But it wasn’t full of all the pictures in that hierarchy either … that was just a file permission problem (web server couldn’t read some of them).

So now I can use postimage. It doesn’t do quite what I expected. What it does is allow you to choose among pictures on your server for inclusion into your blog. It doesn’t let you preview them. All it does is give you a list of files, and then put a link to the most recently chosen file in your blog text. You can call it over and over and it will add more image links. It looks like it can take the render method into account — there is a choice of markdown, html, rst. But, that choice was in the source code … not sure if it will detect your render method automatically.

I expected to be able to upload pictures to the blog … oh well. I guess the way postimage works is safer. It doesn’t put files up there for you — it assumes you have put them up already — into a “POSTIMAGE_ROOT” directory — and just accesses what is already there.

Categories:
Posted by: bjb

Before:

Image

During (1):

Image

During (2):

Image

During (3):

Image

During (4):

Image

During (5):

Image

Look Ma! No load-bearing walls! … now how do you put this thing back together again ???

Posted by: bjb

I’m trying out byteflow under django 1.2, and I finally have it working. There were only a few changes to make.

First off, the databases are specified differently in django 1.2 — there is the option to connect to multiple databases now. Strangely however, django did not force me to change my database settings … I guess there is some backward compabitility stuff for now.

old settings_local.py

    DATABASE_ENGINE = 'postgresql_psycopg2'
    DATABASE_NAME = 'byteflow'
    DATABASE_USER = 'db_user'
    DATABASE_PASSWORD = 'sekrit'

new settings_local.py

    DATABASES = { 'default' :
        {
            'ENGINE' : 'postgresql_psycopg2',
            'NAME'   : 'byteflow',
            'USER'   : 'db_user',
            'PASSWORD' : 'sekrit',
        }
    }

There are also some deprecation warnings in the logs about admin.site.root, in urls.py (I may have added all those ‘settings.BLOG_URLCONF_ROOT’ in when using ‘bjb’ as my URL_PREFIX):

old:
    url(r'^%sadmin/(.*)' % settings.BLOG_URLCONF_ROOT,
        admin.site.root, name='admin'),

new:
    url(r'^%sadmin/(.*)' % settings.BLOG_URLCONF_ROOT,
        include(admin.site.urls)),

But this didn’t work for me so I went back to the old way. The problem was that when I asked to edit a blog post, it brought me to the main admin page. When I clicked on the Change link, it stayed on the main admin page. I’ll have to look into that another time.

An update was required to apps/tagging/managers, in usage_for_queryset, to update the database query for the django 1.2 database scheme (multiple databases). I found this hint.

Also, in order to run django 1.2 on my stable machine, I set up a virtualenv (with --no-site-packages) in which to run it. Had to install all the site-packages into the virtualenv:

  • BeautifulSoup-3.1.0.1
  • Django-1.2.1
  • PIL
  • mx
  • openid
  • psycopg2-2.0.7

That’s about it except for infrastructure:

  • easy-install
  • pip-0.8
  • setuptools-0.6c8

Well I suppose I should have started by upgrading byteflow, I’ll have to try that another time. Maybe some of my changes have been fixed in upstream already. However I did quickly note that the byteflow install page still says it requires django 1.0.

Categories:
Posted by: bjb

If you want to do some unattended operations on your postgres database, and if you haven’t specified that the user who will do those unattended operations has access to that database using ident or sameuser authorization in /etc/postgresql/M.N/main/pg_hba.conf, then you will have to give a password upon invocation. But, postgres commands generally don’t let you specify a password on the command line (and there is a good reason for this).

There are two ways to configure your admin user to be able to work on your postgres database. One is with an environment variable and the other is with a postgres password config file in the admin user’s home directory.

The environment variable to set is PGPASSWORD, for example export PGPASSWORD=sekrit; pg_dump mydatabase.

The config file method means writing lines like hostname:port:database:username:password into a file called .pgpass in the admin user’s home directory. Don’t forget to set the permissions on ~/.pgpass to 0400, or -r--------.

The reason why postgres strongly discourages specifying the password on the command line is that it is easy for other users on the system to see that password with a simple invocation of the ps command.

Categories: , , , ,
Posted by: bjb

If you’re running a slave nameserver using bind9 and you’re getting messages like this in your logs:

    Aug 31 19:58:30 sns named[12175]: zone somedomain.com/IN: refused notify from non-master: 2002:1234:cdef::1234:cdef#13361

then the master is sending out notifies on an IPv6 address. Normally, you could just add that address to the “masters” list in the zone on the slave, but if the master isn’t listening on IPv6 you’ll get a bunch of other errors, like this:

    Aug 31 07:32:33 sns named[12175]: zone somedomain.com/IN: refresh: retry limit for master 2002:1234:cdef::1234:cdef#53 exceeded (source ::#0)
    Aug 31 07:32:33 sns named[12175]: zone somedomain.com/IN: Transfer started.
    Aug 31 07:35:42 sns named[12175]: transfer of 'somedomain.com/IN' from 2002:1234:cdef::1234:cdef#53: failed to connect: timed out
    Aug 31 07:35:42 sns named[12175]: transfer of 'somedomain.com/IN' from 2002:1234:cdef::1234:cdef#53: Transfer completed: 0 messages, 0 records, 0 bytes, 189.000 secs (0 bytes/sec)

There are two ways to fix this: on the slave nameserver, or on the master.

 continue reading
Posted by: bjb

Using my blog for it’s intended purpose: notes to self.

django on my server is an older version, my apps developed on my desktop need a newer version of django. I need to deploy virtualenv on my server so I can run a newer version of django for some apps. Like ipaddr and byteflow.

byteflow in particular, needs jquery.js (for attaching an image to a post, via postimage app and TAGGING_AUTOCOMPLETE_JS_BASE_URL setting) and that is not included in django 1.0.2.

But I’m out of time for today, so this is a task for another day.

Categories:
Posted by: bjb

Summary of emacs rectangle commands, with default keystrokes:

C-x r k    kill-rectangle
C-x r d   delete-rectangle
C-x r y   yank-rectangle
C-x r o   open-rectangle
C-x r c   clear-rectangle
M-x delete-whitespace-rectangle
C-x r t <text><enter>  replace rectangle contents with text (string-rectangle)
M-x string-insert-rectangle<enter><string><enter>  insert string on each line of the rectangle

from http://www.gnu.org/software/emacs/manual/html_node/emacs/Rectangles.html