How to totally expunge FOG and everything it's touched



  • Primarily I want to as it says, totally remove everything and anything that FOG has touched or used from the latest release 1.5.7 all the way back to at least 1.2.

    Not that I’m giving up on FOG right now, but I have some legacy servers cruising for a bruising, and I want to be able to rebuild as cleanly as possible, by remote.

    Then of course, comes the rebuild. Installing FOG is a cinch, but of course I need to re-install those OS elements affected, and I’d prefer to not have anything at all left from them that FOG may have touched … to totally remove any doubt that something, somewhere, may have been borked by FOG or the many versions installers over the years of revisions.

    I’m interested in a CentOS 7 solution.


  • Developer

    @sudburr Ok, I tested and updated my version of the script below (derived from yours).

    Again, make sure you have backups of your /images and the certificate files before you run this script!! I won’t be responsible for any trouble caused by this script!



  • @sudburr said in How to totally expunge FOG and everything it's touched:

    But I don’t want to re-install the OS by remote. Not yet at least.

    I’d have already done it…

    Side note: I rarely even install OSs at home anymore. I have clean VMs that I clone for making new VMs. :D


  • Developer

    @sudburr I can see that re-installing the OS in your situation is not easy if you with the server being remote. Before I get into the details, here is one word of caution: Be aware that purging the CA and certificate/key files will likely cause you a lot of trouble if you have clients that are pinned to this FOG server!! Make a backup of those files before you go ahead. As well this script will purge ALL IMAGES from the server.

    I won’t be responsible for any trouble caused by this script!

    I see four options:

    1. you have a proper server with iKVM - this way you can boot the server from a virtually mount ISO and install from scratch
    2. someone is at site to setup a iKVM box for you - similar to 1. but you’d need the box and someone setting it up at site
    3. someone is at site and can boot from DVD for you and type in grub boot parameters for VNC setup: https://cloudwrk.com/remote-server-installation-centos-7/
    4. Someone implements the ./installfog.sh --uninstall option that was added as “Not yet supported” years ago but unfortunately was never finished

    Don’t feel offended, I am just joking with some of what I said. Still re-installing the OS is the best option to have a clean start.

    Other than that I might add some commands to your script:

    source /opt/fog/.fogsettings
    
    # Remove FOG services
    for service in FOGMulticastManager.service FOGImageReplicator.service FOGScheduler.service FOGSnapinReplicator.service FOGSnapinHash.service FOGPingHosts.service FOGImageSize.service
    do
        systemctl stop $service
        systemctl disable $service
        rm -f /usr/lib/systemd/system/$service
    done
    
    # Delete FOG database
    mysql -u root -p<password> -e 'DROP DATABASE fog;'
    
    # Remove FOG files
    rm -rf /images
    rm -rf /var/www/fog
    rm -rf /var/www/html/fog 
    rm -rf /opt/fog
    rm -rf /opt/fog.old
    rm -rf /tftpboot
    rm -rf /tftpboot.prev
    rm -rf /opt/trunkgit
    rm -rf /opt/trunksvn
    
    # Remove configs generated by the installer
    rm -rf /etc/dhcp/dhcpd.conf /etc/exports /etc/httpd/conf.d/fog.conf /etc/xinetd.d/tftp* /etc/vsftpd /etc/php-fpm.d/www.conf /etc/php.ini
    
    # Remove service data
    rm -rf /var/lib/dhcpd /var/lib/mysql /var/lib/rpcbind /var/lib/nfs /var/lib/php
    
    # Remove logs
    rm -rf /var/log/httpd /var/log/mariadb /var/log/php-fpm /var/log/xferlog /var/log/fog
    
    # Delete FOG system user
    userdel --force --remove fog
    userdel --force --remove fogproject
    rm -rf /home/fog*
    rm -rf /home/fogproject*
    
    # Delete packages installed by FOG installer sourced from .fogsettings
    uninstall=${packages//curl }
    uninstall=${uninstall//gzip }
    uninstall=${uninstall//tar }
    yum -y remove $uninstall
    
    # Remove extra repos
    rm -f /etc/yum.repos.d/epel*
    rm -f /etc/yum.repos.d/remi*
    
    # Clean & Update the OS
    yum clean all
    rm -rf /var/tmp/yum-administrator-PudGB
    rm -rf /var/cache/yum
    yum list iostat
    yum makecache
    yum grouplist
    yum grouplist hidden
    yum update -y
    
    # Reboot to Commit
    reboot
    


  • @Tom-Elliott Okay, I’ll look into that.

    Ultimately I’m looking for a best-effort recommended, second to last resort (reinstalling OS would be the last resort) solution that would tear down and pave over all that is FOG.

    Sometimes tinkering, tweaking and forensic fixes just don’t do the job and you need other more drastic options in your troubleshooting arsenal; a FOG uninstaller.



  • But I don’t want to re-install the OS by remote. Not yet at least.


  • Senior Developer

    The other method is to use most of the stuff but for removing packages, source in the .fogsettings file before you remove the /opt/fog/ folder. Then you can use packagemanager-uninstallcmd $packages

    Note this will simply remove the packages fog installs. All the other bits of service removal and what not should work as indicated.

    I kind of side with @Sebastian-Roth however because removing all the installed packages can sometimes uninstall elements unexpectedly and out of “fogs” control. I’ve seen occasionally some like like installing python then uninstalling it breaking package manager tools like yum or apt


  • Developer

    @sudburr What I meant is re-installing the Linux OS!



  • Re-installing FOG does not strip it from the server. It re-installs FOG.

    It’s easy enough to yum remove virtually everything else. What about a solution for FOG and its tendrils?


  • Developer

    @sudburr Why not re-install the whole system from scratch?



  • You misunderstand. I’m exploring a “nuke it from orbit” solution. I want to tear the server down to its bones then build it back without physical intervention.

    For one particular server I used the following.

    # Remove FOG services
    	rm /etc/init.d/FOGImageReplicator
    	rm /etc/init.d/FOGMulticastManager
    	rm /etc/init.d/FOGScheduler
    
    # Delete FOG database
    	mysql -u root -p
    	<password>
    	drop database fog;
    	exit
    
    # Remove FOG files
    	rm -rf /var/www/fog
    	rm -rf /var/www/html/fog 
    	rm -rf /opt/fog
    	rm -rf /opt/fog.old
    	rm -rf /tftpboot
    	rm -rf /opt/trunkgit
    	rm -rf /opt/trunksvn
    
    # Delete FOG system user
    	userdel fog
    	userdel fogproject
    
    # Delete supportive systems
    	yum -y remove php*
    	yum -y remove httpd
    
    # Clean & Update the OS
    	yum clean all
    	rm -rf /var/tmp/yum-administrator-PudGB
    	rm -rf /var/cache/yum
    	yum list iostat
    	yum makecache
    	yum grouplist
    	yum grouplist hidden
    	yum update -y
    
    # Reboot to Commit
    	reboot
    
    



Log in to reply
 

527
Online

6.3k
Users

13.7k
Topics

129.3k
Posts