#!/bin/bash exec > /root/log.txt 2>&1 set -x # CentOS postinstall script BASEURL="http://ukr.pw" echo echo "Installing minimal set of software..." echo yum -y install wget screen lynx mc jwhois telnet ftp ntpdate traceroute mlocate lsof tcpdump openssh-clients vim-enhanced bind-utils tcpdump xz man echo echo "Performing postinstall configuration..." echo updatedb & wget -O - $BASEURL/wgetrc.txt > /etc/wgetrc wget -O - $BASEURL/vimrc.txt > /etc/vimrc wget -O - $BASEURL/lynx.cfg.txt > /etc/lynx.cfg wget -O - $BASEURL/screenrc.txt > /etc/screenrc echo LANG=\"C\" > /etc/sysconfig/i18n sed -i -e 's/\[1-6\]/1/' /etc/sysconfig/init sed -i -e 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config setenforce Permissive if [ -f /boot/grub/grub.conf ]; then sed -i -e "s/quiet/quiet vt.default_utf8=0/" /boot/grub/grub.conf fi wget -O /bin/rf $BASEURL/cs/rf.txt && chmod 755 /bin/rf echo 'root ALL=(ALL) ALL' > /etc/sudoers echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers chmod 440 /etc/sudoers useradd -u 100 -g 10 -d /home/apl -c "Sasha Polonsky" -m -p '$6$Trc/XYUt$ZPYySNm19KcdUAuFuQJQ6kAI0RhZCq/4HRh2.ipfpo314NyNUkzoRXJMD2Aj8Yepn0CAskwWl5WYKRegzYKHE.' apl userdel -r -f centos sed -i -e '11,44d' /etc/bashrc wget -O - $BASEURL/cs/prompt.txt >> /etc/bashrc wget -O - $BASEURL/ipl.txt >> /etc/bashrc sed -e "s/^uucp/#uucp/" -i /etc/rsyslog.conf service rsyslog restart sed -i -e 's/^weekly/monthly/' -e '/^monthly/a minsize 1M' -e 's/rotate 4/rotate 1/' /etc/logrotate.conf sed -i '/spooler/d' /etc/logrotate.d/syslog rm -rf /var/log/spooler /var/log/tallylog /var/log/anaconda* wget -O - $BASEURL/6off.txt >> /etc/sysctl.conf wget -O /bin/gp $BASEURL/gp.txt chmod 755 /bin/gp echo kernel-`uname -r` > /root/kernel.txt echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config sed -i -e '/^GSSAPIAuthentication/s/yes/no/' -e '/^UsePAM/s/yes/no/' -e 's/^#UseDNS yes/UseDNS no/' -e '/^PasswordAuthentication/s/no/yes/' /etc/ssh/sshd_config service sshd restart ntpdate pool.ntp.org hwclock -w SWAP=`free | grep Swap: | awk '{ print $2 }'` if [ $SWAP -eq 0 ]; then echo echo "No swap space found, creating swap file 50% of RAM size..." echo MEM=`free | grep Mem: | awk '{ print $2 }'` swapoff -a rm -f /pagefile.sys dd if=/dev/zero of=/pagefile.sys bs=100K count=$(($MEM*50/10000)) mkswap -f /pagefile.sys grep -v swap /etc/fstab > /tmp/fstab mv -f /tmp/fstab /etc echo "/pagefile.sys none swap sw 0 0" >> /etc/fstab swapon -a fi echo echo "Cleaning up..." echo for i in INPUT OUTPUT FORWARD; do iptables -P $i ACCEPT; iptables -F $i ; done service iptables save for i in netfs auditd iptables; do chkconfig --level 2345 $i off; done yum -y update # Unfinished part. rc.local executes after this script, so it takes one more # step to schedule something at next reboot. #echo 'KERNELS=`rpm -qa | grep kernel-2.6 | grep -v devel | wc -l`' >> /etc/rc.d/rc.local #echo 'if [ $KERNELS -gt 1 ]; then yum -y remove `cat /root/kernel.txt`; fi' >> /etc/rc.d/rc.local #echo 'rm -f /root/kernel.txt' >> /etc/rc.d/rc.local #echo 'head -n -4 /etc/rc.d/rc.local > /tmp/rc.local && mv -f /tmp/rc.local /etc/rc.d/rc.local' >> /etc/rc.d/rc.local