0x1949 Team - FAZEMRX - MANAGER
Edit File: cpanel-mailman.preinst
#!/bin/sh set -e export USE_PYTHON="/usr/bin/python2.7" ## <asset scriplets/pre> set -e USER=mailman GROUP=mailman MAILMAN_ROOT=/usr/local/cpanel/3rdparty/mailman # USE_PYTHON checkUserGroup() { echo "check mailman required users" # These users need to exist, and the RPM should fail to install if # they do not. id nobody id mail mkdir -p ${MAILMAN_ROOT} # add group /usr/bin/getent group $GROUP >/dev/null || \ /usr/sbin/groupadd -r $GROUP # add user if needed /usr/bin/getent passwd $USER >/dev/null || \ /usr/sbin/useradd -r -g $GROUP -M -d ${MAILMAN_ROOT} \ -s /usr/local/cpanel/bin/noshell \ -c "GNU Mailing List Manager" $USER } checkPython() { echo "checking Python" if [ -z $USE_PYTHON ]; then echo "Do not know which python to use: set USE_PYTHON" exit 1 fi if [ -x $USE_PYTHON ]; then echo "python: ${USE_PYTHON} ok" return fi # create symlink if missing [ currently not own by any RPM ] # view install/Python.pm logic ( [ -x /usr/bin/python2 ] && ln -s -f /usr/bin/python2 ${USE_PYTHON} ) \ || ( [ -x /usr/local/bin/python2 ] && ln -s /usr/local/bin/python2 ${USE_PYTHON} ) test -x ${USE_PYTHON} return } checkCrontab() { echo "checking mailman crontab" ( crontab -u mailman -l >/dev/null 2>&1 && crontab -u mailman -r ) ||: } sanitycheckUser() { # should not be required if [ "x$(id -u mailman 2>/dev/null)" = "x" ]; then echo "Missing mailman user" fi # We'll make sure any existing mailman user has the right group and # homedir, if it's not already correct. mmuser=$(getent passwd mailman ||:) mmgrp=$(getent group mailman ||:) if [ "x$mmgrp" != "x" ]; then # Ensure that: # (a) the gid of the mailman group is the mailman user's primary gid # (b) the supplementary users in the mailman group include mailman if [ "$(echo $mmgrp | awk -F: '{print $3}')" != "$(echo $mmuser | awk -F: '{print $4}')" -o "x$(echo $mmgrp | awk -F: '$4 ~ /mailman/{print $4}')" = "x" ] then /usr/sbin/usermod -g $GROUP -G $GROUP $USER fi fi # If the mailman homedir is wrong, correct it if [ "x$(echo $mmuser | awk -F: '{print $6}')" != "x${MAILMAN_ROOT}" ]; then /usr/sbin/usermod -d ${MAILMAN_ROOT} $USER fi } runPre() { echo "# pre mailman" echo "# - checkUserGroup" checkUserGroup; echo "# - checkPython" checkPython; echo "# - checkCrontab" checkCrontab; echo "# - sanitycheckUser" sanitycheckUser; echo "# pre mailman: done" } ## </asset> case "$1" in install) runPre; ;; upgrade) runPre; ;; esac exit 0