Archiv ‘Linux’

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) 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) 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) 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

Sonntag, 3. November 2013

(Aus dem Archiv) Download page with all linked 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.

When the end of the semester gets close, I usually get into a rush and try to download all online material of the lectures. Being tired of clicking through thousands of pages, I remembered wget. A very useful tool, not just to download … err … thumbs and their linked close-ups ;-)

The following command will do the trick:

wget -r -np -nd <url>

You end up having all links recursively downloaded -r, but tell wget not the step up a level -np, and finally, we don’t want to have put the files in nested directories -nd. That’s it, alreay, straight and steady.

To just download files of special type, I recommend adding the following switch:

wget -r -np -nd -A *.pdf <url>

Tags: , , ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Batch rename 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.

With this little script, you can batch rename directories in current folder AND subfolders

#!/bin/sh

SEARCH="set"
REPLACE="s"

for ITEMOLD in `find . -type d`
do
	echo "Processing '$ITEMOLD'"
	ITEMNEW=`echo $ITEMOLD | sed "s/$SEARCH/$REPLACE/g"`
	#echo "After search/replace: '$ITEMNEW'"
	
	if [ $ITEMOLD != $ITEMNEW ]
	then
	
		if [ ! -d "$ITEMNEW" ]
		then
			echo "Attempting to rename '$ITEMOLD' to '$ITEMNEW'"
			mv "$ITEMOLD" "$ITEMNEW"
			
			if [ ! -d "$ITEMNEW" ]
			then
				echo "[-] Renaming seems to have failed - '$ITEMNEW' doesn't exist"
				exit 1
			else	
				echo "[+] Success"
			fi
		else
			echo "[-] '$ITEMNEW' already exists"
		fi
	
	else
		echo "[i] '$ITEMOLD' does not match expression, skipping"
	fi
	
	echo ""
done

exit 0

Tags: , ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Find files greater than x Bytes

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.

In my special case, I used the following command to separate thumbnails (expected smaller than 10KB) and closeups (expected to be greater than 10KB) in a web-dump.

find . -type f -name "*.jpg" -size +10240c -exec mv '{}' ~/newdir/ ';'

Tags: , ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen

Sonntag, 3. November 2013

(Aus dem Archiv) Remove file types except those which contain ‚foobar‘

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.

My linux servers hosts my complete electronic Music Library, sharing it using daapd. All downloads come with a mess of additional files like covers, cue-sheets, nfo-files etc. Usually, I’m too lazy to get rid of’em directly after the download. As time passed by, everything got messed up with every new album I’ve leeched. Instead of going through every directory – and there are many of them – I used another fine find-command to remove anything not an mp3-file within my MP3-Folder:

find . -type f \! -name "*.mp3" -exec rm '{}' ';'

Tags: , ,
Labels: Linux

Keine Kommentare | neuen Kommentar verfassen