#!/bin/bash # Amazon Linux 2 postinstall script BASEURL="http://ukr.pw" echo echo "Installing minimal set of software from Amazon Linux repository..." echo yum -y install iptables-services mc mlocate tcpdump vim-enhanced wget telnet ftp lsof bind-utils traceroute echo echo "Installing extra of software from EPEL repository..." echo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum -y install screen lynx whois ARCH=`uname -m` if [ $ARCH = "aarch64" ]; then wget -O /sbin/busybox https://github.com/xerta555/Busybox-Binaries/raw/master/busybox-arm64 else wget -O /sbin/busybox https://busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-$ARCH fi chmod 755 /sbin/busybox echo echo "Performing postinstall configuration..." echo updatedb & wget -O - $BASEURL/vimrc.txt > /root/.vimrc cp -f /root/.vimrc /etc/skel wget -O - $BASEURL/lynx.cfg.txt > /etc/lynx.cfg wget -O - $BASEURL/screenrc.txt > /etc/screenrc cd /home for i in `ls -1`; do cp -f /root/.vimrc $i chown $i: $i/.vimrc done echo "LANG=C" > /etc/locale.conf echo "KEYMAP=us" > /etc/vconsole.conf sed -i -e 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config useradd -u 100 -g 10 -d /home/apl -c "Sasha Polonsky" -m -p '$6$Trc/XYUt$ZPYySNm19KcdUAuFuQJQ6kAI0RhZCq/4HRh2.ipfpo314NyNUkzoRXJMD2Aj8Yepn0CAskwWl5WYKRegzYKHE.' apl echo 'root ALL=(ALL) ALL' > /etc/sudoers echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers chmod 440 /etc/sudoers wget -O - $BASEURL/cs/prompt.txt >> /etc/bashrc wget -O - $BASEURL/ipl.txt >> /etc/bashrc wget -O - $BASEURL/cs/top.cron.txt >> /etc/crontab service chronyd stop busybox ntpd -nqp pool.ntp.org hwclock -w service chronyd start SWAP=`free | grep Swap: | awk '{ print $2 }'` if [ $SWAP -eq 0 ]; then MEM=`free | grep Mem: | awk '{ print $2 }'` SWAPSIZE=$(($MEM/2)) if [ $SWAPSIZE -gt 3100000 ]; then SWAPSIZE=3100000; fi echo echo "No swap found, creating swap file $SWAPSIZE megabytes" echo swapoff -a rm -f /pagefile.sys dd if=/dev/zero of=/pagefile.sys bs=100M count=$(($SWAPSIZE/100000)) chmod 600 /pagefile.sys 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 yum -y remove firewalld ssd-common yum -y install iptables-services wget -O - $BASEURL/6off.txt >> /etc/sysctl.conf wget -O /bin/gp $BASEURL/gp.txt chmod 755 /bin/gp systemctl stop tuned.service systemctl disable tuned.service