<?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>about:nothing</title>
	<atom:link href="http://blog.inf.ed.ac.uk/gdutton/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.inf.ed.ac.uk/gdutton</link>
	<description>not-a-blog, not-a-service, not-a-clue.</description>
	<lastBuildDate>Fri, 08 Mar 2013 16:53:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>a big hand for rfe</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2013/03/a-big-hand-for-rfe/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2013/03/a-big-hand-for-rfe/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 21:09:50 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[DICE]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[scripty]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[LOM]]></category>
		<category><![CDATA[power control]]></category>
		<category><![CDATA[rfe]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=417</guid>
		<description><![CDATA[Here are some tools that I&#8217;ve put together that make a huge difference to a clunky rfe workflow. Bored already? Don&#8217;t worry, I&#8217;ve written the script already: tl;dr Imagine power cycling a DICE server with redundant PSUs, using our lovely power bar control files. You don&#8217;t know where it&#8217;s installed, so you have to search [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some tools that I&#8217;ve put together that make a huge difference to a clunky <code>rfe</code> workflow.  Bored already?  Don&#8217;t worry, I&#8217;ve written the script already: <a href="#tldr">tl;dr</a></p>
<p>Imagine power cycling a DICE server with redundant PSUs, using our lovely <a href="https://wiki.inf.ed.ac.uk/DICE/ApcPowerBarRfeControl">power bar control</a> files.  You don&#8217;t know where it&#8217;s installed, so you have to search for it.  <span id="more-417"></span>Thank goodness for the <code>-xf</code> script:</p>
<blockquote><p><code>$ rfe -xf fpdu/myserver<br />
s90.outlets:outlet  3 myserver on<br />
s91.outlets:outlet  3 myserver on<br />
</code></p></blockquote>
<p>Great.  But now we have to open and edit each of these by hand:</p>
<blockquote><p><code>$ rfe -xf fpdu/s90.outlets<br />
outlet  1 thingy on<br />
outlet  2 another on<br />
outlet  3 myserver <strong>off⌶</strong><br />
outlet  4 [...]<br />
</code>&#8230;then&#8230;<code><br />
$ rfe -xf fpdu/s91.outlets<br />
outlet  1 thingy on<br />
outlet  2 another on<br />
outlet  3 myserver <strong>off⌶</strong><br />
outlet  4 [...]</code></p></blockquote>
<p>and check the console, and again&#8230;</p>
<blockquote><p><code>$ rfe -xf fpdu/s90.outlets<br />
outlet  3 myserver <strong>off⌶</strong><br />
</code>&#8230;and&#8230;<code><br />
$ rfe -xf fpdu/s91.outlets<br />
outlet  3 myserver <strong>off⌶</strong><br />
[...]<br />
</code></p></blockquote>
<p>much easier to use my new <strong>rfeall</strong> script:</p>
<pre style="font-size: 0.8em;background-color: #f0f0ff;border: 1px solid gray;padding: 0.5em;margin-bottom: 1em">
#!/bin/bash
# rfe edit all matching maps
search=$*; map=${search%/*}
maps=$(rfe -xf "$search" \
&nbsp;&nbsp;&nbsp; |&amp; awk -F ':' '/^rfe:/{exit;}{print $1;}' \
&nbsp;&nbsp;&nbsp; | sort | uniq | xargs)
if [[ -n $maps ]]; then
&nbsp;&nbsp;&nbsp; args=""
&nbsp;&nbsp;&nbsp; for m in $maps; do args="${args}${map}/`filename ${m}` "; done
&nbsp;&nbsp;&nbsp; rfe -S $args
else
&nbsp;&nbsp;&nbsp; echo "No matches found for $search." &gt;&amp;2
&nbsp;&nbsp;&nbsp; exit 1;
fi
</pre>
<p>which allows a far simpler edit:</p>
<blockquote><p><code>$ rfeall fpdu/myserver</code></p></blockquote>
<p>Oh.  But we still have to edit two files, twice&#8230;</p>
<blockquote><p><code><br />
outlet  3 myserver <strong>off⌶</strong><br />
[...]<br />
outlet  3 myserver <strong>off⌶</strong><br />
</code> and relaunch, and&#8230; <code><br />
outlet  3 myserver <strong>on⌶</strong><br />
[...]<br />
outlet  3 myserver <strong>on⌶</strong><br />
</code></p></blockquote>
<p>So how much further can we take this?</p>
<p>Well, for a start I don&#8217;t want to have to navigate to line three every time.  So let&#8217;s save the tedious effort of searching four times for the same thing.  Turns out to be as easy as writing your own editor.  Wait, what?</p>
<blockquote><p><code>/usr/bin/vim -c 'call search("myserver")' $*</code></p></blockquote>
<p>Maybe a slight exaggeration.  But it needs to be a real, callable thing if you&#8217;re going to make it your <code>$EDITOR</code>, thus:</p>
<pre style="font-size: 0.8em;background-color: #f0f0ff;border: 1px solid gray;padding: 0.5em;margin-bottom: 1em">
# rfe edit all matching maps; seek to match:
[...]
for m in $maps; do args="${args}${map}/${m} "; done
editr=/tmp/rfeall.$$
echo "/usr/bin/vim -c 'call search(\"$file\")' \$*" &gt; $editr &amp;&amp; chmod 700 $editr
EDITOR=$editr rfe -S $args
[...]
</pre>
<p>vim now opens at precisely the right location, give or take a word.  But we <em>still</em> have to change those words by hand.  Time for some vim scripting&#8230;</p>
<pre style="font-size: 0.8em;background-color: #f0f0ff;border: 1px solid gray;padding: 0.5em;margin-bottom: 1em">
function! SwitchOn()
&nbsp;&nbsp;&nbsp; s/o\(ff\|n\) *$/on/
endfunction
function! SwitchOff()
&nbsp;&nbsp;&nbsp; s/o\(ff\|n\) *$/off/
endfunction
nmap   \O  :call SwitchOn()
nmap   \o  :call SwitchOff()
</pre>
<p>My vim&#8217;s not so sharp, so I have a nagging feeling there&#8217;s a nicer way to do this, but putting this into my <code>.vimrc</code> is enough to allow me to use two keys to turn the machine on the current line <strong><code>\O</code></strong>n or <strong><code>\o</code></strong>ff.</p>
<p><a name="#tldr">So&#8230;</a> you can now do your dual-PSU power cycle with approximately twenty keystrokes from the first time you hit &lt;rtn&gt;:</p>
<blockquote><p><code><br />
$ rfeall fpdu/myserver<br />
\o :wq<br />
\o :wq<br />
</code>&#8230;check your console, hit up, return&#8230;<code><br />
\O :wq<br />
\O :wq<br />
</code></p></blockquote>
<p>all done.  Since rfeall uses the same maps as rfe, it&#8217;s moderately useful to allow the <code>rfe</code> tab completion to work for the new script, too.  In your ~/.bash_completion file (you have one, don&#8217;t you?):</p>
<pre style="font-size: 0.8em;background-color: #f0f0ff;border: 1px solid gray;padding: 0.5em;margin-bottom: 1em">
complete -o nospace -F _rfe rfeall
</pre>
<p>Yes, I suppose could automate even the last step by setting &#8216;sed&#8217; as my editor, but there&#8217;s a limit, I think &#8211; I trust myself little enough to turn off the right machine without delegating it to my dubious pattern-matching skills&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2013/03/a-big-hand-for-rfe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>cron and on and on?</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2012/11/cron-and-on-and-on/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2012/11/cron-and-on-and-on/#comments</comments>
		<pubDate>Fri, 02 Nov 2012 15:32:51 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=319</guid>
		<description><![CDATA[DICE users have long had the ability to add their own cron jobs, to schedule repeating tasks or to launch services on reboot1 using the standard crontab command. The Research and Teaching unit recently noted that users&#8217; crontabs (sometimes required, for example, on research servers to start or check on custom services) are not routinely [...]]]></description>
			<content:encoded><![CDATA[<p>DICE users have long had the ability to add their own <code>cron</code> jobs, to schedule repeating tasks or to launch services on reboot<sup><a href="#n1">1</a></sup> using the standard <code>crontab</code> command.</p>
<p>The Research and Teaching unit recently noted that users&#8217; crontabs (sometimes required, for example, on research servers to start or check on custom services) are not routinely backed up.  They are of course necessarily minimal and easy to recreate, but their fate following a disaster (or even a reinstallation) is not obvious.  Even if users are aware of this limitation, it prevents us from performing a completely automated recovery where users&#8217; crontabs are involved.</p>
<p>It is possible to back up crontabs on demand or routinely, but we&#8217;ve no procedure to do this on machines that typically have no other data to back up.  So the purpose of this post is simply to draw attention to the above, and ask a few general questions:</p>
<ul>
<li>Is it well-known that crontabs are &#8220;at risk&#8221;?  Does anyone care?</li>
<li>Should crontabs be backed up routinely? on all servers? desktops? at all?</li>
<li>Is there anything else we should be doing about this?</li>
</ul>
<p>Comments are encouraged, below or by email.</p>
<hr />
<ol style="font-size: smaller">
<li><a name="n1"></a><code>crontab</code> is the <a href="http://en.wikipedia.org/wiki/Setuid">setuid</a> executable which manages  <code>/var/spool/cron/</code> for this purpose.  The location is notable: on DICE, the <code>/var</code> directory (or filesystem) consists of data which is either transient or generated and managed automatically.  With the exception of some database files, this data is not typically backed up since its value is only to the running system.  Indeed most cron entries on a machine are not created by users; they are configured by LCFG and (re)created automatically.</li>
<li><a name="n2"></a>Note that using cron on DICE requires a few steps to <a href="https://wiki.inf.ed.ac.uk/DICE/AFSProblemsSolutions#Running_Cron_jobs">work with (or around) AFS</a>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2012/11/cron-and-on-and-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actually Using pgluser</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2012/07/actually-using-pgluser/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2012/07/actually-using-pgluser/#comments</comments>
		<pubDate>Wed, 18 Jul 2012 17:21:27 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=386</guid>
		<description><![CDATA[pgluser is a handy tool on DICE, and allows me to manage postgresql user accounts and databases in a completely automated manner. As it was primarily a tool to make my life easier, I&#8217;ve never tried particularly hard to increase its uptake. This is my attempt to help, at least for anyone considering setting up [...]]]></description>
			<content:encoded><![CDATA[<p>pgluser is a handy tool on DICE, and allows me to manage postgresql user accounts and databases in a completely automated manner.   As it was primarily a tool to make my life easier, I&#8217;ve never tried particularly hard to increase its uptake.  This is my attempt to help, at least for anyone considering setting up an postgresql server in an LCFG environment:</p>
<p>  <a href="https://svn.theon.inf.ed.ac.uk/trac/wiki/PgluserAndDice">https://svn.theon.inf.ed.ac.uk/trac/wiki/PgluserAndDice</a></p>
<p>Have I missed anything?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2012/07/actually-using-pgluser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>alpine, nagios and display filters</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2012/07/alpine-and-display-filters/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2012/07/alpine-and-display-filters/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 12:04:29 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[DICE]]></category>
		<category><![CDATA[evangelism]]></category>
		<category><![CDATA[scripty]]></category>
		<category><![CDATA[alpine]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[display filters]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=345</guid>
		<description><![CDATA[I&#8217;ve been aware of alpine&#8217;s &#8220;display filter&#8221; feature for some time, used as it is for on-the-fly GPG interpretation amongst other things. But I&#8217;d never really examined the feature before now. The manual says: The [filter] command is executed and the message is piped into its standard input. The standard output of the command is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been aware of alpine&#8217;s &#8220;display filter&#8221; feature for some time, used as it is for on-the-fly GPG interpretation amongst other things.  But I&#8217;d never really examined the feature before now.  The <a href="http://www.washington.edu/alpine/tech-notes/config.html">manual</a> says:</p>
<blockquote><p>The [filter] command is executed and the message is piped into its standard input. The standard output of the command is read back by Alpine.</p></blockquote>
<p>This says it all: display filters turn out to be an extremely powerful generic mechanism for reformatting and enhancing text; it works particularly well when applied to machine generated messages.  Maybe its power is best explained by the example which caused me to investigate in in the first place:</p>
<h3 style="margin-top: 24pt">An example (the nagios bit):</h3>
<p>A longstanding irritant to me has been a my difficulty in <a href="http://blog.inf.ed.ac.uk/gdutton/2010/07/nag-nag-nag-nag-nagios/">shutting nagios up</a>.  For a long time I&#8217;ve been relying on a filter to parse nagios&#8217; incoming emails and generate a URL.  The display filter closes the loop, automatically injecting that magic URL at the end of the message.</p>
<p>Here&#8217;s a simplified version of the filter, reminiscent of the one in the previous post:</p>
<pre style="color: navy">

#!/usr/bin/gawk -f
# Crude detection of problem type for acknowledgement link
# Don't forget to validate these inputs...
/Notification Type: / { TYPE=$3; }
/Service:/ { SERVICE=substr($0,length($1)+1,length($0)); }
/Host:/ { HOST=$2; }
# Important: this is a filter, so don't forget to print input lines back out!
// {print;}
# Now add the acknowledgement link below:
END {
    if (HOST &amp;&amp; TYPE == "PROBLEM") {
        # this is the script which generates the URL.
        # ideally this should be replaced with some awk to do the same thing
        cmd="~/bin/nagack "HOST" "SERVICE
        cmd | getline url
        close(cmd)
        # now add the link to the email.
        print "[Acknowledgement link: "url" ]"
}

</pre>
<p>Now, to alpine&#8217;s <code>Display Filters</code> setting, add:</p>
<pre style="color: navy">

Display Filters    = _LEADING("***** Nagios")_ /path/to/nagios-filter-script
</pre>
<p>that&#8217;s it!  My emails from nagios now look like:</p>
<pre style="color: navy">

***** Nagios *****
Notification Type: PROBLEM
Service: ssh
Host: myhost
Address: 192.168.12.34
State: CRITICAL
...
[Acknowledgement link: https://nagiosserver/nagios/cgi-bin/cmd.cgi?cmd_typ=3... ]

</pre>
</p>
<h3 style="margin-top: 24pt">Important caveats:</h3>
<ul>
<li>If you&#8217;re not careful, by adding these filters you will have introduced a trivial local shell injection attack to your mail client.  Validate your inputs &#8212; just like I didn&#8217;t above!</li>
<li>The developers have this to note about running filters on every message:
<p>
<blockquote>Testing for the trigger and invoking the filter doesn&#8217;t come for free. There is overhead associated with searching for the trigger string, testing for the filter&#8217;s existence and actually piping the text through the filter. The impact can be reduced if the Trigger Modifying Tokens [...] are employed.</p></blockquote>
<p>I&#8217;ve certainly noticed a small (immeasurable, but noticeable) delay in opening messages with triggers.  Large enough to be annoying if I&#8217;d planned to filter every message, even using a trivial bash filter which itself is quick to complete.</p>
</li>
<li>One additional caveat on DICE: if your alpine session outlives your AFS credentials, and you&#8217;ve stored your display filters in your home directory, you will find that the display filters simply disappear.  As good a reminder as any to renew, and thankfully a &#8220;renc&#8221; is all that&#8217;s required to restore your filters to former glory.</li>
</ul>
<p>That&#8217;s it!  Surprisingly trivial, and with a handful of these triggers, the benefits are huge.  I&#8217;m using five so far, mostly generating clickable links to some of our automated systems, but I&#8217;d be pleased to hear what other people are doing with these filters.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2012/07/alpine-and-display-filters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Editing component files with vim</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2012/05/editing-component-files-with-vim/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2012/05/editing-component-files-with-vim/#comments</comments>
		<pubDate>Tue, 01 May 2012 16:57:51 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[DICE]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[scripty]]></category>
		<category><![CDATA[ftdetect]]></category>
		<category><![CDATA[lcfg]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=324</guid>
		<description><![CDATA[Editing LCFG component source files using Vim is of course The Right Thing to do, but due to the way these source files are named (typically filename.ext.cin) vim doesn&#8217;t necessarily pick up on the filetype, and goodies such as syntax highlighting are lost. This is easy to fix using vim&#8217;s ftdetect system. Some examples for [...]]]></description>
			<content:encoded><![CDATA[<p>Editing LCFG component source files using Vim is of course The Right Thing to do, but due to the way these source files are named (typically <code>filename.ext.cin</code>) vim doesn&#8217;t necessarily pick up on the filetype, and goodies such as syntax highlighting are lost.</p>
<p>This is easy to fix using vim&#8217;s <code>ftdetect</code> system.  Some examples for simple types:</p>
<pre style="font-size: 0.8em;background-color: #f0f0ff;border: 1px solid gray;padding: 0.5em;margin-bottom: 1em">
" These files are always POD in disguise
au BufRead,BufNewFile *.pod.cin : set filetype=pod
" Slightly contentious: a new filetype is needed, really, but this is a decent match.
au BufRead,BufNewFile *.def.cin : set filetype=cpp
" For other, unknown types, detect from the as-yet undefined shebang:
au BufRead,BufNewFile *.cin : if getline(1) =~ '^#!@SHELL@' | set filetype=sh | endif
au BufRead,BufNewFile *.cin : if getline(1) =~ '^#!@PERL@' | set filetype=perl | endif
</pre>
<p>(note the latter two lines are specified separately, rather than <code>elseif</code>ed, purely for readability).  It&#8217;s fairly obvious that this can be extended to any file type, and there&#8217;s also scope for adding an automatic mapping to allow all files of form <code>file.typ.cin</code> to be mapped automatically to their default <code>.typ.</code> &#8220;sub-extension&#8221; file type.</p>
<p>Anyway, the above has already improved my productivity no end so I&#8217;ll leave the latter exercise to the reader.  Comments and contributions are welcome, as always &#8212; so long as they&#8217;re not suggestions to use Emacs(!)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2012/05/editing-component-files-with-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Away with the PXEs</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2012/04/away-with-the-pxes/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2012/04/away-with-the-pxes/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 16:19:59 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[DICE]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lcfg]]></category>
		<category><![CDATA[pxe]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=312</guid>
		<description><![CDATA[Occasionally, for the purposes of internal testing or continuity, it&#8217;s desirable to bring up a server with a duplicate MAC address. It&#8217;s a safe enough manoeuvre (so long as these machines operate on different wires) for the brief periods in which I require it but when this scenario involves the installation of a new server [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally, for the purposes of internal testing or continuity, it&#8217;s desirable to bring up a server with a duplicate MAC address. It&#8217;s a safe enough manoeuvre (so long as these machines operate on different wires) for the brief periods in which I require it but when this scenario involves the installation of a new server via our installroot PXE service, things are trickier.</p>
<p>Our PXE server is configured automagically by spanning map and, effectively, keyed on MAC, so it&#8217;s unlikely to present the correct configuration (reliably) when the new host differs from the old one in some way.</p>
<p>The workaround is to override the PXE configuration on the *existing* server (on the basis that you weren&#8217;t planning on reinstalling it, anyway, were you?):</p>
<blockquote><pre>
!pxeclient.platforms mADD(new_plat_name) /* e.g. sl6_64 */

/* And, if you need to add or remove serial console support: */
!pxeclient.serial_port mSET(ttyS0) /* or () */
</pre>
</blockquote>
<p>Post-PXE, the <code>dhclient</code> component is aware of subnet differences and will ensure your machine receives the correct profile for installation (though, to prevent future confusion, remove this as soon as the installer has done its work!).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2012/04/away-with-the-pxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get on the rpm bus</title>
		<link>http://blog.inf.ed.ac.uk/gdutton/2011/05/get-on-the-rpm-bus/</link>
		<comments>http://blog.inf.ed.ac.uk/gdutton/2011/05/get-on-the-rpm-bus/#comments</comments>
		<pubDate>Wed, 11 May 2011 08:55:44 +0000</pubDate>
		<dc:creator>gdutton</dc:creator>
				<category><![CDATA[DICE]]></category>
		<category><![CDATA[scripty]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[pkgforge]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[simple]]></category>

		<guid isPermaLink="false">http://blog.inf.ed.ac.uk/gdutton/?p=289</guid>
		<description><![CDATA[This is a quickie script which streamlines my RPM building and submission to a single command. Note that this is entirely dependent on our shiny new Package Forge system, which feeds RPMs to multiple platforms for building and eventual submission into our RPM buckets. All it does is chain up &#8220;rpmbuild -bs [spec]; pkgforge submit [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quickie script which streamlines my RPM building and submission to a single command.  Note that this is entirely dependent on our shiny new <a href="https://pkgforge.inf.ed.ac.uk/doc/">Package Forge</a> system, which feeds RPMs to multiple platforms for building and eventual submission into our RPM buckets.</p>
<p>All it does is chain up &#8220;rpmbuild -bs [spec]; pkgforge submit [srpm]&#8221; but it&#8217;s a nice timesaver nonetheless.  Side-benefits include the automatic generation of a readable ID and provision of a tracking link for pkgforge so that you can anxiously refresh the page to watch the build progress (or you could just wait for the report email&#8230;).</p>
<p>So, here is is; my very simple and stupid RPM automation.  Suggested name: &#8216;rpmbus&#8217;.</p>
<pre>
#!/bin/bash
if [[ -z $2 ]]; then
    echo "RPMbus: build -&gt; submit assist"
    echo "Usage: `basename $0`   [pkgforge args]"
    exit 1
fi
bucket=$1; shift
spec=$1; shift
args=$*

output=`rpmbuild -bs ${spec} | tail -n 1`
pkg=`echo ${output} | sed -e 's_^Wrote: __'`

if [[ ! -e ${pkg} ]]; then
    echo "Package wasn't built: ${output}"
    exit 1
fi

id=`basename ${spec} | sed -e 's_\.spec__' -e 's_\.__g'`-`date +"%s"`
echo -e "Found source package:\n  ${pkg}"
echo "  Extra args: ${args:-none}"

read -p "Submit to '${bucket}'?" foo
if [[ ${foo} != 'y' ]]; then
    echo "Cancelled"
    exit 1
fi

echo "Submitting to ${bucket}..."
pkgforge submit --id ${id} -B ${bucket} ${args} ${pkg} &amp;&amp; \
echo "  https://pkgforge.inf.ed.ac.uk/job/view?id=${id}"
</pre>
<p>&nbsp;</p>
<p>Caveats: well, they&#8217;re numerous and they&#8217;re pretty apparent.  But it took five minutes to write and it WFM :)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.inf.ed.ac.uk/gdutton/2011/05/get-on-the-rpm-bus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
