Last active
November 3, 2020 17:29
-
-
Save jamenlang/49513b92f2d063ea132ee583395c75e7 to your computer and use it in GitHub Desktop.
Dynamic postmulti management script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# assuming all of the instances start with "postf" e.g. "postfix-2" or "postfix-test" | |
mapfile -t instance_array < <( find /etc* -maxdepth 1 -type d -name "postf*" -printf "%f\n" ) | |
for instance in "${instance_array[@]}" | |
do | |
echo "copying resolv.conf for ${instance}" | |
cp /etc/resolv.conf "/var/spool/${instance}/etc/resolv.conf" | |
echo "updating ssl certs for ${instance}" | |
mkdir -p "/var/spool/${instance}/etc/ssl/certs" | |
cp /etc/ssl/certs/ca-certificates.crt "/var/spool/${instance}/etc/ssl/certs/ca-certificates.crt" | |
if [[ ${instance} != postfix ]]; then | |
echo "updating required libraries for ${instance}" | |
mkdir -p "/var/spool/${instance}/lib" | |
cp /var/spool/postfix/lib/x86_64-linux-gnu "/var/spool/${instance}/lib" -r | |
fi | |
echo "updating postfix token ownership for ${instance}" | |
chown -R postfix:postfix /var/spool/${instance}/etc/tokens | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment