April 2006

Magic Sysrq key

Because I can never find the SysRq magic key combinations when I need them, I’ve copied and pasted them here:

ALT+SysRq+COMMAND-KEY

The ‘SysRq’ key is also known as the ‘Print Screen’ key. COMMAND-KEY can be any one of the following (all keys need to hit simultaneously) :
‘b’ : Will immediately reboot the system without syncing or unmounting your disks.
‘o’ : Will shutdown your system off (if configured and supported).
’s’: Will attempt to sync all mounted filesystems.
‘u’ : Will attempt to remount all mounted filesystems read-only.
‘e’ : Send a SIGTERM to all processes, except for init.
‘h’: Show help, indeed this the one you need to remember.

So whey you need to tell your Linux computer to reboot or when your X server is crashed or you don’t see anything going across the screen then just press:

ALT+SysRQ+s : (Press and hold down ALT, then SysRQ (Print Screen) key and press ’s’) -Will try to syn all mounted system

ALT+SysRQ+r : (Press and hold down ALT, then SysRQ (Print Screen) key and press ‘r’) -Will reboot the system.

If you wish to shutdown the system instead of reboot then press following key combination:
ALT+SysRQ+o

Linux
Web links

Comments (0)

Permalink

Weblinks

In the good old days(tm), before I started blogging and stuff I used to e-mail myself weblinks if I didn’t want to lose them. Since I’m now blogging and have recently completely replaced the way I get my email, I’m now sorting out the contents of my inbox and removing these links. Anything which is still useful or relevent is here:

A simple text list of ‘language notes’ on python. It’s really useful and concise, as well as listing most of the nifty things you can do with the Python language.

A comprehensive guide to the stuff you can do with .htaccess. It’s lists juast about everything you could do (or at least want to do) with the .htaccess file in a straightforward way. One of the better references for doing stuff with a .htaccess file.

Lots of shiny icons.

The exceptionally shiny flurry screensaver from MacOSX for windows

Howto use 3rd party encoders with exact audio copy (e.g. FLAC)

Nifty settings and stuff for mutt

An intersting article on gentoo in the server room

Gentoo
Linux
Mail
Web links

Comments (0)

Permalink

Blog Software

Although Simple PHP Blog does it’s job, it has a few irritating quirks. So much so, that one of my suggestions for a third year Computer Science project was to write a database-less Blog script which worked the way I wanted.

While searching for an alternative, using the phrase ‘blog no database’ (since, due to an error on the TechTeam’s part I have no database when I should have a MySQL database) I found Jean-Claude Wipple’s blog. On it he is complaining about programs which do not use databases, which I found quite hipocritical since he’s (coincidentally) using a database-less blog script written in bash, of all things!

This looks very interesting, especially as I’m a fan of bash. Maybe I’ll have a poke and look into replacing this blog with it…

Blog
Web links

Comments (0)

Permalink

New Blog Software

I’ve just finished replacing my old blog software (Simple PHP Blog) with a new one. The new one, Marko’s µBlog, is a lot nicer and more easily customisable so hopefully I can hack it into behaving as I expect.

I’m going to leave the old blog up for another hour or so, so I can have a go at hacking the new one’s CSS and also give the people who subscribed to my blog’s RSS feed( if there are any) a chance to be told of the impending change.

Blog
Web links

Comments (0)

Permalink

Gentoo Linux

Hmm, so I installed Gentoo on my laptop again. Despite the time spent compiling it (yes, I did a Stage 1 install, using the approved method for Stage 1 Gentoo install), I really do apprecate the reasons I liked Gentoo in the first place. Sensible defaults (like Arch Linux) and no silly dialogs when you install packages means that installation is pratically unattended and most of the time stuff ‘just works’(tm) without any further editing. On top of that it is stupidly fast, since everything is compiled for my computer’s specific arcitecture and by using the USE flags nothing I don’t need is compiled in.

I managed to setup (with a little effort and some head-bashing – for some reason xbindkeys doesn’t like running xtrlock directly so I had to use xautolock to hax it) a minimalistic desktop, based upon a tutorial on UWLUG. Just for reference, here’s the relevent config files:

.Xresources:

XTerm*background: Black
XTerm*foreground: White
XTerm*visualBell: True
XTerm*eightBitInput: false
XTerm*metaSendsEscape: true
xautolock*locker: xtrlock
! timeout of 3 mins before locking
xautolock*time: 3
! Active corner = bottom right
xautolock*corners: 000+
! Corner timeout = 1 second
xautolock*cornerdelay: 1

.xbindkeys:

"xautolock -locknow &"
control+alt+semicolon
"xautolock -exit &"
control+alt+q
"opera &"
control+alt+o

.xsession:

xbindkeys
tpb -d
xv -quit -root -rmode 5 -max ~/36275-emerge.jpg
#xpenguins & # This and conky do _NOT_ get along as both like the root window (xpenguins destroys parts of conky until it refreshes)
conky -d
evilwm -snap 10 &
exec xautolock

