Posted in Linux on January 27th, 2010 by Rugmonster – Be the first to comment
UPDATE: I found that what I originally posted was wrong and didn’t work at all. I don’t know how I managed to do that, but I’ve fixed it and it’s verified as working now.
I was asked if there was a way to extract the FTP activity to be emailed to someone. The server had a typical xferlog, but the box was being used for shared hosting and the reports didn’t need to include results for all of the other sites.
I put together the following script to extract the activity and transpose it to a more friendlier output. read more »
Posted in Linux, Mail, One-Liners, Plesk, qmail on December 1st, 2009 by Rugmonster – Be the first to comment
I needed to remove messages older than a week old for a list of email accounts on a Plesk system running Qmail. I put together the following BASH script to locate the messages using find and back them up outside of the mailbox (just in case). This builds on the technique I used in my previous post, Maintain directory structure copying `find` results.
All you need to do is create a file with one address per line to be read in by the command.
cd /var/qmail/mailnames; \
IFS="@"; \
while read LINE ; \
do \
ADDR=( ${LINE} ); \
echo "${ADDR[0]}@${ADDR[1]}"; \
find ${ADDR[1]}/${ADDR[0]}/Maildir/ \
\( -path "*/cur/*" -o -path "*/new/*" \) \
! -type d -mtime +7 | \
while read FILE; \
do \
DIR=$( dirname ${FILE} ); \
mkdir -p /path/to/dst/${DIR}; \
mv ${FILE} /path/to/dst/${DIR}; \
done; \
done < /path/to/address_file
Posted in Linux, One-Liners on November 27th, 2009 by Rugmonster – 1 Comment
Let’s say you have a directory structure consisting of files owned by various users, but you want to copy only the files of a particular user to another path, but maintain the directory structure in the destination path. If you just use something like this…
find /path/to/src/ -user foo -exec cp -a {} /path/to/dst/
…you end up with all of the files in /path/to/dst/ with the original directory structure flattened out.
I came up with the following to solve the problem:
find /path/to/src/ -user foo | while read FILE \
do \
DIR=$( dirname ${FILE} ); \
mkdir -p /path/to/dst/${DIR}; \
cp -d --preserve=mode,ownership,timestamp ${FILE} /path/to/dst/${DIR}; \
done
Here’s a brief explanation. Since the find command returns the relative path of the matching item in it’s STDOUT, we can use the dirname command to get the original relative directory name. We then create the directory if it doesn’t exist, and finally do the copy.
Posted in Uncategorized on May 29th, 2009 by Rugmonster – Be the first to comment
A client today had a problem with Squirrelmail giving the following error, preventing the folder listing from coming up:
Query: CREATE "Sent"
Reason Given: Invalid mailbox name.
read more »
Posted in qmail on May 17th, 2009 by Rugmonster – Be the first to comment
A couple of weeks ago at work, I was arguing which RBLs should be used with Plesk came up. I had always assumed that Plesk’s qmail setup would allow authenticated users regardless of any RBL results. If that were the case, then using zen.spamhaus.org wouldn’t pose any problem to mail users on a residential Internet service. I was wrong, but I wanted to sort out why and what options were available. read more »
Posted in Postfix on March 8th, 2009 by Rugmonster – Be the first to comment
The battle between email admins and spammers is an ongoing arms race. The spammers are at a disadvantage because by and large, they have to rely on exploiting vulnerable systems to send their mail. With the ever growing size of botnets, they have a pretty large pool of exploited systems to send from, but Postfix can be configured to weed out most of that.
read more »
Posted in Apache, RHEL 5 on March 5th, 2009 by Rugmonster – Be the first to comment
Apparently, I’m one of the only people who has ever built mod_fastcgi on Red Hat Enterprise Linux 5. At least after much Googling and gnashing of teeth, here’s how it’s done. read more »
Posted in One-Liners on February 19th, 2009 by Rugmonster – Be the first to comment
It’s all too common for me to come across a box that is hopelessly overloaded with Apache requests and MySQL queries. Sometimes, it takes some brute force to keep the whole box from going under. When all else fails, I use the following one-liner to kill off all of those queries that have been running for too long. read more »