Sonntag, 3. November 2013

(Aus dem Archiv) Installing mod_bwshare on Debian Linux running Apache 2.0.x

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

Recently, I noticed msnbot was spamming my whole upload bandwidth because it seemed to create a complete dump of my photo gallery – several image requests within a minute! After some googling I discovered several Apache modules which promise to get rid of such bots running amok (although there are some concerns about artificially prolonging download times for leechers – beware!). I finally decided to go on with mod_bwshare. In a temporary „dust of war“, I got the wrong impression that I needed to upgrade to Apache 2.0.x to be able to get a precompiled .deb. Well, haha! There isn’t a debian package available right now. Well, okey, at least I’m running the newest Apache now, although I had to

apt-get remove apache
dpkg-reconfigure php4
dpkg-reconfigure php4-mysql
dpkg-reconfigure php4-curl
dpkg-reconfigure php4-imap
dpkg-reconfigure php4-gd

to get back to my „touched working system“ and make PHP aware of Apache 2. Be aware: Everything starts with untouched config files, so make sure you enable error logging in PHP again. Especially if you’re a web-dev like I am, you know about usefulness of

error_reporting = E_ALL

Okey, now straight back to the task. Since all this stuff is open source, we could at least give it a try with compiling and stuff (honestly, I just now enough about compiling to completly havoc a system, but I was a lucky guy in this case). So download the source files:

cd /tmp
wget http://www.topology.org/src/bwshare/bwshare-0.1.3.zip
unzip bwshare-0.1.3.zip

So, there we had’em now, hundreds of lines of codes. As stated on the developers homepage itself, running

cd src/modules/bwshare
apxs2 -c mod_bwshare.c
apxs2 -i mod_bwshare.la

Should do the trick. Nada, first we needed the developer package:

apt-get install apache2-dev

Once again:

apxs2 -c mod_bwshare.c
apxs2 -i mod_bwshare.la

A lot of warnings were displayed, but finally, I read

...
chmod 644 /usr/lib/apache2/modules/mod_bwshare.so

After having succesfully compiled mod_bwshare, I had to create two text-files in /etc/apache2/mods-available/

bwshare.load
bwshare.conf

and pasted the following contents:

LoadModule bwshare_module /usr/lib/apache2/modules/mod_bwshare.so
# Some bandwidth control parameters.
BW_tx1cred_rate         2
BW_tx1debt_max          10
BW_tx2cred_rate         1000
BW_tx2debt_max          1000000

<Location /bwshare-info>
SetHandler bwshare-info
</Location>

<Location /bwshare-trace>
SetHandler bwshare-trace
</Location>
</IfModule>

That was it (if you got that far, you surely know now what comes next – putting symlinks in mods-enabled/ and doing a

apache2ctl graceful

(Thanks to our solaris master Aeschlimann at the University for the graceful hint some time ago – greetz).

Tags: , ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Installing SNMP-Daemon (snmpd) on IPCop for remote monitoring

The Task

After some days of testing I finally found out a relative simple solution to run a SNMP-Daemon on my IPCop-Router.

Package management under Mac OS X

First of all, I had to deal with Debian-packages. This posed some problems to me, because I don’t have any linux box here except the one running IPCop, which hasn’t package-managers installed. After I dived into manuals for dpkg i was able to extract the files on my PowerMac running Mac OS X. Before you can execute the shell command below, you need to download and install Fink. After that, continue:

dpkg-deb -x <package>.deb <destination-dir>

Installation

You now do have the required files on your workstation, but yet they need to be put on the IPCop-box. Make use of an SFTP-Client, which requires the SSH-Service enabled on the router. With a SSH-connection to the box, I checked the error messages which occured upon start of the snmpd and then went out to look for the additional files required. The ’search file within packages‘-Function of some package-sites helped me a lot!

Packages needed

These 3 Debian-Packages are essential for your success. Download the .debs and extract them to a single folder with the command mentioned above:

  • snmpd (4.2.3-2)
  • libsnmp4.2 (= 4.2.3-2)
  • libwrap0

File locations

I had to copy all files over to IPCop manually, therefore I made this list to monitor all the files necessary.

/lib/libwrap.so.0
/usr/lib/libucdagent-0.4.2.so
/usr/lib/libucdmibs-0.4.2.so
/usr/lib/libsnmp-0.4.2.so

/usr/sbin/snmpd

Caveats

Don’t try to copy snmpd.conf over to the box. In my case, it prevented snmpd to act the way it should. I have no idea where the problem lied, but after deleting snmpd.conf, everything worked fine. I hope this saves you a lot of headaches.

Tags: ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) „Saving your Settings“ / „Einstellungen werden gespeichert“ takes forever on logout

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

  1. Group Policy Editor (gpedit.msc)
  2. Local Computer Policy
  3. Administrative Templates
  4. System
  5. Logon
  6. „Maximum retries to unload and update user profile“ = 2 (default 60 [seconds? tries?])

