maketank-scripts from ansible

This commit is contained in:
2025-08-25 10:40:17 +02:00
parent 8ec81febba
commit 30ce409c4e
15 changed files with 281 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
#!/bin/bash
cd /etc/postfix
nmap -p 3306 10.201.0.4 |grep -q '3306/tcp.*open.*mysql'
if [[ $? == 1 ]]; then
exit 1
fi
MYSQL="mysql --skip-ssl -h 10.201.0.4 -u maketank -pknatekam2007 -B --database=maketank_froxlor"
#virtual_alias_maps
OLD=/etc/postfix/virtual_alias_maps
NEW=/etc/postfix/virtual_alias_maps.new
${MYSQL} -e 'select email,destination from mail_virtual where destination <> "" and destination <> " " order by email ASC'|sed -e 's@ @, @g' |sed '1d' >$NEW
if [[ $(md5sum $NEW|cut -f 1 -d ' ') != $(md5sum $OLD|cut -f 1 -d ' ') ]]; then
cp $NEW $OLD
/usr/sbin/postmap hash:$OLD
fi
#Virtual domains
NEW=/etc/postfix/virtual_mailbox_domains
${MYSQL} -e 'select domain from panel_domains where isemaildomain = "1" order by domain ASC' |tr '\n' ','|sed s/,$//|sed s/^domain,// >$NEW

View File

@@ -0,0 +1,15 @@
#!/usr/bin/ruby
out = %x{/usr/sbin/logtail2 /var/log/mail.info |/usr/sbin/pflogsumm |/bin/grep -v "Grand Totals"|/usr/bin/head -22 |/usr/bin/awk '/\d+/ {print}'}.chomp
out.each_line { |line|
line.delete!('"')
line.strip!
line.chomp!
str = line.split(' ')
met = str[1]
val = str[0].delete('^0-9')
cmd = "/usr/bin/gmetric -x 300 -d 30000 -g mail -t uint16 -D \"Postfix #{met}\" -n postfix_#{met} -v #{val}"
puts cmd
%x{#{cmd}}
}