Add greylistd build.
This commit is contained in:
parent
57a7c0899e
commit
8ec4583aa1
9 changed files with 620 additions and 0 deletions
73
source/greylistd/doinst.sh
Normal file
73
source/greylistd/doinst.sh
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# Version: 0.3.5
|
||||
# Copyright (c) 2005-2022:
|
||||
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
|
||||
# Licensed under the terms of the GNU General Public License version 3.
|
||||
|
||||
install_file() {
|
||||
# $1 = Path of file to process (without leading /, with .new extension)
|
||||
|
||||
[[ -z "$1" ]] || [[ ! -e "$1" ]] && return
|
||||
local OLDFILE="${1%.new}"
|
||||
|
||||
if [[ ! -e "$OLDFILE" ]]; then
|
||||
mv "$1" "$OLDFILE"
|
||||
elif [[ -L "$OLDFILE" ]]; then
|
||||
# |--------|-----------------------------------------------------------|
|
||||
echo "WARNING: $OLDFILE"
|
||||
echo " is a symbolic link - the incoming .new file was not written"
|
||||
echo " to it in order to prevent clobbering something important."
|
||||
echo
|
||||
elif [[ "$(md5sum <"$OLDFILE")" == "$(md5sum <"$1")" ]]; then
|
||||
rm -f "$1"
|
||||
else
|
||||
# |--------|-----------------------------------------------------------|
|
||||
echo "WARNING: $OLDFILE"
|
||||
echo " has been customised since original installation and was not"
|
||||
echo " replaced with the incoming .new file."
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Install new configuration files.
|
||||
install_file "etc/default/greylistd.new"
|
||||
install_file "var/lib/greylistd/whitelist-hosts.new"
|
||||
|
||||
# Add required user/group.
|
||||
GROUPNAME="mail"
|
||||
GROUPID="12"
|
||||
USERNAME="greylist"
|
||||
USERID="37"
|
||||
grep "^$GROUPNAME:" etc/group >/dev/null 2>&1 || {
|
||||
if chroot . usr/sbin/groupadd -g "$GROUPID" -r "$GROUPNAME" && chroot . usr/sbin/grpconv; then
|
||||
echo "NOTICE: Added new system group: $GROUPNAME ($GROUPID)."
|
||||
else
|
||||
echo "WARNING: Failed to add required group: $GROUPNAME."
|
||||
fi
|
||||
echo
|
||||
}
|
||||
grep "^$USERNAME:" etc/passwd >/dev/null 2>&1 || {
|
||||
if chroot . usr/sbin/useradd -d "/var/lib/greylistd" -g "$GROUPNAME" -M -N -r -s /bin/fbash -u "$USERID" "$USERNAME" && chroot . usr/sbin/pwconv; then
|
||||
echo "NOTICE: Added new system user: $USERNAME ($USERID)"
|
||||
else
|
||||
echo "WARNING: Failed to add required user: $USERNAME."
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
# Add service start to rc.local
|
||||
RC="rc.greylistd"
|
||||
fgrep "/etc/rc.d/$RC" etc/rc.d/rc.local >/dev/null 2>&1 || {
|
||||
echo >>etc/rc.d/rc.local
|
||||
echo "[[ -x /etc/rc.d/$RC ]] /etc/rc.d/$RC start" >>etc/rc.d/rc.local
|
||||
}
|
||||
|
||||
# Add service shutdown to rc.local_shutdown
|
||||
fgrep "/etc/rc.d/$RC" etc/rc.d/rc.local_shutdown >/dev/null 2>&1 || {
|
||||
# If rc.local_shutdown doesn't exist, create it.
|
||||
[[ -e etc/rc.d/rc.local_shutdown ]] || {
|
||||
echo "#!/bin/bash" >etc/rc.d/rc.local_shutdown
|
||||
chmod 755 etc/rc.d/rc.local_shutdown
|
||||
}
|
||||
echo >>etc/rc.d/rc.local_shutdown
|
||||
echo "[[ -x /etc/rc.d/$RC ]] && /etc/rc.d/$RC stop" >>etc/rc.d/rc.local_shutdown
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue