Install Qmail by copy/paste

Install qmail by copy/paste… I suggest in small blocks at a time

Code:

#!/bin/sh SERVERNAME=`hostname` cd /usr/local/src/ wget http://qmail.linocomm.net/netqmail-1.06.tar.gz wget http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/daemontools-0.76.errno.patch wget http://qmail.org/moni.csi.hu/pub/glibc-2.3.1/ucspi-tcp-0.88.errno.patch # install qmail: umask 022 mkdir -p /package cp daemontools-0.76.tar.gz /package chmod 1755 /package tar -xzf netqmail-1.06.tar.gz tar -xzf ucspi-tcp-0.88.tar.gz cd /package tar -xzf daemontools-0.76.tar.gz mkdir /var/qmail cd /usr/local/src/netqmail-1.06 echo " /usr/sbin/groupadd nofiles /usr/sbin/useradd -g nofiles -d /var/qmail/alias alias /usr/sbin/useradd -g nofiles -d /var/qmail qmaild /usr/sbin/useradd -g nofiles -d /var/qmail qmaill /usr/sbin/useradd -g nofiles -d /var/qmail qmailp /usr/sbin/groupadd qmail /usr/sbin/useradd -g qmail -d /var/qmail qmailq /usr/sbin/useradd -g qmail -d /var/qmail qmailr /usr/sbin/useradd -g qmail -d /var/qmail qmails" > IDS /bin/sh IDS make setup check ./config-fast $SERVERNAME cd /usr/local/src/ucspi-tcp-0.88 patch -p1 < ../ucspi-tcp-0.88.errno.patch make make setup check cd /package/admin/daemontools-0.76 patch -p1 < /usr/local/src/daemontools-0.76.errno.patch package/install echo "./Maildir/" > /var/qmail/control/defaultdelivery echo 120 > /var/qmail/control/concurrencyincoming echo 120 > /var/qmail/control/concurrencyremote echo 120 > /var/qmail/control/concurrencylocal chmod 644 /var/qmail/control/concurrencyincoming chmod 644 /var/qmail/control/concurrencyremote chmod 644 /var/qmail/control/concurrencylocal echo '#!/bin/sh # Using stdout for logging # Using control/defaultdelivery from qmail-local to deliver messages by default ' > /var/qmail/rc echo "exec env – PATH="/var/qmail/bin:$PATH" \ qmail-start "`cat /var/qmail/control/defaultdelivery`" " >> /var/qmail/rc chmod 755 /var/qmail/rc mkdir /var/log/qmail # the qmailctl script­: echo '#!/bin/sh # For Red Hat chkconfig # chkconfig: – 80 30 # description: the qmail MTA ' > /var/qmail/bin/qmailctl echo 'PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin export PATH QMAILDUID=`id -u qmaild` NOFILESGID=`id -g qmaild` case "$1' in start) echo "Starting qmail" if svok /service/qmail-send ; then svc -u /service/qmail-send else echo qmail-send supervise not running fi if svok /service/qmail-smtpd ; then svc -u /service/qmail-smtpd else echo qmail-smtpd supervise not running fi if [ -d /var/lock/subsys ]; then touch /var/lock/subsys/qmail fi ;; stop) echo "Stopping qmail…" echo " qmail-smtpd" svc -d /service/qmail-smtpd echo " qmail-send" svc -d /service/qmail-send if [ -f /var/lock/subsys/qmail ]; then rm /var/lock/subsys/qmail fi ;; stat) svstat /service/qmail-send svstat /service/qmail-send/log svstat /service/qmail-smtpd svstat /service/qmail-smtpd/log qmail-qstat ;; doqueue|alrm|flush) echo "Flushing timeout table and sending ALRM signal to qmail-send." /var/qmail/bin/qmail-tcpok svc -a /service/qmail-send ;; queue) qmail-qstat qmail-qread ;; reload|hup) echo "Sending HUP signal to qmail-send." svc -h /service/qmail-send ;; pause) echo "Pausing qmail-send" svc -p /service/qmail-send echo "Pausing qmail-smtpd" svc -p /service/qmail-smtpd ;; cont) echo "Continuing qmail-send" svc -c /service/qmail-send echo "Continuing qmail-smtpd" svc -c /service/qmail-smtpd ;; restart) echo "Restarting qmail:" echo "* Stopping qmail-smtpd." svc -d /service/qmail-smtpd echo "* Sending qmail-send SIGTERM and restarting." svc -t /service/qmail-send echo "* Restarting qmail-smtpd." svc -u /service/qmail-smtpd ;; cdb) tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp chmod 644 /etc/tcp.smtp.cdb echo "Reloaded /etc/tcp.smtp." ;; help) cat << HELP stop — stops mail service (smtp connections refused, nothing goes out) start — starts mail service (smtp connection accepted, mail can go out) pause — temporarily stops mail service (connections accepted, nothing leaves) cont — continues paused mail service stat — displays status of mail service cdb — rebuild the tcpserver cdb file for smtp restart — stops and restarts smtp, sends qmail-send a TERM & restarts it doqueue — schedules queued messages for immediate delivery reload — sends qmail-send HUP, rereading locals and virtualdomains queue — shows status of queue alrm — same as doqueue flush — same as doqueue hup — same as reload HELP ;; *) echo "Usage: $0 {start|stop|restart|doqueue|flush|reload|stat|pause|cont|cdb|queue|help}" exit 1 ;; esac exit 0 ' >> /var/qmail/bin/qmailctl ln -s /var/qmail/bin/qmailctl /etc/rc.d/init.d/qmail ln -s ../init.d/qmail /etc/rc.d/rc0.d/K30qmail ln -s ../init.d/qmail /etc/rc.d/rc1.d/K30qmail ln -s ../init.d/qmail /etc/rc.d/rc2.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc3.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc4.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc5.d/S80qmail ln -s ../init.d/qmail /etc/rc.d/rc6.d/K30qmail chmod 755 /var/qmail/bin/qmailctl ln -s /var/qmail/bin/qmailctl /usr/bin mkdir -p /var/qmail/supervise/qmail-send/log mkdir -p /var/qmail/supervise/qmail-smtpd/log echo '#!/bin/sh' > /var/qmail/supervise/qmail-send/run echo "exec /var/qmail/rc " >> /var/qmail/supervise/qmail-send/run echo '#!/bin/sh' > /var/qmail/supervise/qmail-send/log/run echo "exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t n40 s5242880 /var/log/qmail " >> /var/qmail/supervise/qmail-send/log/run cd /var/qmail/control ln -s ../outgoingip outgoingip echo '#!/bin/sh' > /var/qmail/supervise/qmail-smtpd/run echo 'QMAILDUID=`id -u qmaild` NOFILESGID=`id -g qmaild` MAXSMTPD=`cat /var/qmail/control/concurrencyincoming` LOCAL=`head -1 /var/qmail/control/me` if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in echo /var/qmail/supervise/qmail-smtpd/run exit 1 fi exec /usr/local/bin/softlimit -m 2000000 \ /usr/local/bin/tcpserver -v -H -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \ -u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \ /var/qmail/bin/qmail-smtpd 2>&1' >> /var/qmail/supervise/qmail-smtpd/run echo '#!/bin/sh' > /var/qmail/supervise/qmail-smtpd/log/run echo "exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t n40 s5242880 /var/log/qmail/smtpd " >> /var/qmail/supervise/qmail-smtpd/log/run mkdir -p /var/log/qmail/smtpd chown qmaill /var/log/qmail /var/log/qmail/smtpd chmod 755 /var/qmail/supervise/qmail-send/run chmod 755 /var/qmail/supervise/qmail-send/log/run chmod 755 /var/qmail/supervise/qmail-smtpd/run chmod 755 /var/qmail/supervise/qmail-smtpd/log/run ln -s /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-smtpd /service sleep 10 qmailctl stop #create system aliases: echo postmaster > /var/qmail/alias/.qmail-root echo postmaster > /var/qmail/alias/.qmail-postmaster ln -s .qmail-postmaster /var/qmail/alias/.qmail-mailer-daemon chmod 644 /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-postmaster echo '127.:allow,RELAYCLIENT=""' >>/etc/tcp.smtp qmailctl cdb /etc/rc.d/init.d/sendmail stop rpm -e --nodeps sendmail # link qmail version of sendmail: rm /usr/lib/sendmail rm /usr/sbin/sendmail ln -s /var/qmail/bin/sendmail /usr/lib ln -s /var/qmail/bin/sendmail /usr/sbin qmailctl start
cd /etc/pki/tls cd private openssl genrsa -des3 -out `hostname`.key 1024 # password: whatever you want # TO MAKE IT HAVE NO PASSPHRASE (optional): cp `hostname`.key `hostname`.key.orig openssl rsa -in `hostname`.key.orig -out `hostname`.key # MAKE THE CSR cd ../csr openssl req -new -key ../private/`hostname`.key -out `hostname`.csr # answer the questions # MAKE THE SELF-SIGNED CERT: cd ../certs openssl x509 -req -days 1800 -in ../csr/`hostname`.csr -signkey ../private/`hostname`.key -out `hostname`.crt

