<?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>Drop By! &#187; bash</title>
	<atom:link href="http://www.rekk.de/bloggy/category/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rekk.de/bloggy</link>
	<description>Dropping Brain Crumbs ...</description>
	<lastBuildDate>Wed, 09 Jun 2010 16:59:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Gnome Application Launcher &#8211; Run Application in Certain Directory</title>
		<link>http://www.rekk.de/bloggy/2009/gnome-application-launcher-run-application-in-certain-directory/</link>
		<comments>http://www.rekk.de/bloggy/2009/gnome-application-launcher-run-application-in-certain-directory/#comments</comments>
		<pubDate>Tue, 12 May 2009 09:20:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=136</guid>
		<description><![CDATA[This would be easy in kde, but in gnome some extra steps are needed. I changed to gnome just recently being impressed by the clarity and simplicity of the user interface. Being used to the &#8220;kde way&#8221; I needed some time to figure that out. This is an example for kdissert: Create a wrapper script [...]]]></description>
			<content:encoded><![CDATA[<p>This would be easy in kde, but in gnome some extra steps are needed. I changed to gnome just recently being impressed by the clarity and simplicity of the user interface. Being used to the &#8220;kde way&#8221; I needed some time to figure that out.</p>
<p>This is an example for kdissert:</p>
<p>Create a wrapper script for example kdissert.sh in ~/bin/launch and make it executable</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash                                                                                                     </span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Known
<span style="color: #c20cb9; font-weight: bold;">nohup</span> kdissert <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>Then use the panel menu to create a Custom Application Launcher : Add to panel -> Custom Application Launcher -> Choose Type: Application, Command: /home/yourusername/bin/launch/kdissert.sh </p>
<p>Another way is to use shell directly. But watch out &#8211; you will need to source your .bashrc if needed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Desktop Entry<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">Version</span>=<span style="color: #000000;">1.0</span>
<span style="color: #007800;">Encoding</span>=UTF-<span style="color: #000000;">8</span>
<span style="color: #007800;">Name</span>=netbeans with some environment settings
<span style="color: #007800;">Exec</span>=<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span>  <span style="color: #ff0000;">'. ~/.bashrc; ~/workarea/nb_run.sh'</span>
<span style="color: #666666; font-style: italic;"># to run it in a terminal:</span>
<span style="color: #666666; font-style: italic;"># Exec=gnome-terminal --command &quot;/bin/bash -c  '. ~/.bashrc; ~/workarea/nb_run.sh' &quot;</span>
<span style="color: #007800;">Icon</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>kostja<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>netbeans-6.5rc2<span style="color: #000000; font-weight: bold;">/</span>nb6.5<span style="color: #000000; font-weight: bold;">/</span>netbeans.png
<span style="color: #007800;">Categories</span>=Development;Java;IDE
<span style="color: #007800;">StartupNotify</span>=<span style="color: #c20cb9; font-weight: bold;">true</span>
<span style="color: #007800;">Type</span>=Application</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2009/gnome-application-launcher-run-application-in-certain-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Script &#8211; Add &#124; Include only certain Files to Subversion Repository</title>
		<link>http://www.rekk.de/bloggy/2009/bash-script-add-include-only-certain-files-to-subversion-repository/</link>
		<comments>http://www.rekk.de/bloggy/2009/bash-script-add-include-only-certain-files-to-subversion-repository/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 10:43:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[build management]]></category>
		<category><![CDATA[ivy]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=122</guid>
		<description><![CDATA[Recently I had to face a limitation of subversion &#8211; you can set files and patterns for ignoring files (using svn:ignore) but you can not specify certain files or patterns for files to be included. In my situation, I wanted to build an Ivy repository and put only the ivy files under the version control [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had to face a limitation of subversion &#8211; you can set files and patterns for ignoring files (using svn:ignore) but you can not specify certain files or patterns for files to be included. In my situation, I wanted to build an <a href="http://ant.apache.org/ivy/">Ivy</a> repository and put only the ivy files under the version control cause all other artifacts could be rebuild using SCM.</p>
<p>So I came up with a simple bash script, which is run just before commit and is actually called from an ant script in a build environment:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># adds only certain files to repository, adds</span>
<span style="color: #666666; font-style: italic;"># all intermediate directories on their paths,</span>
<span style="color: #666666; font-style: italic;"># it also works with empty space in path (except newline)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># @todo Add some bells and whistles!</span>
&nbsp;
<span style="color: #007800;">REPO_NAME</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>some_repo<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Running $0 on&quot;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #ff0000;">&quot;with <span style="color: #007800;">$REPO_NAME</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># this file will help to limit the search, if it's modified on commit</span>
<span style="color: #666666; font-style: italic;"># for example the log file of last commit, the idea here is to run </span>
<span style="color: #666666; font-style: italic;"># this script always before commit</span>
<span style="color: #007800;">REF_TIME_FILE</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>some_file<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #007800;">REP_PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>some<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>your<span style="color: #000000; font-weight: bold;">/</span>copies<span style="color: #000000; font-weight: bold;">/</span>root
&nbsp;
<span style="color: #007800;">FILE_PATTERN</span>=<span style="color: #ff0000;">'ivy.xml*'</span>
<span style="color: #007800;">DIR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$REP_PATH</span>
<span style="color: #007800;">IFS_ORIG</span>=<span style="color: #007800;">$IFS</span>
<span style="color: #666666; font-style: italic;"># this allows paths with whitespace, but not with newline</span>
<span style="color: #007800;">IFS</span>=$<span style="color: #ff0000;">'\n'</span>
<span style="color: #666666; font-style: italic;">#IFS=&quot;$(echo)&quot; another way to get newline</span>
<span style="color: #000000; font-weight: bold;">for</span> ivy <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-newer</span> <span style="color: #007800;">$REF_TIME_FILE</span>  <span style="color: #660033;">-type</span> f  <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$FILE_PATTERN</span>&quot;</span>  -print<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;found fresh file <span style="color: #007800;">$ivy</span>&quot;</span>
	<span style="color: #007800;">p</span>=<span style="color: #007800;">$ivy</span>
	<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$p</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">do</span> 
			<span style="color: #007800;">all_paths</span>=<span style="color: #800000;">${all_paths}</span><span style="color: #800000;">${del}</span><span style="color: #800000;">${p}</span>
			<span style="color: #007800;">p</span>=<span style="color: #800000;">${p%/*}</span>	
			<span style="color: #007800;">del</span>=:
	<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #007800;">IFS</span>=<span style="color: #007800;">$IFS_ORIG</span>
<span style="color: #666666; font-style: italic;">#echo $all_paths | tr ':' '\n' | sort | uniq |  tr '\n' '\0' | xargs -0 -i echo {}</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$all_paths</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">':'</span> <span style="color: #ff0000;">'\n'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">'\n'</span> <span style="color: #ff0000;">'\0'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #660033;">-0</span>  <span style="color: #c20cb9; font-weight: bold;">svn</span> add <span style="color: #660033;">--non-recursive</span>  <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;^A&quot;</span>
&nbsp;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$DIR</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Finish $0 on&quot;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #ff0000;">&quot;with <span style="color: #007800;">$REPO_NAME</span>&quot;</span></pre></div></div>

<p>It&#8217;s not a big deal but might help you to spare some time. There might be better ways to do it and I wonder if same can be done using &#8220;plain ant&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2009/bash-script-add-include-only-certain-files-to-subversion-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Init &#124; Start &#124; Boot Script for Hudson Continuous Integration Engine on SuSE Linux</title>
		<link>http://www.rekk.de/bloggy/2008/init-start-boot-script-for-hudson-continuous-integration-engine-on-suse-linux/</link>
		<comments>http://www.rekk.de/bloggy/2008/init-start-boot-script-for-hudson-continuous-integration-engine-on-suse-linux/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:44:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[hudson]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=53</guid>
		<description><![CDATA[Here is an init script to control hudson start up at boot time. It is tested on SLES 10 . I am not commenting it in detail here, nevertheless you are welcome to ask and leave comments. It&#8217;s rather beta but I hope that it could be useful as a starting point. #!/bin/bash # Author: [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an init script to control hudson start up at boot time. It is tested on SLES 10 . I am not commenting it in detail here, nevertheless you are welcome to ask and leave comments. It&#8217;s rather beta but I hope that it could be useful as a starting point.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;"># Author: Konstantin.rekk@gbv.de, 2008</span>
<span style="color: #666666; font-style: italic;"># Using ideas from http://developer.novell.com/wiki/index.php/Writing_Init_Scripts</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># install:</span>
<span style="color: #666666; font-style: italic;"># copy to /etc/init.d/gbv-hudson-integration</span>
<span style="color: #666666; font-style: italic;"># ln -s /etc/init.d/gbv-hudson-integration /sbin/rcgbv-hudson-integration</span>
<span style="color: #666666; font-style: italic;"># insserv /etc/init.d/gbv-hudson-integration</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:          gbv-hudson-integration</span>
<span style="color: #666666; font-style: italic;"># Required-Start:    $local_fs $network</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:</span>
<span style="color: #666666; font-style: italic;"># Default-Start:     3 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:      0 1 2 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: Starts the hudson server for CI </span>
<span style="color: #666666; font-style: italic;"># Description:       Starts Continuous Integration System for VZG SOA</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># to avoid conflict with functions local $1</span>
<span style="color: #007800;">ARG</span>=$<span style="color: #000000;">1</span>
&nbsp;
<span style="color: #007800;">APP</span>=<span style="color: #ff0000;">&quot;hudson&quot;</span>
&nbsp;
<span style="color: #007800;">HUDSON_USER</span>=soarun
<span style="color: #007800;">HUDSON_GROUP</span>=soarun
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${HUDSON_USER}</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">VZGSOA_HOME</span>=<span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>soa-workarea
&nbsp;
<span style="color: #666666; font-style: italic;"># include rc.status functions </span>
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.status <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> . <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.status <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> rc_reset
&nbsp;
<span style="color: #666666; font-style: italic;"># use test_for_app &lt;appl|file&gt; (x|f)</span>
test_for_app <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">app_found</span>=<span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;f&quot;</span> = <span style="color: #ff0000;">&quot;$2&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">app_found</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;x&quot;</span> = <span style="color: #ff0000;">&quot;$2&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">app_found</span>=<span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">0</span> = <span style="color: #007800;">$app_found</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Warning:  Couldn't find $1&quot;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ARG</span>&quot;</span> = <span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
            rc_failed <span style="color: #000000;">0</span>
        <span style="color: #000000; font-weight: bold;">else</span>
            rc_failed <span style="color: #000000;">5</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        rc_status <span style="color: #660033;">-v</span>
        rc_exit
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
test_for_app <span style="color: #007800;">$VZGSOA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>vzgsoa.env f
test_for_app <span style="color: #007800;">$VZGSOA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>integration<span style="color: #000000; font-weight: bold;">/</span>integration.env f
. <span style="color: #007800;">$VZGSOA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>vzgsoa.env
. <span style="color: #007800;">$VZGSOA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>integration<span style="color: #000000; font-weight: bold;">/</span>integration.env
&nbsp;
<span style="color: #007800;">HUDSON_CMD</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${JAVA}</span> -jar <span style="color: #007800;">${HUDSON_WAR}</span> --httpPort=<span style="color: #007800;">${CI_HTTP_PORT}</span> --argumentsRealm.passwd.hudson=<span style="color: #007800;">${HUDSON_PW}</span> --argumentsRealm.roles.hudson=admin&quot;</span>
&nbsp;
<span style="color: #007800;">HUDSON_PIDFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>hudson.pid
<span style="color: #007800;">HUDSON_LOG</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>hudson
&nbsp;
usage <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: $0 &lt;command&gt; &quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;where &lt;command&gt; is one of the following:&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    start - start <span style="color: #007800;">$APP</span> if not running&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    stop - stop <span style="color: #007800;">$APP</span> if running&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    status - report whether <span style="color: #007800;">$APP</span> is running&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    restart - stop and restart <span style="color: #007800;">$APP</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;    usage, help - print this message&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
get_pid_for_cmd <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">for</span> pid <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$pid</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$pid</span><span style="color: #000000; font-weight: bold;">/</span>cmdline <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(&lt;/proc/$pid/cmdline)</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #666666; font-style: italic;"># return with current pid </span>
                <span style="color: #7a0874; font-weight: bold;">return</span>
            <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    <span style="color: #007800;">pid</span>=<span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># checkport &lt;port&gt;</span>
<span style="color: #666666; font-style: italic;"># returns port_used</span>
check_port<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #007800;">port</span>=$<span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-nlept</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">--regexp</span>=<span style="color: #ff0000;">&quot;:<span style="color: #007800;">$port</span> &quot;</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null ; <span style="color: #000000; font-weight: bold;">then</span>
        	<span style="color: #007800;">port_used</span>=<span style="color: #000000;">1</span>
    	<span style="color: #000000; font-weight: bold;">else</span>
        	<span style="color: #007800;">port_used</span>=<span style="color: #000000;">0</span>
    	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># checks hudson, sets/returns status - </span>
<span style="color: #666666; font-style: italic;"># 0 if pidfile same as pid, running</span>
<span style="color: #666666; font-style: italic;"># 3 no pidfile, not running (what with running?)</span>
<span style="color: #666666; font-style: italic;"># 2 pidfile, but no process (remove file ...), not running</span>
<span style="color: #666666; font-style: italic;"># 1 pidfile != pid, but running</span>
<span style="color: #666666; font-style: italic;"># 4 no pidfile, but running</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;"># @todo: check port usage</span>
check_hudson<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> 
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
	get_pid_for_cmd <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${HUDSON_CMD}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/ //g'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$HUDSON_PIDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #007800;">pidfile_pid</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$HUDSON_PIDFILE</span><span style="color: #000000; font-weight: bold;">`</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">0</span> = <span style="color: #007800;">$pid</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">status</span>=<span style="color: #000000;">2</span>
		<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$pid</span>&quot;</span> = <span style="color: #ff0000;">&quot;<span style="color: #007800;">$pidfile_pid</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">status</span>=<span style="color: #000000;">0</span>;
		<span style="color: #000000; font-weight: bold;">else</span> 
			<span style="color: #007800;">status</span>=<span style="color: #000000;">1</span>;
		<span style="color: #000000; font-weight: bold;">fi</span>		
	<span style="color: #000000; font-weight: bold;">else</span> 
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">0</span> = <span style="color: #007800;">$pid</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #007800;">status</span>=<span style="color: #000000;">3</span>;
		<span style="color: #000000; font-weight: bold;">else</span> 
			<span style="color: #007800;">status</span>=<span style="color: #000000;">4</span>;
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
test_for_app <span style="color: #800000;">${JAVA}</span> x
test_for_app <span style="color: #800000;">${HUDSON_WAR}</span> f
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        check_hudson
        <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$status</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
            <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${APP}</span> already running&quot;</span>
		rc_failed <span style="color: #000000;">0</span>
		rc_status <span style="color: #660033;">-v1</span>
           	rc_exit
                <span style="color: #000000; font-weight: bold;">;;</span>
	    <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${APP}</span> seems running but pidfile is not up to date or doesn't exist, please check!&quot;</span>
		rc_failed
                rc_status <span style="color: #660033;">-v1</span>
                rc_exit
		<span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Found stale pidfile for <span style="color: #007800;">${APP}</span> - unclean shutdown?&quot;</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #800000;">${HUDSON_PIDFILE}</span>
                <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #666666; font-style: italic;"># not running - ok</span>
        	check_port <span style="color: #007800;">$CI_HTTP_PORT</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$port_used</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
			<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Port <span style="color: #007800;">$CI_HTTP_PORT</span> already in use, pleas check!&quot;</span>
                	rc_failed
                	rc_status <span style="color: #660033;">-v1</span>
                	rc_exit
		<span style="color: #000000; font-weight: bold;">fi</span> 
                <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Check for <span style="color: #007800;">${APP}</span> failed&quot;</span>
                rc_failed
                rc_status <span style="color: #660033;">-v1</span>
                rc_exit
        <span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting <span style="color: #007800;">${APP}</span>&quot;</span>
        startproc <span style="color: #660033;">-f</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$HUDSON_USER</span> <span style="color: #660033;">-g</span> <span style="color: #007800;">$HUDSON_GROUP</span> <span style="color: #660033;">-p</span> <span style="color: #800000;">${HUDSON_PIDFILE}</span> <span style="color: #800000;">${HUDSON_CMD}</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${HUDSON_LOG}</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">0</span> = <span style="color: #007800;">$?</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;(Error - &quot;</span>
            <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$?</span> <span style="color: #000000; font-weight: bold;">in</span>
                <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;invalid arguments&quot;</span>
                    <span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;insufficient permission&quot;</span>
                    <span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;no such program&quot;</span>
                    <span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;launch failure&quot;</span>
                    <span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
                    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;unspecified error&quot;</span>
                    <span style="color: #000000; font-weight: bold;">;;</span>
            <span style="color: #000000; font-weight: bold;">esac</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;)&quot;</span>
            rc_failed
            rc_status <span style="color: #660033;">-v1</span>
            rc_exit
        <span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #666666; font-style: italic;"># removing spaces from commandline to be able to compare with /proc/&lt;pid&gt;/cmdline</span>
        get_pid_for_cmd <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${HUDSON_CMD}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/ //g'</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">0</span> = <span style="color: #007800;">$pid</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Warning - Couldn't obtain PID for <span style="color: #007800;">${APP}</span> &quot;</span>
        <span style="color: #000000; font-weight: bold;">else</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$pid</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #800000;">${HUDSON_PIDFILE}</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        rc_status <span style="color: #660033;">-v</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> $<span style="color: #000000;">1</span> = <span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            check_hudson
	    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$status</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Warning - not running!&quot;</span>
	    <span style="color: #000000; font-weight: bold;">fi</span>
            killproc <span style="color: #660033;">-p</span> <span style="color: #800000;">${HUDSON_PIDFILE}</span> <span style="color: #660033;">-t</span> <span style="color: #000000;">10</span> <span style="color: #800000;">${JAVA}</span>
            rc_status <span style="color: #660033;">-v</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        check_hudson
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$status</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        <span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;(running)&quot;</span>
            rc_failed <span style="color: #000000;">0</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  
	    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;(running)&quot;</span>
	    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span>  <span style="color: #ff0000;">&quot;Warning - PID corrupted&quot;</span>
            rc_failed <span style="color: #000000;">0</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;(not running)&quot;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Warning - PID file found&quot;</span>
            rc_failed <span style="color: #000000;">3</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;(not running)&quot;</span>
            rc_failed <span style="color: #000000;">1</span>
            <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;(unknown)&quot;</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Warning - Couldn't get status&quot;</span>
            rc_failed <span style="color: #000000;">1</span>
            rc_status <span style="color: #660033;">-v1</span>
            rc_exit
    <span style="color: #000000; font-weight: bold;">esac</span>
    rc_status <span style="color: #660033;">-v</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        $<span style="color: #000000;">0</span> stop <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        $<span style="color: #000000;">0</span> start <span style="color: #000000; font-weight: bold;">&amp;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        rc_status <span style="color: #660033;">-v</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    usage<span style="color: #000000; font-weight: bold;">|</span><span style="color: #7a0874; font-weight: bold;">help</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        usage
        rc_exit
        <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        usage
        rc_failed <span style="color: #000000;">1</span>
        rc_status <span style="color: #660033;">-v</span>
        rc_exit
<span style="color: #000000; font-weight: bold;">esac</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2008/init-start-boot-script-for-hudson-continuous-integration-engine-on-suse-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux &#8211; List last modified directory</title>
		<link>http://www.rekk.de/bloggy/2008/linux-list-last-modified-directory/</link>
		<comments>http://www.rekk.de/bloggy/2008/linux-list-last-modified-directory/#comments</comments>
		<pubDate>Wed, 14 May 2008 14:08:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=51</guid>
		<description><![CDATA[ls -d --sort=time */ &#124; head -n 1]]></description>
			<content:encoded><![CDATA[<p><code>ls -d --sort=time */ | head -n 1</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2008/linux-list-last-modified-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion exclude files by svn:ignore and &#8216;svn add *&#8217;  pitfall</title>
		<link>http://www.rekk.de/bloggy/2008/subversion-exclude-files-by-svnignore-and-svn-add-pitfall/</link>
		<comments>http://www.rekk.de/bloggy/2008/subversion-exclude-files-by-svnignore-and-svn-add-pitfall/#comments</comments>
		<pubDate>Tue, 13 May 2008 14:57:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=49</guid>
		<description><![CDATA[To exclude certain files and directories from subversion&#8217;s version control you can set the &#8216;svn:ignore&#8217; property as described in Ignoring Unversioned Items. That works fine but nevertheless you might run into problems if you are using svn add * or similiar on linux systems. This is due to the shell expansion of wildcards. The above [...]]]></description>
			<content:encoded><![CDATA[<p>To exclude certain files and directories from subversion&#8217;s version control you can set the &#8216;svn:ignore&#8217; property as described in <a href="http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.ignore.html">Ignoring Unversioned Items</a>.<br />
That works fine but nevertheless you might run into problems if you are using<br />
<code>svn add *</code><br />
or similiar on <strong>linux </strong> systems. This is due to the shell expansion of wildcards. The above command is expanded to explicit files names <code>svn add filename</code> and seems to have the same effect as <code>svn add --no-ignore filename</code>.<br />
<strong>Tip: Use <code>svn add --force .</code> instead!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2008/subversion-exclude-files-by-svnignore-and-svn-add-pitfall/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Never ending learning &#8211; never ending surprise</title>
		<link>http://www.rekk.de/bloggy/2008/never-ending-learning-never-ending-surprise/</link>
		<comments>http://www.rekk.de/bloggy/2008/never-ending-learning-never-ending-surprise/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 13:02:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=39</guid>
		<description><![CDATA[Have you ever been surprised by obvious, even trivial facts which you have been overlooking for years? Today it hit me: I used shell metacharacters for expansion and even wrote quite complex bash scripts and used tree (not installed by default in ubuntu) to look into a given display depth of the directory tree. But [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever been surprised by obvious, even trivial facts which you have been overlooking for years?</p>
<p>Today it hit me:<br />
I used shell metacharacters for expansion and even wrote quite complex bash scripts and used tree (not installed by default in ubuntu) to look into a given display depth of the directory tree. But a combination of ls and shell expansion can do quite the same:<br />
<pre><code>ls */*
ls */*/*</code></pre></p>
<p>Another interesting example from the same category is<br />
<code>echo */</code><br />
to list all directories in working directory.</p>
<p>One more example &#8211; List only the directories :<br />
<code>ls -d */</code><br />
works similiar to<br />
<code>find . -type d -maxdepth 1 -mindepth 1</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2008/never-ending-learning-never-ending-surprise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scheduling Video (and Audio) Stream Recording on Linux</title>
		<link>http://www.rekk.de/bloggy/2007/scheduling-stream-recording-on-linux/</link>
		<comments>http://www.rekk.de/bloggy/2007/scheduling-stream-recording-on-linux/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 22:47:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=34</guid>
		<description><![CDATA[Say you want to record a video live stream from the internet for example from the Streaming CCC Congress in Berlin 2007. This can be accomplished using the glorious mplayer HOWTO Rip Streams With MPlayer. To stop the recording after a certain amount of time use this simple script (see also my post Finding Child [...]]]></description>
			<content:encoded><![CDATA[<p>Say you want to record a video live stream from the internet for example from the <a href="http://events.ccc.de/congress/2007/Streaming">Streaming CCC Congress in Berlin 2007</a>.</p>
<p>This can be accomplished using the glorious mplayer <a href="http://gentoo-wiki.com/HOWTO_Rip_Streams_With_MPlayer">HOWTO Rip Streams With MPlayer</a>.</p>
<p>To stop the recording after a certain amount of time use this simple script (see also my post <a href="http://www.rekk.de/bloggy/?p=33">Finding Child Process Pids &#8230;</a> ):<br />
<pre><code>#!/bin/bash
URL=$1
FILE=$2
# duration in minutes
DURATION=$3
mplayer -framedrop -autosync 30 -cache 10000 -dumpstream $URL -dumpfile $FILE &amp;amp;amp;
sleep $DURATIONm
kill %+</code></pre></p>
<p>Now you need to start this script at a certain time. For that you could use the linux &#8220;at&#8221; command (see <a href="http://linux.about.com/library/cmd/blcmdl1_at.htm">at</a>). To run it you have to export the DISPLAY variable on ubuntu (see <a href="https://bugs.launchpad.net/ubuntu/+source/at/+bug/94933">Bug #94933</a>):<br />
<code>export DISPLAY=$DISPLAY ; export TERM=$TERM; echo &quot;echo &#039;Hallo&#039;&quot; | at&nbsp;&nbsp;now</code></p>
<p>But I prefer KAlarm from KDE to schedule tasks which should run only once.<br />
Run KAlarm, create New Alarm, choose Action &#8220;Command&#8221;, enter the path to your script with appropriate arguments for stream url, dumpfile and duration in minutes:<br />
<code>/home/myhome/scripts/stream_ripper.sh mms://streaming-internet.fem.tu-ilmenau.de/saal3 test.asf 60</code><br />
, adjust all other settings which are quite self explaining. Use the template feature of KAlarm for similiar tasks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2007/scheduling-stream-recording-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding Child Process Pids in Bash Shell Scripts</title>
		<link>http://www.rekk.de/bloggy/2007/finding-child-pids-in-bash-shell-scripts/</link>
		<comments>http://www.rekk.de/bloggy/2007/finding-child-pids-in-bash-shell-scripts/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 20:35:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=33</guid>
		<description><![CDATA[To control background child processes from a shell script you want to know the PID or job-id of the child. Here are some ways to do this: First starting a background process echoes the job-id and pid of the process: $ emacs &#38;amp; [1] 15393 The PID of the last command set to run in [...]]]></description>
			<content:encoded><![CDATA[<p>To control background child processes from a shell script you want to know the PID or job-id of the child. Here are some ways to do this:</p>
<p>First starting a background process echoes the job-id and pid of the process:<br />
<pre><code>$ emacs &amp;amp;
[1] 15393</code></pre><br />
The PID of the last command set to run in the background by the current shell or script is stored in $! variable:<br />
<pre><code>$ echo $!
15393</code></pre><br />
This you could find out by using the jobs command:<br />
<code>$ PID=`jobs -l | sed -n &#039;s/^\[[0-9]*\] *+&nbsp;&nbsp;*\([0-9]*\) .*$/\1/p&#039;`; echo $PID</code><br />
using the fact that the last current (last started) job will be marked by a + in<br />
jobs -l output.<br />
To terminate the current job you don&#8217;t need the explicit job-id:<br />
<code>$ kill %+</code><br />
The exit status will be stored in the $? variable.<br />
Read more in the <a href="http://tldp.org/LDP/abs/html/x8618.html">Advanced Bash-Scripting Guide:Job Control Commands</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2007/finding-child-pids-in-bash-shell-scripts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Find Process ID by Port Number</title>
		<link>http://www.rekk.de/bloggy/2007/find-process-id-by-port-number/</link>
		<comments>http://www.rekk.de/bloggy/2007/find-process-id-by-port-number/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 22:39:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.rekk.de/bloggy/?p=18</guid>
		<description><![CDATA[In linux you can use some shell scripting to find a running server process by port number. I came up with this example using awk (watch out for backticks `): ps aux &#124; grep --regexp=&#34;`netstat -nlept &#124; awk '/:8079 / &#124;&#124; /:8080 / {split($9,t,&#34;/&#34;); print t[1]}'`&#34; where you suspect the server ports to be 8079 [...]]]></description>
			<content:encoded><![CDATA[<p>In linux you can use some shell scripting to find a running server process by port number. I came up with this example using awk (watch out for backticks `):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">--regexp</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`netstat -nlept | awk '/:8079 / || /:8080 / {split($9,t,&quot;/&quot;); print t[1]}'`</span>&quot;</span></pre></div></div>

<p>where you suspect the server ports to be 8079 or 8080. Problem here &#8211; if nothing is found then all processes will be listed. For automation you might prefer:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> u <span style="color: #660033;">--no-heading</span> <span style="color: #660033;">-p</span>  <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-nlept</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'/[:]8080 / {split($9,t,&quot;/&quot;); print t[1]}'</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

<p>&#8230; last part will redirect error/help message in case there is no process.</p>
<p>Or put it into a function:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">myserver_info<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">--regexp</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`netstat -nlept | awk '/8079/ || /8080/ {split($9,t,&quot;/&quot;); print t[1]}'`</span>&quot;</span>; <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>this definition you can add to your .bashrc .</p>
<p>Usage:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">myserver_info</pre></div></div>

<p>or pass it within a pipe to &#8220;kill &lt;pid&gt;&#8221; command for example.</p>
<p>You can extend it further by passing the ports as function arguments &#8230;  (see <a HREF="http://tldp.org/LDP/abs/html/functions.html">Advanced Bash-Scripting Guide: Functions</a>)</p>
<p>Do you know a shorter way to do the same?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rekk.de/bloggy/2007/find-process-id-by-port-number/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

