<?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>logIt &#187; startup</title>
	<atom:link href="https://lakm.us/logit/tag/startup/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Running Two Squid Instances in Upstart Init</title>
		<link>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/</link>
		<comments>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/#comments</comments>
		<pubDate>Fri, 10 May 2013 08:55:16 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=644</guid>
		<description><![CDATA[After installing squid3 from repository, Ubuntu will place the init in upstart style (instead of /etc/rc*.d/ or /etc/init.d/ style used to maintain backward compatibility to legacy System-V init). The upstart job is placed in /etc/init/squid3.conf with default runlevel (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using service: $ sudo [...]]]></description>
				<content:encoded><![CDATA[<p>After installing <a href="http://www.squid-cache.org/" target="_blank">squid3</a> from <a href="http://packages.ubuntu.com/precise/squid3" target="_blank">repository</a>, Ubuntu will place the <code>init</code> in <a href="http://upstart.ubuntu.com/" target="_blank">upstart</a> style (instead of <code>/etc/rc*.d/</code> or <code>/etc/init.d/</code> style used to maintain backward compatibility to legacy <a href="http://en.wikipedia.org/wiki/Init" target="_blank">System-V init</a>). The upstart job is placed in <code>/etc/init/squid3.conf</code> with default <code>runlevel</code> (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using <code>service</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> service squid3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>To specify what to run, an <code>upstart</code> <a href="http://upstart.ubuntu.com/getting-started.html" target="_blank">must have</a> <code>exec</code> or <code>script</code> stanza. When the goal is to start two or more (multiple) instances of <code>squid3</code>, <code>exec</code> is meant <a href="http://manpages.ubuntu.com/manpages/precise/man3/exec.3.html" target="_blank">to replace existing process image</a> of <code>/usr/sbin/squid3</code> executable, therefore will not start two instances.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Eltek Smartpack Controller type with SNMP Support" src="../../../../images/squid3-two-instances-illustration.png" title="Multiple squid3 instances started via upstart exec" width="385" height="188" /><p class="wp-caption-text">Multiple squid3 instances started via upstart exec</p></div>
<p>As workaround we can have symbolic link to <code>squid3</code> executable instead and add new <code>upstart</code> job configuration with <code>exec</code> call to the link. I need two instances running in the same machine due to the implementation design where the fist instance is HTTP proxy cache while the second one is accelerator/interceptor (reverse proxy) that serves default landing page telling user to use proxy (and how to do that). Hence, for the second instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">6</span> May  <span style="color: #000000;">3</span> 09:<span style="color: #000000;">25</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>squid3ins2 -<span style="color: #000000; font-weight: bold;">&gt;</span> squid3
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">1156</span> May  <span style="color: #000000;">6</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3ins2.conf</pre></div></div>

<p>and for the first instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">298</span> May  <span style="color: #000000;">3</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">13</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3.override</pre></div></div>

<p><code>squid3ins2</code> is our link and <code>/etc/init/squid3ins2.conf</code> contains <code>exec</code> call to it to run second <code>squid3</code>. For the first instance I choose to write an override (<code>/etc/init/squid3.override</code>) so that the original job configuration file is left intact. For the complete content of all files check <a href="https://github.com/bandono/proxyConf/tree/v1.1/init" target="_blank">my github v1.1</a> of the Squid integration. There, in details you&#8217;ll also find how both instances PID, log, etc. are differentiated by each instance config via the following directives:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http_port
cache_dir
pid_filename
cache_access_log
cache_log</pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Startup script for TAP interfaces</title>
		<link>https://lakm.us/logit/2009/02/startup-script-for-tap-interfaces/</link>
		<comments>https://lakm.us/logit/2009/02/startup-script-for-tap-interfaces/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 15:31:12 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://localhost/it/?p=8</guid>
		<description><![CDATA[To add startup script we can use: System > Preferences > Sessions local boot script (as services start/stop in /etc/init.d/) I added the following shell script: setup-tap: #! /bin/bash tap_up&#40;&#41; &#123; tunctl -t tap0 -u $USER tunctl -t tap1 -u $USER ifconfig tap0 192.168.20.1 ifconfig tap1 192.168.40.1 #iptables -t nat -A POSTROUTING -o eth1 -j [...]]]></description>
				<content:encoded><![CDATA[<p>To add startup script we can use:</p>
<ul>
<li>System > Preferences > Sessions</li>
<li>local boot script  (as  services start/stop  in  /etc/init.d/)</li>
</ul>
<p>I added the following shell script: <code>setup-tap</code>:</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>
tap_up<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>
tunctl <span style="color: #660033;">-t</span> tap0 <span style="color: #660033;">-u</span> <span style="color: #007800;">$USER</span>
tunctl <span style="color: #660033;">-t</span> tap1 <span style="color: #660033;">-u</span> <span style="color: #007800;">$USER</span>
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> tap0 192.168.20.1
<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> tap1 192.168.40.1
<span style="color: #666666; font-style: italic;">#iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE</span>
sysctl <span style="color: #660033;">-w</span> net.ipv4.ip_forward=<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
tap_down<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>
tunctl <span style="color: #660033;">-d</span> tap0
tunctl <span style="color: #660033;">-d</span> tap1
sysctl <span style="color: #660033;">-w</span> net.ipv4.ip_forward=<span style="color: #000000;">0</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<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>
tap_up
<span style="color: #000000; font-weight: bold;">;;</span>
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
tap_down
<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;Usage: $0 {start|stop}&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;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>Basically it is used as <code>./setup-tap start|stop</code>.  The following steps add it to boot:<br />
copy it to <code>/etc/init.d/setup-tap<br />
</code><code>chmod +xr setup-tap</code><code><br />
update-rc.d setup-tap defaults</code><br />
The last updating will put it in default runlevel:<br />
<code>setup-tap <strong>start</strong></code> in runlevel 2,3,4, and 5 <code>setup-tap <strong>stop</strong></code> in runlevel 1 and 6.</p>
<p>Specific to this script itself, it didn&#8217;t run at first due to the <code>$USER</code> environment variable which must be set to <code>arif</code> (my username).</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2009/02/startup-script-for-tap-interfaces/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
