<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>itsMine &#187; bash</title>
	<atom:link href="http://blog.itsmine.co.uk/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.itsmine.co.uk</link>
	<description></description>
	<lastBuildDate>Sun, 18 Apr 2010 02:28:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<atom:link rel="next" href="http://blog.itsmine.co.uk/tag/bash/feed/?page=2" />

		<item>
		<title>Firewall editing script</title>
		<link>http://blog.itsmine.co.uk/2009/09/06/firewall-editing-script/</link>
		<comments>http://blog.itsmine.co.uk/2009/09/06/firewall-editing-script/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 15:23:24 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Red Hat]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.itsmine.co.uk/?p=715</guid>
		<description><![CDATA[Ok, here&#8217;s a wee script I threw together to help myself and any other sys admins who have to make a lot of edits to the iptables firewall in Red Hat / CentOS. It basically opens up the /etc/sysconfig/iptables file to allow you to make your edit(s) and then when you close the editor, it&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, here&#8217;s a wee script I threw together to help myself and any other sys admins who have to make a lot of edits to the iptables firewall in Red Hat / CentOS. It basically opens up the /etc/sysconfig/iptables file to allow you to make your edit(s) and then when you close the editor, it&#8217;ll ask you if you want to apply the changes straight away, or apply them immediately to allow for testing, then unload the iptables module after a set amount of time (2 minutes as defined on line 2) in case anything broke.</p>
<pre class="brush: bash; title: ;">#!/bin/bash
TESTING_MINS=2
vim /etc/sysconfig/iptables
clear
QUESTION1=&quot;Do you want to restart the firewall now? (hit 't' to test for $TESTING_MINS min(s)) [y/n/t] &quot;
echo -n $QUESTION1

a=&quot;&quot;
while test -z &quot;$a&quot;
do
        read -n1 a
        echo &quot;&quot;

 case &quot;$a&quot; in
  Y|y)
        echo -e &quot;Restarting...\n\n&quot;
		/sbin/service iptables restart
  ;;
  N|n)
        exit 0
  ;;
  T|t)
        echo -e &quot;Time is now `date +%H:%M` -firewall service will be stopped at `date +%H:%M -d &quot;+$TESTING_MINS min&quot;`\nIf your test was successful, you will need to manually start the service again by running:\nservice iptables start&quot;
        echo &quot;/sbin/service iptables stop &amp;&gt; /dev/null&quot; | at now + $TESTING_MINS min &amp;&gt; /dev/null
		echo &quot;&quot;
        /sbin/service iptables restart
  ;;
  *)
        a=&quot;&quot;
        echo -n $QUESTION1
  ;;
  esac
done</pre>
<p>P.S. Any scripts I write and publish here are © Rob Freeman and released under the <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">GPL</a> unless otherwise stated.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsmine.co.uk/2009/09/06/firewall-editing-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yum restore script</title>
		<link>http://blog.itsmine.co.uk/2009/01/04/yum-restore-script/</link>
		<comments>http://blog.itsmine.co.uk/2009/01/04/yum-restore-script/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 01:05:00 +0000</pubDate>
		<dc:creator>rob</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Project]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://blog.itsmine.co.uk/?p=354</guid>
		<description><![CDATA[Ok, so I&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so I&#8217;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&#8217;ve set up the repos on the new system I can simply execute this script, it&#8217;ll install all the packages I have now, then I can just restore my /etc/directory on top and hey-presto, I&#8217;ll be back to a nicely functioning system.</p>
<p>So without further ado:</p>
<pre>#!/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 &gt; $EXECUTABLE

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

exec 3&lt; $INSTALLED

while read &lt;&amp;3

do

echo -n "$REPLY " &gt;&gt; $LIST

done

exec 3&gt;&amp;-

# Create the yum installation script file

if [ $UNATTENDED_INSTALL = "yes" ]

then

OPTION="-y"

fi

echo "#!/bin/bash" &gt;&gt; $EXECUTABLE

echo -n "$REPLY " &gt;&gt; $LIST

echo "sudo yum clean all;sudo yum install $OPTION `cat $LIST`" &gt;&gt; $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</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.itsmine.co.uk/2009/01/04/yum-restore-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
