/usr/lib/cyrus/bin/makedirs is in cyrus-common 2.4.17+caldav~beta9-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | #!/bin/sh -e
#
# cyrus-makedirs - Parses a Cyrus imap.d configuration file, and creates
# the correct directory trees for all partitions
#
# Copyright 2001,2002 by Henrique de Moraes Holschuh <hmh@debian.org.
# Released under the terms of the GNU General Public License (GPL) version 2
# See lib/util.c, dir_hash_c for Cyrus' directory hashing
# for the new hash style
#HASHDIRS="A B C D E F G H I J K L M N O P Q R S T U V W"
# for the old hash style
HASHDIRS="a b c d e f g h i j k l m n o p q r s t u v w x y z"
# Sane locale, please
LC_ALL=C
export LC_ALL
CYRUSOPTFILESYS=1
CONF=/etc/imapd.conf
[ -r /etc/default/cyrus-imapd ] && . /etc/default/cyrus-imapd
getconf () {
if [ -r "$CONF" ]; then
confvalue=$(sed --silent -e "/^[[:blank:]]*$1:/ { \
s#^[[:blank:]]*$1:[[:blank:]]*## \
p
}" < "$CONF" | head -1)
result=${confvalue:-$2}
else
result=${2}
fi
}
killsquat=0
[ "$1" = "--cleansquat" ] && {
killsquat=1
shift
}
getconf configdirectory /var/lib/cyrus
confdir="$result"
[ -d "$confdir" ] || {
echo $0: $confdir is not an directory. Aborting...
exit 2
}
getconf sievedir /etc/sieve
sievedir="$result"
getconf sieveusehomedir 0
case "$result" in
1|t|true|yes|on) nosievedir=1
;;
*) nosievedir=0
;;
esac
getconf hashimapspool 0
case "$result" in
1|t|true|yes|on) hashspool=1
;;
*) hashspool=0
;;
esac
# Partitions list
if [ -r "${CONF}" ]; then
partitions=`sed --silent -e "/^[[:blank:]]*partition-[[:alnum:]]\+:/ { \
s#^[[:blank:]]*partition-[[:alnum:]]\+:[[:blank:]]*## \
p
} " < "$CONF" | sort | uniq | xargs`
else
# Set default partitions list
partitions="/var/spool/cyrus/mail /var/spool/cyrus/news"
fi
# First, fix up the entire confdir subtree
echo "Creating/updating cyrus control directories in ${confdir}..."
[ -d "$confdir" ] || mkdir -p "$confdir"
chmod 750 "$confdir"
for i in db proc socket log msg user quota lock; do
[ -d "$confdir/$i" ] || mkdir -p "$confdir/$i"
chmod 700 "$confdir/$i"
done
chmod 750 $confdir/socket
for i in user quota lock; do
for j in $HASHDIRS ; do
[ -d "$confdir/$i/$j" ] || mkdir "$confdir/$i/$j"
done
done
find -H "$confdir" \( -not -user cyrus -or -not -group mail \) -execdir chown cyrus:mail '{}' \;
# Now, create the spool partitions
for i in $partitions ; do
echo "Creating/updating partition spool $i..."
[ -d "$i" ] || mkdir -p "$i"
chmod 750 "$i"
[ $hashspool -eq 1 ] && {
for j in $HASHDIRS ; do
[ -d "$i/$j" ] || mkdir "$i/$j"
done
}
[ -d "$i/stage." ] || mkdir "$i/stage."
find -H "$i" \( -not -user cyrus -or -not -group mail \) -execdir chown cyrus:mail '{}' \;
# and kill any squatter indexes
[ $killsquat -ne 0 ] && find -H "$i" -name 'cyrus.squat' -type f -exec rm -f "{}" \;
done
# And the sieve directory structure
[ $nosievedir -eq 0 ] && {
[ -d "$sievedir" ] || mkdir "$sievedir"
chmod 755 "$sievedir"
for j in $HASHDIRS ; do
[ -d "$sievedir/$j" ] || mkdir "$sievedir/$j"
chmod 755 "$sievedir/$j"
done
find -H "$sievedir" \( -not -user cyrus -or -not -group mail \) -execdir chown cyrus:mail '{}' \;
}
[ "x${CYRUSOPTFILESYS}" != "x1" ] && exit 0
#
# Fix attributes for every partition
#
# ext2: Don't use ext2 for Cyrus spools. But if you must, enable Sync writes
# ext3: Journal data too, since that improves access time a LOT
# (maybe in the future, there's a bug in 2.4.18 ext3 w/ +j)
#
echo "Trying to optimize Cyrus partitions, edit /etc/default/cyrus-imapd to disable..."
partsys="${confdir} ${partitions}"
filesys=`df -P -T ${partsys} | sed -e "1 d" -e "s/ \+/ /g" | cut -d " " -f 2 | xargs`
for i in ${filesys} ; do
case ${i} in
ext2)
echo "Setting attributes to +S for ${partsys%% *}..."
find -H "${partsys%% *}" -type d -exec chattr +S "{}" \;
;;
ext3)
echo "Setting attributes to -S -j for ${partsys%% *}..."
find -H "${partsys%% *}" -type d -exec chattr -S -j "{}" \;
;;
esac
partsys="${partsys#* }"
done
exit 0
|