Just to annoy Faux, his blog is available at this page.

Gentoo
Linux

Comments (0)

Permalink

OMG H4X!

I’ve just finshed writing possibly the hackiest(if that’s a word) script I’ve ever written.

I’ve switched to using mutt as my primary mail client and since it’s pretty much a stock mutt setup, it doesn’t particularly like the html emails that the ‘Daily Dilbert’ come as. In order to read the strips with as little effort as possible (always a good thing ;) ), I’ve written this filter. It extracts the url of the image from the email, fetches the image and then replaces the original email with just the image as an attachment (no body).

This is the filter from my .mailfilter (which courier-maildrop uses):

if ( /^Subject: Your Daily Dilbert$/ )
{
# This increadably hacky script extracts just the picture from the 'daily dibert' email so I can view it through
# my non-html email client (mutt).
# It's in an exception block, so if the hacky script fails the email (hopefully) will still get delivered.
exception {
TEMPFILE=`tempfile`
FROMFILE=`tempfile`
OUTFILE=`tempfile`
xfilter "tee $FROMFILE \
| grep 'http://www\.comics\.com/comics/dilbert/archive/images/.*\.gif' \
| sed -e 's#^.*\(http://www\.comics\.com/comics/dilbert/archive/images/.*\.gif\).*$#\1#' > $TEMPFILE \
&& sed -e '/^Subject: Your Daily Dilbert$/d; /^$/Q;' $FROMFILE | tee $FROMFILE > /dev/null \
&& echo 'X-Haxed-For-Piccie-Only: Yes' >> $FROMFILE \
&& curl `cat $TEMPFILE` > /tmp/`cat $TEMPFILE | sed -e 's#^.*/\(.*\.gif\).*$#\1#'` \
&& rm $OUTFILE \
&& mpack -s 'Your Daily Dilbert' -o $OUTFILE /tmp/`cat $TEMPFILE | sed -e 's#^.*/\(.*\.gif\).*$#\1#'` \
&& rm /tmp/`cat $TEMPFILE | sed -e 's#^.*/\(.*\.gif\).*$#\1#'` $TEMPFILE \
&& cat $FROMFILE $OUTFILE \
&& rm $OUTFILE $FROMFILE"
}
to $MAILDIR/.MailingLists/
}

Note the subject gets deleted, and then re-added when mpack creates the email with attachment. This is because mpack refuses to create mail without a subject, even though I’m adding all the original headers (mainly so I can see spam-assassin’s report) back in later.

Linux
Mail

Comments (0)

Permalink

More config crazyness

With help from Euan, i’ve created this script to download and setup the initial sym-links for my config scripts automagically:

#!/bin/bash
mkdir ~/configs
wget --http-user=username --http-passwd=secret http://webserver/path/to/configs.tar.bz2 -O /tmp/configs.tar.bz2
pushd ~/configs
tar -jxf /tmp/configs.tar.bz2
popd
rm ~/.bashrc ~/.bash_profile ~/.vimrc ~/.screenrc ~/.ssh/config
ln -s ~/configs/bashrc ~/.bashrc
ln -s ~/.bashrc ~/.bash_profile
ln -s ~/configs/vimrc ~/.vimrc
ln -s ~/configs/screenrc ~/.screenrc
if [ ! -d ~/.ssh ]
then
mkdir ~/.ssh
fi
ln -s ~/configs/ssh_config ~/.ssh/config

Now I can just run this on a new system:

curl -u user:secret http://website/path/to/setup.sh | bash

and I’ll get all my main configs and symlinks setup.

Linux

Comments (0)

Permalink

Non-free bash prompt

Shamelessly stolen from Tim Retout’s Blog (original article):

# Server 2003!
export PROMPT_COMMAND='export PS1="C:$(pwd|sed '''s#/#\#g''')> "'
echo 'Microsoft Windows 2003 [Version 5.2.3417]'
echo '(C) Copyright 1985-2006 Microsoft Corp.'
echo

Linux

Comments (0)

Permalink

Config file crazyness update

During the brief interlude where I had Arch Linux installed, I discovered some distros apparently don’t have ‘tempfile’ command (looking on the web it would appear that Gentoo also lacks this useful command), which broke my config files archive scripts, so I created this bash script to do the job and set it up as an alias in my .bashrc:

# add our own tempfile command, if one doesn't already exist.
tempfile &> /dev/null
if [ $? -eq 127 ] # $? == 127 == command not found
then
if [ -e ~/configs/tempfile.sh ]
then
alias tempfile='bash ~/configs/tempfile.sh'
fi
fi

tempfile.sh:

#!/bin/bash
# tempfile.sh - temporary filename generator (for systems missing 'tempfile' command)
# Author: Laurence Hurst
# Date: 13 April 2006
filename=`mcookie`
filename=${filename::8}
dirname='/tmp'

