#!/bin/bash
DAEMON_LIST="rpcbind isdn abrt-ccpp gcoe-target sendmail NetworkManager abrtd acpid atd auditd autofs avahi-daemon bluetooth cachefilesd certmonger cgconfig cgred conman cpuspeed cups dirsrv dirsrv-snmp dnsmasq dovecot edac fcoe fcoe-target firstboot httpd ip6tables ipa ipa_kpasswd ipmi ipmievd ipsec iscsi iscsid kadmin kprop krb5kdc libvirt-guests lldpad matahari-broker matahari-host matahari-network matahari-service matahari-sysconfig mcelogd mdmonitor multipathd netconsole netfs oddjobd pki-cad portreserve postfix psacct qpidd quota_nld rdisc restorecond rhnsd rhsmcertd rpcgssd rpcidmapd rpcsvcgssd rstatd rusersd rwhod saslauthd sblim-sfcb smartd snmpd snmptrapd spamassassin spice-vdagentd sssd stap-server stinit tgtd tog-pegasus tomcat6 tunedii vncserver watchdog wdaemon wpa_supplicant ypbind iptables pcscd"
backup_dir="/root/rockplace"
date=`date +%Y_%m_%d_%H_%M_%S`
################## START ################
clear
echo "/etc/ data $backup_dir/etc_$date Copying........."
if ! [ -d $backup_dir ];then
mkdir $backup_dir
fi
cp -ar /etc/ $backup_dir/etc_$date
echo "Backup Susscess"
##### Service Daemon arrangement
check="n"
echo -n "1. Service Daemon arrangement Start ? [y/n] Default [n] : "
read check
if [ $check = "y" ];then
echo "Not Use Daemon off"
for daemon in `echo $DAEMON_LIST`
do
chkconfig $daemon --level 2345 off 2>/dev/null
chkconfig vsftpd --level 2345 on 2>/dev/null
chkconfig telnet --level 2345 on 2>/dev/null
chkconfig ntpd --level 2345 on 2>/dev/null
done
echo " Daemon Off Suscess"
fi
####### Default Setting ###
check="n"
echo -n "2. Default Setting Start ? [y/n] Default [n] : "
read check
if [ $check = "y" ];then
sed -i 's/HISTORY=7/HISTORY=28/g' /etc/sysconfig/sysstat
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/plugins=ifcfg-rh/#plugins=ifcfg-rh/g' /etc/NetworkManager/NetworkManager.conf
#sed -i 's/root/#root/g' /etc/vsftpd/user_list
#sed -i 's/root/#root/g' /etc/vsftpd/ftpusers
sed -i 's/MAILTO=root/MAILTO=""/g' /etc/crontab
echo "options ipv6 disable=1" >> /etc/modprobe.d/ipv6.conf
sed -i 's/\*/#\*/g' /etc/security/limits.d/90-nproc.conf
sed -i 's/root/#root/g' /etc/security/limits.d/90-nproc.conf
sed -i 's/kernel.sysrq = 0/kernel.sysrq = 1/g' /etc/sysctl.conf
cat << EOF >> /etc/sysctl.conf
kernel.panic_on_io_nmi = 1
kernel.panic_on_unrecovered_nmi = 1
kernel.unknown_nmi_panic = 1
EOF
cat << EOF > /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
OPTIonS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"
EOF
sed -i 's/server 0/\#server 0/g' /etc/ntp.conf
sed -i 's/server 1/\#server 1/g' /etc/ntp.conf
sed -i 's/server 2/\#server 2/g' /etc/ntp.conf
sed -i 's/server 3/\#server 3/g' /etc/ntp.conf
cat << EOF >> /etc/ntp.conf
server 166.125.7.177
server 166.125.7.178
EOF
mpathconf --enable
chkconfig ntpd on
fi