# Get it
cd
test -f installed/squirrelmail-webmail-1.4.22.tar.bz2 &&
mv installed/squirrelmail-webmail-1.4.22.tar.bz2 .
test ! -f squirrelmail-webmail-1.4.22.tar.bz2 &&
wget http://downloads.sf.net/squirrelmail/\
squirrelmail-webmail-1.4.22.tar.bz2
# Back up configuration from old versions of SquirrelMail:
for apachedir in /var/www/htdocs \
/usr/local/apache/htdocs /usr/local/apache2/htdocs;
do
find $apachedir -type d -name "squirrelmail-*" 2> /dev/null |
while read smdir;
do
mkdir -p -m 0700 ~/backup/apache/$(basename $smdir)
cp -a $smdir/config/config*.php \
~/backup/apache/$(basename $smdir)
done
done
# Create directories for data and attachments. Default is
# /var/local/squirrelmail, but since no /var/local, I stick with /var/lib...
test ! -d /var/lib/squirrelmail && mkdir -p /var/lib/squirrelmail
( cd /var/lib/squirrelmail
test ! -d attach && mkdir -p attach
test ! -d data && mkdir -p data
chmod 730 . attach data )
# Make that directory owned by the user/group that runs Apache:
test -d /var/www && chown -R root:apache /var/lib/squirrelmail
test -d /usr/local/apache2 && chown -R root:daemon /var/lib/squirrelmail
test -d /usr/local/apache && chown -R root:nobody /var/lib/squirrelmail
# Instead of doing it as done below, you can also unpack SquirrelMail
# in to /usr/local instead, then use an Apache Alias and Directory
# configuration options to allow access to it.
# Unpack the tarball into your web root:
for apachedir in /var/www /usr/local/apache /usr/local/apache2;
do
test ! -d $apachedir && continue
tar xjvf squirrelmail-webmail-1.4.22.tar.bz2 -C ${apachedir}/htdocs/
test "$apachedir" = "/var/www" &&
chown -R root:apache ${apachedir}/htdocs/squirrelmail-webmail-1.4.22
test "$apachedir" = "/usr/local/apache" &&
chown -R root:nobody ${apachedir}/htdocs/squirrelmail-webmail-1.4.22
test "$apachedir" = "/usr/local/apache2" &&
chown -R root:daemon ${apachedir}/htdocs/squirrelmail-webmail-1.4.22
chmod -R o-rwx ${apachedir}/htdocs/squirrelmail-webmail-1.4.22
test -L ${apachedir}/htdocs/squirrelmail &&
rm ${apachedir}/htdocs/squirrelmail
test -d ${apachedir}/htdocs/squirrelmail &&
mv -f ${apachedir}/htdocs/squirrelmail \
${apachedir}/htdocs/squirrelmail.old
ln -sf ${apachedir}/htdocs/squirrelmail-webmail-1.4.22 \
${apachedir}/htdocs/squirrelmail
done
# Make sure Apache is configured to allow symlinks in htdocs (or
# remove the symlink and rename squirrelmail-webmail-1.4.22 to squirrelmail,
# or do it the Alias/Directory way)
# Set Apache to allow .htaccess files under the squirrelmail directory.
# With Apache 2.x, you can add an extra config file for it, and add a
# line to httpd.conf to include it.
# /usr/local/apache2/conf/extra/httpd-squirrelmail.conf
# <Directory /usr/local/apache2/htdocs/squirrelmail>
# AllowOverride AuthConfig Limit
# </Directory>
# (and restart it for the change to take effect)
# Run the (interactive) configuration script:
for apachedir in /var/www /usr/local/apache /usr/local/apache2;
do
test ! -d $apachedir && continue
cd ${apachedir}/htdocs/squirrelmail/config
./conf.pl
done
# Go here with a web browser:
# http://hostyouinstallediton.foo.org/squirrelmail/src/configtest.php
# Set up a cron job to clean up old files from /var/lib/squirrelmail/attach:
find /var/lib/squirrelmail/attach -type f -mtime +1 -exec rm {} \;
# Next, I would suggest tightening up the permissions of the files in
for apachedir in /var/www /usr/local/apache /usr/local/apache2;
do
test ! -d $apachedir && continue
cd ${apachedir}/htdocs/squirrelmail
chown root:root README configure src/configtest.php
chmod 600 README configure src/configtest.php
done
# Become yourself again
exit
# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/squirrelmail-webmail-*.tar.*
mv squirrelmail-webmail-1.4.22.tar.bz2 installed/
# When everything is done, go here to use it:
# http://hostyouinstallediton.foo.org/squirrelmail/
# SquirrelMail IMAP Proxy 1.2.7
# =============================
# This is pretty much just re-packaged up-imapproxy
# Get it
cd
test -f installed/squirrelmail-imap_proxy-1.2.7.tar.bz2 &&
mv installed/squirrelmail-imap_proxy-1.2.7.tar.bz2 .
test ! -f squirrelmail-imap_proxy-1.2.7.tar.bz2 &&
wget http://downloads.sf.net/squirrelmail/\
squirrelmail-imap_proxy-1.2.7.tar.bz2
# Extract it
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "squirrelmail-imap_proxy-*" -exec rm -r {} \;
tar xjvf ~/squirrelmail-imap_proxy-1.2.7.tar.bz2
cd squirrelmail-imap_proxy-1.2.7
test $UID = 0 && chown -R root:root .
# If your OpenSSL is installed under the usual source-installed location
# of /usr/local/ssl, pass --with-openssl=/usr/local/ssl to configure,
# otherwise just running configure should be enough
# Configure and build it
./configure --with-openssl=/usr/local/ssl
make
# Become root
su
# Install a sample configuration file
# ('make install-conf' uses root:bin and 0644, I prefer root:root and 0600)
test ! -f /etc/imapproxy.conf &&
install -m 0600 ./scripts/imapproxy.conf /etc/
# If your basename binary is in /usr/bin and not in /bin (sometimes
# there's a symlink from one to the other), fix it's path in the
# sample init script. Not necessary if yours is in /bin/basename or
# you have a symlink there pointing to the real binary.
cat scripts/imapproxy.init | sed 's|/bin/basename|/usr/bin/basename|' \
> scripts/imapproxy.init.new
test -s scripts/imapproxy.init.new &&
( mv -f scripts/imapproxy.init scripts/imapproxy.init.old
mv -f scripts/imapproxy.init.new scripts/imapproxy.init )
# When you set up SquirrelMail IMAP Proxy to start on boot-up, if it will
# be running on the same host that the IMAP server is, make sure it starts
# after the IMAP server does.
#
# EITHER copy the sample init script to /etc/rc.d/rc.imapproxy:
cp scripts/imapproxy.init /etc/rc.d/rc.imapproxy
chmod 700 /etc/rc.d/rc.imapproxy
rm -f /etc/rc.d/init.d/imapproxy /etc/rc.d/rc?.d/S99imapproxy \
/etc/rc.d/rc?.d/K10imapproxy
# then add something to rc.local to start it like this:
# # SquirrelMail IMAP Proxy
# if [ -x /etc/rc.d/rc.imapproxy ]; then
# /etc/rc.d/rc.imapproxy start
# fi
#
# ...OR set it up the SysV-init way:
install -m 0755 ./scripts/imapproxy.init /etc/rc.d/init.d/imapproxy
for rl in 2 3 4 5; do
test ! -d /etc/rc.d/rc${rl}.d && mkdir -p /etc/rc.d/rc${rl}.d
( cd /etc/rc.d/rc${rl}.d ; ln -sf ../init.d/imapproxy S99imapproxy )
done
( cd /etc/rc.d/rc0.d ; ln -sf ../init.d/imapproxy K10imapproxy )
( cd /etc/rc.d/rc6.d ; ln -sf ../init.d/imapproxy K10imapproxy )
rm -f /etc/rc.d/rc.imapproxy
# Create a user and group for the proxy server to run as:
getent group | grep "^imapproxy:" > /dev/null 2>&1 || groupadd imapproxy
id imapproxy > /dev/null 2>&1 || useradd -g imapproxy imapproxy
# Create the empty chroot directory if not already there (openssh commonly
# uses the same one):
test ! -d /var/empty && install -d -o root -g sys /var/empty
## If you installed imapproxy for the first time, you'll find a heavily
## commented imapproxy.conf in /etc. Here's an example of one that I'm using
## for a server that has IMP running on it for webmail:
# server_hostname localhost
# cache_size 3072
# listen_port 1143
# server_port 143
# cache_expiration_time 300
# proc_username imapproxy
# proc_groupname imapproxy
# stat_filename /var/run/pimpstats
# protocol_log_filename /var/log/imapproxy_protocol.log
# syslog_facility LOG_MAIL
# send_tcp_keepalives no
# enable_select_cache no
# foreground_mode no
# force_tls no
# chroot_directory /var/empty
# enable_admin_commands no
#
# Then you set up the client (SquirrelMail, IMP, RoundCube, whatever) to
# connect to localhost:1143
## If you want 'imapproxy' to show up in 'netstat -l' output, add a line
## like this to /etc/services:
# imapproxy 1143/tcp
# Actually install in.imapproxyd and pimpstat
make install
# If this was an upgrade, stop the running imapproxy:
test -x /etc/rc.d/init.d/imapproxy && /etc/rc.d/init.d/imapproxy stop
test -x /etc/rc.d/rc.imapproxy && /etc/rc.d/rc.imapproxy stop
# (re-)Start it:
test -x /etc/rc.d/init.d/imapproxy && /etc/rc.d/init.d/imapproxy start
test -x /etc/rc.d/rc.imapproxy && /etc/rc.d/rc.imapproxy start
# If you have stat_filename set in your config file, you can now run
# /usr/local/sbin/pimpstat to monitor connections to it
# If you have logrotate, set it to rotate the log file:
cat << EOF > /etc/logrotate.d/imapproxy
/var/log/imapproxy_protocol.log {
rotate 6
daily
notifempty
}
EOF
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become yourself again
exit
# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/squirrelmail-imap_proxy-*.tar.*
mv squirrelmail-imap_proxy-1.2.7.tar.bz2 installed/