<?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>Ersin Acar &#187; boot</title>
	<atom:link href="http://ersinacar.com/tag/boot/feed" rel="self" type="application/rss+xml" />
	<link>http://ersinacar.com</link>
	<description>PHP and Web Technologies Freak</description>
	<lastBuildDate>Fri, 14 May 2010 11:57:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Debian: How to make scripts run at boot</title>
		<link>http://ersinacar.com/debian-how-to-make-scripts-run-at-boot_114.html</link>
		<comments>http://ersinacar.com/debian-how-to-make-scripts-run-at-boot_114.html#comments</comments>
		<pubDate>Sun, 17 May 2009 11:03:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[boot]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[init.d]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://ersinacar.com/?p=114</guid>
		<description><![CDATA[Debian uses a Sys-V like init system for executing commands when the system runlevel changes &#8211; for example at bootup and shutdown time.
If you wish to add a new service to start when the machine boots you should add the script to the directory /etc/init.d/. Many of the scripts already present in that directory will [...]]]></description>
			<content:encoded><![CDATA[<p>Debian uses a Sys-V like init system for executing commands when the system runlevel changes &#8211; for example at bootup and shutdown time.</p>
<p>If you wish to add a new service to start when the machine boots you should add the script to the directory /etc/init.d/. Many of the scripts already present in that directory will give you an example of the kind of things that you can do.</p>
<p>Here&#8217;s a very simple script which is divided into two parts, code which always runs, and code which runs when called with &#8220;start&#8221; or &#8220;stop&#8221;.<span id="more-114"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /bin/sh</span>
<span style="color: #666666; font-style: italic;"># /etc/init.d/routines</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Some lines that run always</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>routines
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>routines
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Carry out specific functions when asked to by the system</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>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting script routines &quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Could do more here&quot;</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping script routines&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Could do more here&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: #ff0000;">&quot;Usage: /etc/init.d/routines {start|stop}&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>Once you&#8217;ve saved your file into the correct location make sure that it&#8217;s executable by running &#8220;chmod 755 /etc/init.d/routines&#8221;.</p>
<p>Then you need to add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up.</p>
<p>The simplest way of doing this is to use the Debian-specific command update-rc.d:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>skx:~<span style="color: #666666; font-style: italic;"># update-rc.d blah defaults</span>
 Adding system startup <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines...
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc0.d<span style="color: #000000; font-weight: bold;">/</span>K20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc1.d<span style="color: #000000; font-weight: bold;">/</span>K20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc6.d<span style="color: #000000; font-weight: bold;">/</span>K20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc2.d<span style="color: #000000; font-weight: bold;">/</span>S20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc3.d<span style="color: #000000; font-weight: bold;">/</span>S20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc4.d<span style="color: #000000; font-weight: bold;">/</span>S20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc5.d<span style="color: #000000; font-weight: bold;">/</span>S20routines -<span style="color: #000000; font-weight: bold;">&gt;</span> ..<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines</pre></div></div>

<p>If you wish to remove the script from the startup sequence in the future run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root<span style="color: #000000; font-weight: bold;">@</span>skx:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc2.d<span style="color: #666666; font-style: italic;"># update-rc.d -f  routines remove</span>
update-rc.d: <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines exists during rc.d purge <span style="color: #7a0874; font-weight: bold;">&#40;</span>continuing<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 Removing any system startup links <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>routines ...
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc0.d<span style="color: #000000; font-weight: bold;">/</span>K20routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc1.d<span style="color: #000000; font-weight: bold;">/</span>K20routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc2.d<span style="color: #000000; font-weight: bold;">/</span>S20routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc3.d<span style="color: #000000; font-weight: bold;">/</span>S20routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc4.d<span style="color: #000000; font-weight: bold;">/</span>S20routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc5.d<span style="color: #000000; font-weight: bold;">/</span>S20routines
   <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc6.d<span style="color: #000000; font-weight: bold;">/</span>K20routines</pre></div></div>

<p>This will leave the script itself in place, just remove the links which cause it to be executed.</p>
<p>You can find more details of this command by running &#8220;man update-rc.d&#8221;. </p>
]]></content:encoded>
			<wfw:commentRss>http://ersinacar.com/debian-how-to-make-scripts-run-at-boot_114.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
