Skip to content

Instantly share code, notes, and snippets.

@efeldhusen
Last active May 23, 2023 04:02
Show Gist options
  • Select an option

  • Save efeldhusen/4bea2031525203b1658b444f4709c12c to your computer and use it in GitHub Desktop.

Select an option

Save efeldhusen/4bea2031525203b1658b444f4709c12c to your computer and use it in GitHub Desktop.

Revisions

  1. efeldhusen revised this gist May 25, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vmware-template.centos7.sh
    Original file line number Diff line number Diff line change
    @@ -10,13 +10,13 @@
    /sbin/service auditd stop

    #remove old kernels
    /usr/bin/package-cleanup oldkernels count=1
    /usr/bin/package-cleanup --oldkernels --count=1

    #clean yum cache
    /usr/bin/yum clean all

    #force logrotate to shrink logspace and remove old logs as well as truncate logs
    /usr/bin/logrotate -f /etc/logrotate.conf
    /usr/sbin/logrotate -f /etc/logrotate.conf
    /bin/rm -f /var/log/*-???????? /var/log/*.gz
    /bin/rm -f /var/log/dmesg.old
    /bin/rm -rf /var/log/anaconda
  2. efeldhusen revised this gist May 25, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vmware-template.centos7.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@

    # Install optional packages
    /usr/bin/yum install -y epel-release
    /usr/bin/yum install -y bash-completion htop yum-utils dkms
    /usr/bin/yum install -y bash-completion htop yum-utils dkms open-vm-tools

    #stop logging services
    /sbin/service rsyslog stop
  3. efeldhusen created this gist May 25, 2017.
    43 changes: 43 additions & 0 deletions vmware-template.centos7.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/bin/bash
    #Paths are for Centos 7.x

    # Install optional packages
    /usr/bin/yum install -y epel-release
    /usr/bin/yum install -y bash-completion htop yum-utils dkms

    #stop logging services
    /sbin/service rsyslog stop
    /sbin/service auditd stop

    #remove old kernels
    /usr/bin/package-cleanup –oldkernels –count=1

    #clean yum cache
    /usr/bin/yum clean all

    #force logrotate to shrink logspace and remove old logs as well as truncate logs
    /usr/bin/logrotate -f /etc/logrotate.conf
    /bin/rm -f /var/log/*-???????? /var/log/*.gz
    /bin/rm -f /var/log/dmesg.old
    /bin/rm -rf /var/log/anaconda
    /bin/cat /dev/null > /var/log/audit/audit.log
    /bin/cat /dev/null > /var/log/wtmp
    /bin/cat /dev/null > /var/log/lastlog
    /bin/cat /dev/null > /var/log/grubby

    #remove udev hardware rules
    /bin/rm -f /etc/udev/rules.d/70*

    #remove uuid from ifcfg scripts
    /bin/sed -i '/^(HWADDR|UUID)=/d' /etc/sysconfig/network-scripts/ifcfg-ens192

    #remove SSH host keys
    /bin/rm -f /etc/ssh/*key*

    #remove root users shell history
    /bin/rm -f ~root/.bash_history
    unset HISTFILE

    #remove root users SSH history
    /bin/rm -rf ~root/.ssh/
    poweroff