Hint taken from Annoyances.org

Tags: , , ,
Labels: IT

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Make Mail.app respect your .mailboxlist when using IMAP

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

Mail.app is a nice, sleek E-Mail-Client which does quite everything you need in everydays use. But there’s one great drawback: Apple engineers sometimes simply miss the point. When accessing IMAP-mailboxes through Mail.app, you’re not only presented all the expected IMAP-folders, but all those crappy dot-hidden-files (.*) in the IMAP-root, even if there is a .mailboxlist, which tells well written (!) Mail-clients which folders to subscribe to (isn’t it even mentioned in a RFC?). Mail.app doesn’t – god knows why. In fact, it seems also to depend on which mail-server your provider uses. If it’s pmdf, you’re most likely to end up the way I am. Another provider I use to store my eMeidi.com-accounts on, there are no such issues at all.

Anyway, while browsing the web I only found some small hints … one worked! There’s some manual work to do, so it’s essential to have SSH-/Telnet-Access to the server where your folders are being stored.

  • Really first, close all your Mail-clients. Safe is safe
  • Second, make a backup-copy of all your IMAP-folders.
  • The clue is to move your IMAP-folders to a subdirectory. I therefore created a folder IMAP/ in my home-directory. Now you can move all folders to IMAP/
  • Configure Mail.app to use „IMAP/“ as folder prefix. This setting is required by all other Mail-clients you use aside
  • Make also sure to update .mailboxlist in your root-directory to point to the new folders
  • If your provider also offers Horde IMP (Webmail), you have to „subscribe“ to the new folders. Don’t forget to point sent-mail and Trash to the new locations. These settings can usually be done under ‚Options‘

I feared to mess it up, so I waited months before I took these steps. Now I wish I had done it earlier. It’s so smooth to see only your mailfolders and all the other .profile, .whatever and .huh being gone forever!

Tags: ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Backup my Mac OS X home directory with rsync

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

Please be aware to use the special rsync-Version written for Mac OS X (fucking resource forks, again!). Otherwise you could end up with a mess (only on the backup side, but this sucks as much!).

I separated iPhoto-Files from the rest, because the .sparseimage wouldn’t fit on a DVD anylonger.

backup.sh

#!/bin/sh

if [ $# -lt 1 ]
then
	echo "Please provide a destination to store the backup to:"
	echo "fwdsk (Firewire-Drive)"
	echo "eth (Server-Share)"
	echo "tmp (/tmp)"
	exit 1
fi

case $1 in
	"fwdsk")
		IMAGEFOLDER="/Volumes/TRANSFER";;
	"eth")
		IMAGEFOLDER="/Volumes/RSYNC";;
	"tmp")
		IMAGEFOLDER="/tmp";;
	*)
		echo "Please provide a destination to store the backup to:"
		echo "fwdsk (Firewire-Drive)"
		echo "eth (Server-Share)"
		echo "tmp (/tmp)"
		exit 1;;
esac

if [ ! -d "$IMAGEFOLDER" ]
then
	echo "Directory '$IMAGEFOLDER' not found"
	exit 1
fi

BACKUPINFO=( "home" "iphoto" )