AllowOverride All is really helpful when you are the admin of the server and want full control over your site:

Code:

<Directory /www/modphp>
Options FollowSymLinks MultiViews
AllowOverride All
</Directory>

Read the rest of this entry »

Below is a method of backing up your web site document root and MySQL. Assuming this is the only thing on your server you care about, but you could easily extend this to include any set of directories you wish to backup.

Put this in cron:

# backup my site:
1 1 * * * /scripts/backup.sh > /dev/null 2>&1

Read the rest of this entry »

Have you ever worked in a CVS module, added a deep tree of directories and files and needed to add them to CVS. If you have, you may have had to go through a painful process of adding one dir at a time, then all the files in that dir, then repeat until you’ve done all the dirs. I have a solution for that:

Just run this over and over again, until all files are added:

Read the rest of this entry »

Use with caution, this will not make backups:

search="searchRegExp" replace="replaceStr" egrep -lri --exclude="Entries" --exclude="*.gif" --exclude="*.WAV" --exclude="*.wav" --exclude="*.zip"  "$search" * | xargs perl -pi -e "s/$search/$replace/gi"

the “gi” option means globally, case-insensitive, so take the “i” off if you want it to be case-sensative.

If you want to make backup files, replace “perl -pi” with “perl -pi.bak”

Read the rest of this entry »

PostPosted: Sat Sep 10, 2005 6:00 pm Post subject: Reply with quote

Imagine that you are supposed to type in an email address into a form. You would typically type an email address that may be stored in your address book from a MySQL database. There are too many emails in your address book to pre-populate into a list on the page. Instead you want to start typing and have addresses that match what you’ve typed so far appear in a drop down. We will fetch the emails to populate the drop down from the server, on the fly, in the background.

Read the rest of this entry »

I’m just getting the code in the post for now… hopefully I’ll have time to come back and document it for you. I am excluding my config.php on purpose, you’ll need to define you’re own constants in there.

<?php

require_once(“config.php”);
require_once(“nusoap.php”);

/*
* This function takes an $email address and returns an array of email addresses
* that are the given email address’s recent contacts from their address book.
*
* @param string $email (the email address of the user)
* @param string $token (a password that is used for authentication for use of this function, it is NOT the email users password.)
*/
function getAutocompleteContacts( $email, $num, $token ) {

Read the rest of this entry »