Skip to content

Instantly share code, notes, and snippets.

@bborysenko
Last active January 4, 2016 06:09
Show Gist options
  • Save bborysenko/8579825 to your computer and use it in GitHub Desktop.
Save bborysenko/8579825 to your computer and use it in GitHub Desktop.
Initial System Setup for CentOS 6 on DigitalOcean

Initial System Setup:

curl -O https://gist.github.com/bborysenko/8579825/raw/dda86bf9fa24060501029732d1e93dcd67da5609/do_initial_system_setup.sh
chmod u+x do_initial_system_setup.sh
./do_initial_system_setup.sh
reboot
#!/usr/bin/env bash
CURRENT_KERNEL=$(uname -r | sed "s/.$(uname -i)//")
RELEASE=$(cut -d ' ' -f3 /etc/centos-release)
# Removing unused kernel packages
if rpm -qa | grep '^kernel-' | grep -v $CURRENT_KERNEL; then
rpm -qa | grep '^kernel-' | grep -v $CURRENT_KERNEL | xargs yum -y remove
fi
# Installing packages for specific kernel version
yum --releasever=$RELEASE -y install kernel-$CURRENT_KERNEL kernel-firmware-$CURRENT_KERNEL kernel-devel-$CURRENT_KERNEL kernel-headers-$CURRENT_KERNEL
# Disabling kernel update
if ! grep -q exclude=kernel /etc/yum.repos.d/CentOS-Base.repo; then
sed -i -r '1,/\[extras\]/ s/KEY-CentOS-6/KEY-CentOS-6\nexclude=kernel*/' /etc/yum.repos.d/CentOS-Base.repo
fi
# Updating system
yum -y update
# Disabling selinux
sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
# Making 1G swap
dd if=/dev/zero of=/swapfile bs=1024 count=1024k
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile
echo -e "/swapfile\t\tswap\t\t\tswap\tdefaults\t0 0" >> /etc/fstab
# Configuring time and NTP
echo "ZONE=\"Europe/Zaporozhye\"" > /etc/sysconfig/clock
yum install -y ntp && ntpdate pool.ntp.org && chkconfig ntpd on && service ntpd start
# Installing additional tools
yum install -y vim man mlocate yum-changelog yum-priorities git rsync lsof
yum install -y wget telnet traceroute mtr bind-utils iperf nmap tcpdump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment