#!/bin/bash
source /root/envsetup/conf.sh

# generate post-deployment conf file
echo "SOURCES.LIST" > /root/deployment.results
cat /etc/apt/sources.list | grep ^deb >> /root/deployment.results
echo "" >> /root/deployment.results

echo "SOURCES.LIST - SKYREACH_HOST" >> /root/deployment.results
cat /etc/apt/sources.list.d/skyreach.list >> /root/deployment.results
echo "" >> /root/deployment.results

echo "NETWORK" >> /root/deployment.results
cat /etc/network/interfaces | grep -v '#' >> /root/deployment.results
echo "" >> /root/deployment.results

echo "RUNNING NETWORK" >> /root/deployment.results
ifconfig >> /root/deployment.results
echo "" >> /root/deployment.results

echo "DNS" >> /root/deployment.results
cat /etc/resolv.conf >> /root/deployment.results
echo "" >> /root/deployment.results

echo "NGINX" >> /root/deployment.results
grep server_name /etc/nginx/sites-enabled/* | uniq >> /root/deployment.results
echo "" >> /root/deployment.results

echo "RTMP" >> /root/deployment.results
cat /etc/hca/rtmp.ini | grep -v '#' >> /root/deployment.results
echo "" >> /root/deployment.results

echo "SERVICES" >> /root/deployment.results
echo "mediaserver $(service mediaserver status | grep Active)" >> /root/deployment.results
echo "WowzaStreamingEngine $(service WowzaStreamingEngine status | grep Active)" >> /root/deployment.results
echo "apt-cacher-ng $(service apt-cacher-ng status | grep Active)" >> /root/deployment.results
echo "campus-manager $(service campus-manager status | grep Active)" >> /root/deployment.results
echo "celerity-server $(service celerity-server status | grep Active)" >> /root/deployment.results
echo "msmonitor $(service msmonitor status | grep Active)" >> /root/deployment.results
echo "munin-node $(service munin-node status | grep Active)" >> /root/deployment.results
echo "mysql $(service mysql status | grep Active)" >> /root/deployment.results
echo "nginx $(service nginx status | grep Active)" >> /root/deployment.results
echo "postfix $(service postfix status | grep Active)" >> /root/deployment.results
echo "ssh $(service ssh status | grep Active)" >> /root/deployment.results
echo "uwsgi $(service uwsgi status | grep Active)" >> /root/deployment.results
echo "" >> /root/deployment.results

cat /root/deployment.results | mail -aFrom:${EMAIL_SENDER} -s "$(hostname) deployed configuration" deployment@ubicast.eu
echo -e "${CYAN}A mail has been sent to deployment@ubicast.eu${NC}"