for VOLNAME in ${BACKUPINFO[@]}
do
	DISKIMAGENAME="$VOLNAME"
	DISKIMAGEPATH="$IMAGEFOLDER/$VOLNAME.sparseimage"
	
	BACKUPSOURCEFILE="/Users/mario/Rsync/bkpsrc/$VOLNAME.txt"
	
	if [ ! -f "$BACKUPSOURCEFILE" ]
	then
		echo "File '$BACKUPSOURCEFILE' not found"
		exit 1
	fi
	
	BACKUPSOURCE=`more $BACKUPSOURCEFILE`
	BACKUPDESTINATION="/Volumes/$VOLNAME"
	RSYNCEXCLUDE="/Users/mario/Rsync/exclude/$VOLNAME.txt"
	
	#-------------------------------------------------
	# Create/reuse & mount Disk-Image
	#-------------------------------------------------
	if [ ! -f "$DISKIMAGEPATH" ]
	then
		# Disk-image-file doesn't even exist - create it
		echo "Creating disk image \"$DISKIMAGEPATH\""
		hdiutil create -fs HFS+ -type SPARSE -size 20g -volname "$DISKIMAGENAME" "$DISKIMAGEPATH"
	else
		echo "Using pre-existing disk image \"$DISKIMAGEPATH\""
	fi
	
	if [ ! -d "$BACKUPDESTINATION" ]
	then
		# Disk-image doesn't seem to be mounted
		hdiutil attach "$DISKIMAGEPATH"
	fi
	
	#-------------------------------------------------
	# Did Disk-Image mount correctly?
	#-------------------------------------------------
	if [ ! -e "$BACKUPDESTINATION" ]
	then
		echo "There was a problem creating or mounting the disk image"
		exit 1
	fi
	
	#-------------------------------------------------
	# Rsync
	#-------------------------------------------------
	/Users/mario/Rsync/rsync.sh "$BACKUPSOURCE" "$BACKUPDESTINATION" "$RSYNCEXCLUDE"
	
	#-------------------------------------------------
	# Unmount Disk-Image and do maintenance operations
	#-------------------------------------------------
	# hdiutil info | grep /Volumes/$VOLNAME | cut -f 1
	# 
	# Expected output: /dev/disk2s2    Apple_HFS       /Volumes/Rsync-Backup
	#                  ^ this info is required to unmount
	
	DISKIMAGEDEVICE=`hdiutil info | grep /Volumes/$VOLNAME | cut -f 1`
	echo "Disk image mounted as $DISKIMAGEDEVICE"
	
	hdiutil detach -quiet "$DISKIMAGEDEVICE"
	echo "Disk image ejected"
	
	hdiutil compact "$DISKIMAGEPATH"
	echo "Disk image compacted"
done

rsync.sh

#!/bin/sh

