X-Git-Url: http://git.onelab.eu/?p=plcrt.git;a=blobdiff_plain;f=plcrt.init;h=e6db40d9ceba3e8380f9eedf97c3140af4fac2be;hp=f72810b97543257c44811ef9e9cbea4bd12c3a93;hb=1021061680a3379f70045f8be06becd1a2117449;hpb=2361d6e83f529403ff1e8801083fc92b1eb720d6 diff --git a/plcrt.init b/plcrt.init index f72810b..e6db40d 100644 --- a/plcrt.init +++ b/plcrt.init @@ -17,6 +17,12 @@ local_config=/etc/planetlab/configs/site.xml PLCRTPATH=/usr/share/plcrt +function gethostbyaddr () +{ + python -c 'import socket; import sys; print socket.gethostbyaddr(sys.argv[1])[0]' $1 2>/dev/null +} + + # Be verbose set -x @@ -167,10 +173,10 @@ function check_rt_aliases () sed -i -e "s/^security.*root//g" /etc/aliases cat <> /etc/aliases # added by RT init scripts for default queues. -support: "|/usr/sbin/rt-mailgate --queue support --action correspond --url http://localhost/rt3/" -monitor: "|/usr/sbin/rt-mailgate --queue monitor --action correspond --url http://localhost/rt3/" -security: "|/usr/sbin/rt-mailgate --queue security --action correspond --url http://localhost/rt3/" -legal: "|/usr/sbin/rt-mailgate --queue legal --action correspond --url http://localhost/rt3/" +support: "|/usr/sbin/rt-mailgate --queue support --action correspond --url http://$PLC_RT_HOST/rt3/" +monitor: "|/usr/sbin/rt-mailgate --queue monitor --action correspond --url http://$PLC_RT_HOST/rt3/" +security: "|/usr/sbin/rt-mailgate --queue security --action correspond --url http://$PLC_RT_HOST/rt3/" +legal: "|/usr/sbin/rt-mailgate --queue legal --action correspond --url http://$PLC_RT_HOST/rt3/" EOF /usr/bin/newaliases fi @@ -216,23 +222,30 @@ check_rt_sendmail () # copy to live configuration cp -f $tmp_sendmailmc /etc/mail/sendmail.mc rm -f $tmp_sendmailmc + fi - # edit /etc/mail/access to add local IP - if ! grep "$PLC_RT_IP" /etc/mail/access ; then - echo "$PLC_RT_IP RELAY" >> /etc/mail/access - makemap hash /etc/mail/access.db < /etc/mail/access - fi - if [ ! -f /etc/smrsh/rt-mailgate ] ; then - ln -s /usr/sbin/rt-mailgate /etc/smrsh/rt-mailgate - fi - if ! grep "$PLC_RT_HOST" /etc/mail/local-host-names ; then - # edit /etc/mail/local-host-names - echo "$PLC_RT_HOST" >> /etc/mail/local-host-names - fi - m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf - service sendmail restart + # edit /etc/mail/access to add local IP + if ! grep "$PLC_RT_IP" /etc/mail/access ; then + echo "$PLC_RT_IP RELAY" >> /etc/mail/access + makemap hash /etc/mail/access.db < /etc/mail/access + fi + + if [ ! -f /etc/smrsh/rt-mailgate ] ; then + ln -s /usr/sbin/rt-mailgate /etc/smrsh/rt-mailgate fi + # TODO: fix this to only append the hostnaen once, rather than appending + if ! grep "$PLC_RT_HOST" /etc/mail/local-host-names ; then + # edit /etc/mail/local-host-names + echo "$PLC_RT_HOST" >> /etc/mail/local-host-names + IP=$( gethostbyname $PLC_RT_HOST ) + REVHOST=$( gethostbyaddr $IP ) + if [ -n "$REVHOST" ] ; then + echo "$REVHOST" >> /etc/mail/local-host-names + fi + fi + m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf + service sendmail restart }