Archive for the ‘Linux’ Category
Drupal - “Content (missing)”
I’ve started playing with Drupal and looking at moving a few sites over to it. In a late night session of bolting things together I ran into a bit of a snag with a few modules trying to create thumbnails on teaser articles.
Unfortunately when I installed the imagefield CCK module I ran into a snag where it wouldn’t allow me to continue without the ‘content’ module which was missing.
I attempted to search for this missing module in the drupal module downloads section with no luck… http://drupal.org/search/node/type%3Aproject_project+content gave me no joy at all.
Luckily, the a nice Drupal IRC user slapped me with a quick ‘CCK = content’ line after I pleaded where this magical ‘Content’ module is and of course after I installed the CCK module everything worked like a charm. I had thought I had already installed this module and was probably too tired to have checked this first…
So for any newbie Drupal users out there I hope you find this helpful tip on Google before you harass some poor sod on IRC… that way you might actually appear somewhat knowledgeable.
MyBook backups with Rsnapshot and some bash trickey
I had a client accidentally purchase half a dozen 500GB MyBook’s instead of the simpler cheaper USB models.
Since this site is remote from me it took a little while to deduce what was going on since the MyBook’s don’t act as USB drives and hence don’t appear as a USB device to linux.
User: ‘Yes, I’ve plugged it in! Yes it’s using the white cable!’
Me: ‘So… what exactly does it say on the box what drive it is…’
Anyhow, after figuring out that is was a MyBook I implemented ssh access using Martin Hinner’s clever hack and found a nice website of various MyBook Hack’s.
I was originally using the venerable Rdiff-backup, but alas couldn’t see it in the Optware packages. So I implemented a Rsnapshot solution, the only problem was I wanted some notifications from the MyBook devices to check that the backups were working, and so a simple bash script was in order…
#!/bin/bash mailto=my@emailaddress.com,clients@theclientsdomain.com time=$1
if /opt/bin/rsnapshot $time > /tmp/rsnapshot.log 2> /tmp/rsnapshot.logthen subject='Backup success'else subject='Backup FAILURE'ficat /tmp/rsnapshot.log | /opt/bin/nail -r admin@theclientsdomain.com -s "$subject" $mailto
I hate Nano!
I hate that cursed text editor. This morning I spent 5 minutes trying to figure out why a fresh crontab wasn’t working as I ssh’d into a server… My syntax was correct yet crontab refuse to save my entry stating bad minute errors in crontab file.
I then realised it was the crap characters nano was feeding into the beginning of the file!
A swift export EDITOR=vim and my crontab problems were gone.
Note: After bitching to a friend of mine who is pro Nano he stated to me that nano > 8. My point exactly, he’s so handicapped from using nano that he can’t even type an Asterisk.
Linux
I came across a selection of delciously funny captions for a swag of Linux distributions. Those who aren’t Linux fan-boys/girls will probably just scratch their heads.
Caldera, Debian, Fedora, Gentoo, Mandrake, RedHat, Slackware, Ubuntu.
Create apt-gettable debian packages
I was suprised this information wasn’t contained more prominently in the APT-HOWTO. It’s very useful to have your own packages, especially in a format you can download them.
First of all install the ‘dpkg-dev’ package, create a directory to hold your packages and source files then run:
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
dpkg-scansources . /dev/null | gzip -9c > Sources.gz
et voila you should now have a repository which is apt-gettable! (ripped from www.steve.org.uk)
Simply throw it on a Apache web server and add something like this
deb http://localhost/apt ./
deb-src http://localhost/apt ./
Symbolic links and Chroot
Found this awesome little tip in the proftpd manual on how to work around symoblic links issues.
There are two types of links in Unix: hard and symbolic.
A hard link is a file that is, for all intents and purposes, the file to which it is linked. The difference between a hardlink and the linked file is one of placement in the filesystem. Editing the hardlink edits the linked file. One limitation of hard links is that linked files cannot reside on different filesystems. This means that if /var and /home are two different mount points in /etc/fstab (or /etc/vfstab), then a file in /var/tmp cannot be hardlinked with a file in /home:
> pwd
/var/tmp
> ln /home/tj/tmp/tmpfile tmplink
ln: cannot create hard link `tmplink’ to `/home/tj/tmp/tmpfile’: Invalid cross-device link
A symbolic link (also referred to as a “symlink”) is a file whose contents contain the name of the file to which the symbolic link points. For example:
lrwxrwxrwx 1 root root 11 Mar 2 2000 rmt -> /sbin/rmt
The file rmt contains the nine characters /sbin/rmt. The reason symbolic links fail when chroot(2) is used to change the position of the root (/)of the filesystem is that, once / is moved, the pointed-to file path changes. If, for example, if chroot(2) is used to change the filesystem root to /ftp, then the symlink above would be actually be pointing to /ftp/sbin/rmt. Chances that that link, if chroot(2) is used, now points to a path that does not exist. Symbolic links that point to nonexistent files are known as dangling symbolic links. Note that symbolic links to files underneath the new root, such as symlinks to a file in the same directory:
> pwd
/var/ftp
> ls -l
-rw-r–r– 1 root root 0 Jan 16 11:50 tmpfile
lrwxrwxrwx 1 root root 7 Jan 16 11:50 tmplink -> tmpfile
will be unaffected; only paths that point outside/above the new root will be affected.
Filesystem Tricks
When chroot is used symlinks that point outside the new root (the user’s home directory in this case) will not work. To get around this apparent limitation, it is possible on modern operating systems to mount directories at several locations in the filesystem.
To have an exact duplicate of the /var/ftp/incoming directory available in /home/bob/incoming and /home/dave/incoming, use one of these commands:
Linux
mount –bind /var/ftp/incoming /home/bob/incoming
Gets around the symbolic links issue.