while [ -a $dirname/$filename ]
do
echo "$dirname/$filename exists! Trying another filename." >&2
filename=`mcookie`
filename=${filename::8}
done
echo "$dirname/$filename"

However the scripts don’t read .bashrc (where this is setup as an alias), and so it doesn’t work. There must be a way to make the scripts use aliases setup in .bashrc, I just can’t figure out how.

.:Update to the Update:.
Accoding to some information I found on interactive vs non-interactive shells it is not possible to use personal aliases in bash scripts for the reason that if you give the script to someone else they probably won’t have the same aliases so it won’t work, which make sense most of the time but not here where the script is only for me, and the alias is for systems which lack a tempfile utility.

I also found this sample .bashrc, which creates a prompt with the current load average which might be nify to add to my (rapidly growing) bash prompt:

152 function powerprompt()
153 {
154 _powerprompt()
155 {
156 LOAD=$(uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g" )
157 }
158
159 PROMPT_COMMAND=_powerprompt
160 case $TERM in
161 *term | rxvt )
162 PS1="${HILIT}[\A \$LOAD]$NC\n[\h \#] \W > \[33]0;\${TERM} [\u@\h] \w07\]" ;;
163 linux )
164 PS1="${HILIT}[\A - \$LOAD]$NC\n[\h \#] \w > " ;;
165 * )
166 PS1="[\A - \$LOAD]\n[\h \#] \w > " ;;
167 esac
168 }
169
170 powerprompt # this is the default prompt - might be slow

I did, however remember that ~/bin, if it exists, is added to the path in my .bashrc so a symlink ~/bin/tempfile -> ~/configs/tempfile.sh (I renamed the scripts directory in my previous post to configs) should work – I will have to try it tomorrow, for now though bed :) .

Linux

Comments (0)

Permalink

Why Arch Linux Sucks (and not in a good way)

I (re-)installed Arch Linux today. Having been using Debian for over a week, I managed to break it during an upgrade (X refused to start. Probably should be fixable, but several hours hacking at google revealed nothing so I decided to go back to what I know – Arch). Coming back from Debian, which is an extremely solid distribution – the very reason I installed it on my mail server – to Arch which is much more bleeding-edge I expected to see the odd bug or two.

I did not expect the shock of poor quality and the bugs which were just unfixed purely out of laziness, as far as I can see. Even before the system was installed the problems started…

  • installer borks on grub-install if cd-drives are above hdds in device chain (as is the case on my desktop). It assumes that hd0(according to grub)==hda(according to the kernel) however if hda and hdb are cd-drives and hdc is the first hard disk, then hd0==hdc not hda. Debian,Fedora,Ubuntu (in fact every other installer I’ve come across) all cope fine so it must be fairly straight-forward to fix.
  • installer leaves stuff in an inconsistent state if an error occurs while formatting or mounting a filesystem. Any filesystems mounted before the error remain mounted, although the installer dumps you back at the beginning. It then cannot continue as it will try to (re-)format the mounted filesystem, and fail dumping you back at the start again. Clearly the solution is to unmount the filesystems manually before continuing but what’s the point of an installer if it doesn’t work?! I would use Gentoo if wanted to mess with this kind of stuff (well, actually I would prefer to use Gentoo but the (mostly perceived) time required to install it prevents me from doing it).
  • makepkg, the script for building your own Arch packages (which is so easy to use building packages is trivial, so the distro’s small repository of prebuilt packages is not too much of a problem), does not work when run from within directories with spaces. This is probably due to poor bash scripts, as is the next problem;
  • I like to rename the network interfaces on my desktop computer (which has 2 network ports on the motherboard). Since the network ports use different chipsets I usually name them ‘eth-’ using udev rules. This works fine on Debian and SuSE, however the network interfaces cannot have hyphens in their name in Arch due to a “won’t fix” bug in the network init script. This is incredibly silly as it should be fixed by simply placing the correct quotes around the variable name when calling ifconfig or dhcpcd from within the init script.
  • There is no vlock package. I consider, among other things, vim,screen and vlock to be core to the functionality of Linux systems(or indeed *nix systems in general). While with a small distribution such as Arch I would expect to have to build my own packages for a few things I would expect these 3 at least to be in the basic repository!

::UPDATE::

I had a look at fixing the bugs in the init-scripts and makepkg. While I successfully fixed the bug in makepkg itself (simply a case of enclosing the relevant variables in “quotes”) most, if not all, of the PKGBUILD scripts refer to $startdir without quotes which means that, since the script is passed straight to bash, to be rid of the bug completely this variable would have to be quoted in all PKGBUILDs. This is no small task.

On the init-script front, the problem is that that rc.conf is simply ’source’d. This means that hiphens cannot occur in variable names (at the time of writing my rant, I was assuming that rc.conf would have been parsed rather than ’source’d). This bug is probably not fixable unless rc.conf becomes parsed which would more than likely go against Arch’s KISS philosophy.

i-ho, i-ho, back to Debian I go

Linux
Rants

Comments (6)

Permalink