<?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>ไอเอินบล๊อก &#187; auto startup</title>
	<atom:link href="http://www.iearn.in.th/tag/auto-startup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iearn.in.th</link>
	<description>Just Play and Just Knowledge</description>
	<lastBuildDate>Fri, 05 Aug 2011 15:10:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Auto startup Script in Ubuntu</title>
		<link>http://www.iearn.in.th/2009/05/11/auto-startup-script-in-ubuntu/</link>
		<comments>http://www.iearn.in.th/2009/05/11/auto-startup-script-in-ubuntu/#comments</comments>
		<pubDate>Mon, 11 May 2009 13:45:34 +0000</pubDate>
		<dc:creator>nolifelover</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[auto startup]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.iearn.in.th/?p=445</guid>
		<description><![CDATA[ห่างหายไม่ได้เขียนบล๊อกไปนาน เพราะว่างานยุ่งมากมายวันนี้ได้โอกาสเนื่องจากว่า ว่างเล็กน้อยเลยมานั่งเขียนบล๊อก สำหรับเรื่องการสร้าง auto startup ใน ubuntu โดยใช้ shell script นี้ผมเขียนสำหรับ project jruby ครับเอาเป็นว่ามาดูกันเลยครับ 1. ขั้นแรกให้ทำการสร้างไฟล์ที่ต้องการครับ เช่น yun_trade ใน /etc/init.d 2. จากนั้นจึงทำการเขียน script ครับโดยตัวอย่างตามนี้ครับ #!/bin/sh &#160; echo &#34;YunTrade $1&#34; &#160; export JAVA_HOME=/home/administrator/java/jdk1.6.0_13 export PATH=$JAVA_HOME/bin:$PATH export JRUBY_HOME=/home/administrator/jruby/jruby-1.1.6 export PATH=$JRUBY_HOME/bin:$PATH export CLASSPATH=/home/administrator/project/trade_manager/lib/commons-beanutils-1.7.jar:/home/administrator/project/trade_manager/lib/commons-collections-2.1.jar:/home/administrator/project/trade_manager/lib/commons-digester-1.7.jar:/home/administrator/project/trade_manager/lib/commons-logging-1.1.jar:derbyclient.jar:/home/administrator/project/trade_manager/lib/iText-2.1.0.jar:/home/administrator/project/trade_manager/lib/mysql-connector-java-5.1.7-bin.jar:/home/administrator/project/trade_manager/lib/xalan.jar:/home/administrator/project/trade_manager/lib/jasperreports-3.1.3.jar:/home/administrator/project/trade_manager/report/fonts; &#160; DESC=&#34;YunTrade Development Server&#34; NAME=&#34;yun_trade&#34; PIDFILE=/home/administrator/project/yun_trade.pid set -e &#160; case &#34;$1&#34; in start&#41; echo [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://www.iearn.in.th/wp-content/uploads/2009/05/sh-auto-script.jpg"><img class="size-medium wp-image-446 aligncenter" title="sh-auto-script" src="http://www.iearn.in.th/wp-content/uploads/2009/05/sh-auto-script-300x157.jpg" alt="sh-auto-script" width="300" height="157" /></a></p>
<p>ห่างหายไม่ได้เขียนบล๊อกไปนาน เพราะว่างานยุ่งมากมายวันนี้ได้โอกาสเนื่องจากว่า ว่างเล็กน้อยเลยมานั่งเขียนบล๊อก สำหรับเรื่องการสร้าง auto startup ใน ubuntu โดยใช้ shell script นี้ผมเขียนสำหรับ project jruby ครับเอาเป็นว่ามาดูกันเลยครับ</p>
<p><span id="more-445"></span><br />
1. ขั้นแรกให้ทำการสร้างไฟล์ที่ต้องการครับ เช่น yun_trade ใน /etc/init.d<br />
2. จากนั้นจึงทำการเขียน script ครับโดยตัวอย่างตามนี้ครับ</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>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;YunTrade $1&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">JAVA_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>java<span style="color: #000000; font-weight: bold;">/</span>jdk1.6.0_13
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$JAVA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">JRUBY_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>jruby<span style="color: #000000; font-weight: bold;">/</span>jruby-1.1.6
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$JRUBY_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">CLASSPATH</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>commons-beanutils-<span style="color: #000000;">1.7</span>.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>commons-collections-<span style="color: #000000;">2.1</span>.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>commons-digester-<span style="color: #000000;">1.7</span>.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>commons-logging-<span style="color: #000000;">1.1</span>.jar:derbyclient.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>iText-2.1.0.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql-connector-java-5.1.7-bin.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>xalan.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jasperreports-3.1.3.jar:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>report<span style="color: #000000; font-weight: bold;">/</span>fonts;
&nbsp;
<span style="color: #007800;">DESC</span>=<span style="color: #ff0000;">&quot;YunTrade Development Server&quot;</span>
<span style="color: #007800;">NAME</span>=<span style="color: #ff0000;">&quot;yun_trade&quot;</span>
<span style="color: #007800;">PIDFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>yun_trade.pid
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&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>
        <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;">$DESC</span>:&quot;</span>
		jruby <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #000000; font-weight: bold;">&amp;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Server is Started&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: #660033;">-n</span> <span style="color: #ff0000;">&quot;Stopping <span style="color: #007800;">$DESC</span>: &quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> <span style="color: #007800;">$NAME</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Server is Stopped&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #000000; font-weight: bold;">|</span>force-reload<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;Restarting <span style="color: #007800;">$DESC</span>: &quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-9</span> <span style="color: #007800;">$NAME</span>
        <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">5</span>
        jruby <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>administrator<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trade_manager<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>server <span style="color: #000000; font-weight: bold;">&amp;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Server is Restarted&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: #007800;">N</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><span style="color: #007800;">$NAME</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$N</span> {start|stop|restart|force-reload}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</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>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>3. จากนั้นให้ทำการสั่งให้ script ของเรา auto start ครับ<br />
<code>update-rc.d -f yun_trade 99 2 3 4 5 .</code><br />
โดยคำสั่งนี้คือให้สร้างตัว startup ขึ้นมาโดย 99 คือลำดับการรันหมายถึงลำดับสุดท้าย 2 3 4 5 หมายถึงโหมดการรันของเครื่อง</p>

<p class="sayac_bilgi">278 views</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iearn.in.th/2009/05/11/auto-startup-script-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

