Yum restore script

Ok, so I’m about to do a reinstallation of Fedora (I made a boo-boo which would be easier to fix by a re-install than go through manually and try to fix). I have backups, but not of the lib folders etc, I do however have backups of the uber important folders e.g. /etc /home /root etc. Anyway, I want to do a minimum-fuss reinstall, and decided to write a wee script which would take a list of all my currently installed packages and make a nice simple exectuable bash script so that once I’ve set up the repos on the new system I can simply execute this script, it’ll install all the packages I have now, then I can just restore my /etc/directory on top and hey-presto, I’ll be back to a nicely functioning system.

So without further ado:

#!/bin/bash

INSTALLED=/tmp/yum-installed

LIST=/tmp/list

EXECUTABLE=/home/rob/yum

USER=rob

GROUP=$USER

UNATTENDED_INSTALL=yes #yes/no

cat /dev/null > $EXECUTABLE

sudo yum clean all;sudo yum list installed | awk -F' ' '{print $1}' | sed 1d | sed 1d | sed s/.i386// &> $INSTALLED

exec 3< $INSTALLED

while read <&3

do

echo -n "$REPLY " >> $LIST

done

exec 3>&-

# Create the yum installation script file

if [ $UNATTENDED_INSTALL = "yes" ]

then

OPTION="-y"

fi

echo "#!/bin/bash" >> $EXECUTABLE

echo -n "$REPLY " >> $LIST

echo "sudo yum clean all;sudo yum install $OPTION `cat $LIST`" >> $EXECUTABLE

# Set correct perms

chmod +x $EXECUTABLE

chown $USER.$GROUP $EXECUTABLE

# Cleanup

rm -f $LIST

rm -f $INSTALLED

Obviously edit the vars at the top to suit your setup etc - then just sudo (or execute as root) the $EXECUTABLE
  1. No comments yet.

  1. No trackbacks yet.