if [ $# -ne 3 ]
then
	echo "Usage:"
	echo "rsync.sh   "
	exit 1
fi

BACKUPSOURCE="$1"
BACKUPDESTINATION="$2"
RSYNCEXCLUDE="$3"

if [ ! -d "$BACKUPSOURCE" ]
then
	echo "Source directory '$BACKUPSOURCE' not found"
	exit 1
fi

if [ ! -d "$BACKUPDESTINATION" ]
then
	echo "Destination directory '$BACKUPDESTINATION' not found"
	exit 1
fi

if [ ! -f "$RSYNCEXCLUDE" ]
then
	echo "Exclude file '$RSYNCEXCLUDE' not found"
	exit 1
fi

# --verbose
# --showtogo
# --dry-run
time sudo /usr/local/bin/rsync -a --delete --delete-excluded --eahfs --showtogo --exclude-from\
 "$RSYNCEXCLUDE" "$BACKUPSOURCE" "$BACKUPDESTINATION"

bkpsrc/home.txt

/Users/mario/.

bkpsrc/iPhoto.txt

/Users/mario/Pictures/iPhoto Library/.

exclude/home.txt

Music/
Movies/
PoisonDownloads/
Cache/
Caches/
.Trash/
Fun-Stuff/
.DS_store
iPhoto Library/

exclude/iphoto.txt

.Trash/
.DS_store

Tags: ,
Labels: Apple

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Search & replace stuff in HTML-Files

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

Recently, I had to replace a URL linking to a no longer accurate place in hundreds of HTML-Files (yeah, this sites origin dates even before ST:ENT started. Terrible!).

Well then, I had two choices: Download anything onto my machine, look out for a nice GUI-editor which allows search & replace for whole folders or … well, dive into the web and put a nice shell-script together which does the work for me. Since GUIs are for kids and professors, i chose the second option. Here is the result (you surely notice how much safety measures I took. In the final version, i disabled creation of .tmp-Files, because it would have messed everything even more. I had luck – everything worked out the way I expected it to ;-):

#! /bin/sh
STRSEARCH="www.unibe.ch\/faculties\/humanities_d.html"
STRREPLACE="www.philhist.unibe.ch\/"

if [ -d /var/www/hist ]
then
	# AT HOME
	cd /var/www/hist
else
	# ON UBECX
	cd /u/hist/www
fi

find . -type f -name '*.htm' -print | while read i
do
	cp "$i" "$i.tmp"
	
	if [ -f "$i.tmp" ]
	then
		#echo "s/$STRSEARCH/$STRREPLACE/g"
		sed "s/$STRSEARCH/$STRREPLACE/g" "$i" > "$i.new"
		if [ -f "$i.new" ]
		then
			mv "$i.new" "$i"
		else
			echo "$i.new doesn't exist"
		fi
	else
		echo "$i.tmp wasn't created"
	fi
done

Tags:
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Split MP3 into tracks based on cue-sheet

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

To do this, you need to get Mp3splt and compile it yourself. Don’t worry, it’s easy (otherwise, I couldn’t have made it ‚til here ;-). Check the manual for proper installation steps.

mp3splt -c sheet.cue audio.mp3

Tags: ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) phpMyAdmin-dumps downloaded through Safari

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

ACHTUNG: Dem Artikel liegt wahrscheinlich Safari 1.x zu Grunde. Mittlerweile sind der Internet Explorer und der Firefox geschlagen und WebKit ist die dominante Plattform für’s Web-Browsing. Der hier erwähnte „Fehler“ ist längst behoben.

Somehow, the dump get’s fucked up because of the line endings. They’re all converted to \r. If you’re trying to restore the dump on a linux machine, nothing works. If you use the following command, everything should be fine:

tr '\015' '\012' < dump-mac.sql > dump-linux.sql

The other way ‚round … Converting linux- to mac-files:

tr '\012' '\015' < unix-format-file > mac-friendly-file

After you’ve treated your dumps, insert’em into your database:

mysql --user=user --password=password database < dump-linux.sql

Tags: , ,
Labels: Apple

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) chmod only files/directories

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

Sometimes I’m running amok with

chmod -R 644 .

without thinking it thouroughly. So folders get lost of their execute-flag, and nobody can enter them anymore. Well, here’s the solution:

find . -type d -exec chmod u+x '{}' ';'

Tags: ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Extract single file from a tar.gz-Backup

Der vorliegende Artikel habe ich ursprünglich irgendwann einmal ab 2002 auf meinem damaligen Linux-Entwicklungsserver im Web publiziert. Da ich das bloggen erst 2005 entdeckt habe, waren die Tipps in einer grossen HTML-Seite untergebracht. Anlässlich einer Aufräumaktion auf dem Server habe ich mich entschieden, die „Perlen“ über meine heutige Kommunikationsplattform ins Web zu posaunen. Seitdem ich die Artikel verfasst habe, sind viele Tage ins Land gegangen — ob der Artikel noch Gültigkeit hat, entscheidet der geneigte Leser selber.

Recently, I accidentally deleted a vital file on my linux server. Thanks to my regular backups by mkcdrec I just needed to have a look for the backup CD. After googling a few minutes, I came out with the appropriate shell command to extract the desired file out of a gzipped tar-archive:

tar -xzv --file=/Volumes/CDrec-29.07.2005/sdb1._var.tar.gz ./www/partyguide/curl/config.txt

This command recreated the directory structure in the current working dir (make sure you’re not cd-ed into the CD mount point, otherwise it can’t write out).

Tags: , ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen