#!/bin/bash
a=`ifconfig |grep 'inet addr'|grep -v '127.0.0.1'|sed 's/[ ]*/ /'|awk '{print $2}'| cut -d: -f2 | cut -d. -f4`
cat >> /etc/rc.local << EOF
ulimit -SHn 65535
ulimit -u 65535
mfsmount -H 192.168.199.8 /mfsdata/
EOF
cat >> /etc/resolv.conf << EOF
search chosk.net
nameserver 192.168.1.11
EOF
cat >> /etc/security/limits.conf << EOF
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
tomcat soft nproc 65535
tomcat hard nproc 65535
EOF
#tune kernel parametres
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
EOF
#net.bridge.bridge-nf-call-ip6tables = 0
#net.bridge.bridge-nf-call-iptables = 0
#net.bridge.bridge-nf-call-arptables = 0
sed -i 's/^net.bridge.bridge/#&/' /etc/sysctl.conf
/sbin/sysctl -p
#disable selinux and clear firewall rules
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
/etc/init.d/iptables stop
/etc/init.d/ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
ntpdate pool.ntp.org
#echo "0 0 * * * /usr/sbin/ntpdate ntpdate 202.112.10.36;/sbin/hwclock -w > /dev/null 2>&1" >> /var/spool/cron/root
service crond reload
sed -i 's/^#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
service sshd reload
rpm -Uvh http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum install salt-minion -y
chkconfig salt-minion on
cat >> /etc/salt/minion << EOF
master: 192.168.50.254
id: app-xy-50-$a.chosk.net
EOF
/etc/init.d/salt-minion restart
reboot