<?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>kus.es</title>
	<atom:link href="http://www.kus.es/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kus.es</link>
	<description>Sobre los mares, reales o de la información</description>
	<lastBuildDate>Fri, 17 Feb 2012 10:22:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Proof of Concept: Build my own Web Provider at home (III) – Stunnel</title>
		<link>http://www.kus.es/2011/11/22/proof-of-concept-build-my-own-web-provider-at-home-iii-%e2%80%93-stunnel/</link>
		<comments>http://www.kus.es/2011/11/22/proof-of-concept-build-my-own-web-provider-at-home-iii-%e2%80%93-stunnel/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 19:19:57 +0000</pubDate>
		<dc:creator>Kus</dc:creator>
				<category><![CDATA[IT]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=248</guid>
		<description><![CDATA[Stunnel The stunnel software is awesome. It allows you to encrypt any connection between local or remote systems. We will use it to perform the SSL Offloading for our system. This tool will take care of all the SSL encryption, releasing that burden from the web servers, because web servers are &#8230; well, web servers, not SSL managers. We will use stunnel to: Listen for secure SSL connections on port [...]]]></description>
			<content:encoded><![CDATA[<h1>Stunnel</h1>
<div id="attachment_249" class="wp-caption aligncenter" style="width: 275px"><a href="http://www.stunnel.org/"><img class="size-full wp-image-249" title="stunnel Logo" src="http://www.kus.es/wp-content/uploads/2011/11/stunnel.png" alt="stunnel Logo" width="265" height="61" /></a><p class="wp-caption-text">stunnel Logo</p></div>
<p>The <a href="http://www.stunnel.org/" target="_blank">stunnel</a> software is awesome. It allows you to encrypt any connection between local or remote systems. We will use it to perform the SSL Offloading for our system. This tool will take care of all the SSL encryption, releasing that burden from the web servers, because web servers are &#8230; well, web servers, not SSL managers.</p>
<p>We will use stunnel to:</p>
<ol>
<li>Listen for secure SSL connections on port 443 of our external IPs</li>
<li>Manage the encryption/decryption</li>
<li>Request (without encryption) the web page from the Web servers</li>
<li>Send the request back to the client encrypted</li>
</ol>
<p>&nbsp;</p>
<p>From the Stunnel web page:</p>
<p style="padding-left: 30px;"><em>The stunnel program is designed to work as an SSL encryption wrapper between remote client and local (inetd-startable) or remote server. It can be used to add SSL functionality to commonly used inetd daemons like POP2, POP3, and IMAP servers without any changes in the programs&#8217; code. Stunnel uses <a href="http://www.openssl.org/">OpenSSL</a> libraries for cryptography, so it supports whatever cryptographic algorithms you compiled into your library. </em></p>
<p style="padding-left: 30px;"><em>Stunnel can benefit from <a href="http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/1401val2008.htm#1051">FIPS 140-2</a> certification of the OpenSSL library, as long as the building process meets its <a href="http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1051.pdf">Security Policy</a>. </em></p>
<p style="padding-left: 30px;"><em>Stunnel is a free software authored by <a href="http://mike.mirt.net/">Michal Trojnara</a>. Although distributed under <a href="http://www.stunnel.org/?page=license">GNU GPL version 2 or later with OpenSSL exception</a>, stunnel is not a community project. We retain the copyright of the source code. Please <a href="http://www.stunnel.org/?page=contact">contact us</a> for support or non-GPL licenses. </em></p>
<p style="padding-left: 30px;"><em>The obsolete 3.x branch is no longer maintained. Use <a href="ftp://ftp.stunnel.org/stunnel/stunnel3">stunnel3</a> perl script as a drop-in replacement for backward compatibility.</em></p>
<p>Ideally you could run your own farm of TLS/SSL Offloaders using their own hardware (in combination with a balancing  software tools like <a href="http://haproxy.1wt.eu/">HAproxy</a> / <a href="http://www.backhand.org/wackamole/">Wackamole</a> / <a href="http://www.spread.org/">Spread</a>  / <a href="http://www.ultramonkey.org/">UltraMonkey</a> you can have your own home made High Availability Load Balancer). As mentioned before, this would allow you to release the encryption load from the Web tier.</p>
<p><span id="more-248"></span></p>
<h2>Our certificate</h2>
<p>But first, we need an TLS/SSL certificate. You can <a href="http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#selfcert" target="_blank">build your own self signed certificate</a> (but it will generate a warnign alert as it is officially signed by a real CA) or buy one from any of the <a href="https://www.google.com/search?q=Certificate+Authority&amp;ie=utf-8&amp;oe=utf-8" target="_blank">Certificates Authorities</a> (CA).</p>
<p>An important concept: You can only have 1 SSL certificate per IP (in other words, you need to have as many IPs as different SSL domains you have). Why? Simple, the certificate needs to be sent as soon as the HTTP connection is established and at that point the Client still has not sent to the Server which FQDN (domain) they want to get. You have the Apache explanation <a href="http://httpd.apache.org/docs/2.2/ssl/ssl_faq.html#vhosts" target="_blank">here</a>. There is a relative exception here. If you use subdomains (sub1.kus.es sub2.kus.es etc) then you can use a wild-card certificate (a cert that is valid for *.kus.es).</p>
<h2>The tool</h2>
<p>I recommend you to download Stunnel software from source, apply the <a href="http://www.exceliance.fr/download/free/patches/stunnel/x-forwarded-for/">&#8216;xforwaredefor&#8217; patch</a> from the HAproxy site and install it. Why? Because this patch will allow Stunnel to send the source IP to the next tier, in this case, to HAproxy. This is a cut&amp;paste from the HAproxy site:</p>
<p style="padding-left: 30px;"><em><strong>X-Forwarded-For support for Stunnel</strong></em></p>
<p style="padding-left: 30px;"><em><a href="http://www.stunnel.org/">Stunnel</a> currently makes a perfect complement to provide SSL client-side support to HAProxy. However, since Stunnel is a proxy an has no knowledge of HTTP, the client&#8217;s IP address was lost, which is somewhat annoying. A few patches were available on the Net to add the X-Forwarded-For header, but they introduced an undesirable <strong>buffer overflow</strong>. So I took my courage and wrote a reliable and secure patch to implement this useful feature. I sent it to Stunnel&#8217;s authors but got no feedback. So the patch is provided here for various versions from Stunnel-4.14 and above in the hope it will be useful to some people. At least it seems to be the case, considering the number of people who send updates <img src='http://www.kus.es/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  <strong>Note that this patch does not work with keep-alive, see send-proxy below for that</strong>.</em></p>
<p style="padding-left: 30px;"><em><a href="http://www.exceliance.fr/download/free/patches/stunnel/x-forwarded-for/">Get the patches from Exceliance&#8217;s public patch repository</a></em></p>
<h2> The setup</h2>
<p>Ok, now thatyou have Stunnel compiled &amp; installed, let&#8217;s set up our stunnel instance. The following configuration file defines some basic settings for the SSL encryption: it forces Stunnel to use only &#8216;good&#8217; ciphers, don&#8217;t use SSLv2, TCP timeouts, etc. I do recommend you to check the Stunnel documentation for</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Descargar <a href="http://www.kus.es/wp-content/plugins/wp-codebox/wp-codebox.php?p=248&amp;download=stunnel.conf">stunnel.conf</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2482"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p248code2"><pre class="bash" style="font-family:monospace;">; Protocol version <span style="color: #7a0874; font-weight: bold;">&#40;</span>all but not SSLv2<span style="color: #7a0874; font-weight: bold;">&#41;</span>
sslVersion = all
options = NO_SSLv2
;PID location
pid = <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>stunnel4.pid
; TCP settings
socket = l:<span style="color: #007800;">TCP_NODELAY</span>=<span style="color: #000000;">1</span>
socket = r:<span style="color: #007800;">TCP_NODELAY</span>=<span style="color: #000000;">1</span>
TIMEOUTclose = <span style="color: #000000;">0</span>
TIMEOUTbusy = <span style="color: #000000;">180</span>
TIMEOUTconnect = <span style="color: #000000;">30</span>
TIMEOUTidle = <span style="color: #000000;">60</span>
;Location of the Common Authorities certificates
CApath = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>certs
;Logging. Set debug to <span style="color: #000000;">7</span> <span style="color: #000000; font-weight: bold;">for</span> debugging
debug = <span style="color: #000000;">0</span>
output = <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>stunnel4<span style="color: #000000; font-weight: bold;">/</span>stunnel.log
;Use only strong ciphers
ciphers = HIGH:MEDIUM:<span style="color: #000000; font-weight: bold;">!</span>ADH
;libwrap = <span style="color: #c20cb9; font-weight: bold;">yes</span>
;Number of sessions to manage <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">in</span> concordance with the haproxy setup<span style="color: #7a0874; font-weight: bold;">&#41;</span>
session = <span style="color: #000000;">300</span>
&nbsp;
;Specific settings <span style="color: #000000; font-weight: bold;">for</span> kus.es
<span style="color: #7a0874; font-weight: bold;">&#91;</span>https-kus.es<span style="color: #7a0874; font-weight: bold;">&#93;</span>
;Certificate files location, <span style="color: #000000; font-weight: bold;">for</span> automatic startup remove the passphrase from the key
<span style="color: #007800;">cert</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>kus.es.crt
<span style="color: #007800;">key</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>kus.es.key
;where lo listen, change external-ip with your real external IP
<span style="color: #007800;">accept</span>=external-ip:<span style="color: #000000;">443</span>
;where is haproxy listeing <span style="color: #000000; font-weight: bold;">for</span> Stunnel requests
<span style="color: #007800;">connect</span>=127.0.0.1:<span style="color: #000000;">8443</span>
;send the <span style="color: #7a0874; font-weight: bold;">source</span> IP to haproxy via the X-Forwarded-For header
<span style="color: #007800;">xforwardedfor</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>With this setup, you tell Stunnel to listen on the external IP of your server in the port 443 (<code>accept=external-ip:443</code>). Once it gets a request, it will use the certificate (<code>cert=/etc/ssl/certs/kus.es.crt</code>) to set up the SSL handshake and encrypt the connection and will connect to HAproxy (<code>connect=127.0.0.1:8443</code>) to obtain the web page the user has requested. Once it gets the page, it will be encrypted and sent back to the client.</p>
<p>Yes, we need to have haproxy listening on the port 8443 of the loopback interface. We will see why and how on the next chapter&#8230;</p>
<h2>Useful commands</h2>
<h3>Remove the  passphrase from the certificate key</h3>
<p>Careful here, if you remove the passphrase from the key, anyone with access to it maybe be able to use your certificate. If you do this, make sure  you secure the key file:</p>
<p>openssl rsa -in server-with-pass.key -out server-without-pass.key</p>
<h3>From crt to pem formats (option I)</h3>
<h4>Ugly way:</h4>
<p><code>$&gt; openssl x509 -in input.crt -out input.der -outform DER</code></p>
<p><code>$&gt; openssl x509 -in input.der -inform DER -out output.pem -outform PEM</code></p>
<h3>From crt to pem formats (option II)</h3>
<p>This one embeddds the key in the pem file, needed by some LB software as pound</p>
<p><code>$&gt; openssl x509 -in server.crt -out server.pem</code></p>
<p><code>$&gt; openssl rsa -in server.key &gt;&gt; server.pem</code></p>
<h3>Compile stunnel from source</h3>
<ol>
<li>Create a temporary directory /home/yourser/src<br />
<code><br />
cd &amp;&amp; mkdir src &amp;&amp; cd src<br />
</code></li>
<li>Download the Stunnel source (in this case, version 4.44) and extract it<br />
<code><br />
wget -c http://mirrors.zerg.biz/stunnel/archive/4.x/stunnel-4.44.tar.gz<br />
tar zxvf stunnel-4.44.tar.gz<br />
</code></li>
<li>Download the X-Forwarded-For patch and apply it<br />
<code><br />
wget -c http://www.exceliance.fr/download/free/patches/stunnel/x-forwarded-for/stunnel-4.44-xforwarded-for.diff<br />
patch -p0 &lt; stunnel-4.44-xforwarded-for.diff<br />
</code></li>
<li>Configure and compile it based on your needs (I like to install it in /opt)<br />
<code><br />
cd stunnel-4.44<br />
./configure --prefix=/opt/stunnel-4.44 --enable-static --with-gnu-ld --with-threads=pthread<br />
make<br />
sudo make install<br />
sudo ln -s /opt/stunnel-4.44 /opt/stunnel<br />
sudo ln -s /opt/stunnel/bin/stunnel /opt/stunnel/bin/stunnel4<br />
</code></li>
</ol>
<h3>Patch to modify the default&#8217;s Ubuntu startup file /etc/init.d/stunnel4</h3>
<p>If you have patched Stunnel tool, you need to modify the startup scripts to use the new binary, that is located at <code>/opt/stunnel/bin/stunnel4</code>. You can directly edit your <code>/etc/init.d/stunnel4</code> or you can apply this patch:</p>
<pre line="1" file="init.d-stunnel4.diff" colla="+" lang="diff">--- stunnel4.dpkg-dist	2009-12-22 08:57:08.000000000 +0100
+++ stunnel4	2011-11-22 20:11:18.000000000 +0100
@@ -11,7 +11,7 @@
 ### END INIT INFO

 DEFAULTPIDFILE="/var/run/stunnel4.pid"
-DAEMON=/usr/bin/stunnel4
+DAEMON=/opt/stunnel/bin/stunnel4
 NAME=stunnel
 DESC="SSL tunnels"
 FILES="/etc/stunnel/*.conf"</pre>
<p>Previous: <a title="ssh" href="https://www.kus.es/2011/09/25/proof-of-concept-build-my-own-web-provider-at-home-ii-%E2%80%93-sshd/">SSH</a><br />
Next: HAProxy</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2011/11/22/proof-of-concept-build-my-own-web-provider-at-home-iii-%e2%80%93-stunnel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wikipedia needs you!</title>
		<link>http://www.kus.es/2011/11/21/the-wikipedia-needs-you/</link>
		<comments>http://www.kus.es/2011/11/21/the-wikipedia-needs-you/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 09:44:18 +0000</pubDate>
		<dc:creator>Kus</dc:creator>
				<category><![CDATA[IT]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=255</guid>
		<description><![CDATA[wikipedia support]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.wikipedia.org/">Wikipedia </a>is in need of our help: they need a bit of funding to continue providing their invaluable help without the need of advertising.</p>
<p>I personally think this project reflects the best of the Internet: share knowledge thanks to the community efforts and for the community.</p>
<p>If you have a free minute and a dollar to spend, that&#8217;s a good project. Go to <a href="http://www.wikipedia.org/">any of their articles</a> or click in the link below to support them:<br />
<a href="https://wikimediafoundation.org/wiki/Support_Wikipedia/en"><img class="aligncenter" src="//upload.wikimedia.org/wikipedia/commons/4/4b/Fundraising_2009-square-treasure-en.png" alt="Support Wikipedia" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2011/11/21/the-wikipedia-needs-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proof of Concept: Build my own Web Provider at home (II) – sshd</title>
		<link>http://www.kus.es/2011/09/25/proof-of-concept-build-my-own-web-provider-at-home-ii-%e2%80%93-sshd/</link>
		<comments>http://www.kus.es/2011/09/25/proof-of-concept-build-my-own-web-provider-at-home-ii-%e2%80%93-sshd/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 22:49:50 +0000</pubDate>
		<dc:creator>Kus</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=220</guid>
		<description><![CDATA[sshd The sshd daemon will be used to access the system. If we want to have multiple web instances, each one managed by different individuals, we&#8217;d usually think about setting up a FTP server and create virtual users (so we know they cannot log in). Or, we can use the SFTP subsystem, rely on the OS user management and also have Secure FTP only access to our system. Even more, [...]]]></description>
			<content:encoded><![CDATA[<h2><a id="sshd" name="sshd"></a>sshd</h2>
<p><a href="http://www.kus.es/wp-content/uploads/2011/09/ssh.jpg"><img class="aligncenter size-full wp-image-240" title="ssh" src="http://www.kus.es/wp-content/uploads/2011/09/ssh.jpg" alt="" width="480" height="314" /></a></p>
<p>The sshd daemon will be used to access the system. If we want to have multiple web instances, each one managed by different individuals, we&#8217;d usually think about setting up a FTP server and create virtual users (so we know they cannot log in). Or, we can use the SFTP subsystem, rely on the OS user management and also have Secure FTP only access to our system. Even more, we can create RSA keys for the users so they don&#8217;t need to worry about passwords. The main features of the setup would be:</p>
<ul>
<li>We will grant only SFTP access to the UNIX accounts of the web instances, this way we will have a Secure FTP server that relies on the system accounts. No shell access will be granted to these users.</li>
<li>The access to the root user is disabled (we can allow forced commands to run rsync scripts)</li>
<li>The UNIX group <strong>sshusers</strong> defines the users that can access to a shell via ssh<acronym title="Secure Shell"></acronym></li>
<li>The UNIX group <strong>sftpweb</strong> defines the users that will only access the system via SFTP (they cannot get a shell).This group contains all the users created to run the Web instances. In fact, they will only be able to access a particular directory (in this example this directory is <code>/home/user/data</code>, where the user will find his <code>htdocs/</code> and <code>logs/</code> directories of the web instance)</li>
<li>In the case that Public Key authentication is going to be used, make sure we manage the public keys, so the users cannot modify them.</li>
</ul>
<p><span id="more-220"></span></p>
<p>Make sure the sshd daemon is installed on your system</p>
<p style="padding-left: 30px;"><code>$&gt; apt-get install opensshd-server</code></p>
<p>Let&#8217;s have a look at the config file <code>/etc/ssh/sshd_config</code>. This file defines the settings for the sshd daemon (make a backup of your default sshd_config file, in case something goes wrong!):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Descargar <a href="http://www.kus.es/wp-content/plugins/wp-codebox/wp-codebox.php?p=220&amp;download=ssd_config">ssd_config</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2205"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code" id="p220code5"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#You can modify the default port if you want. Now very useful, really.</span>
Port <span style="color: #000000;">22</span>
<span style="color: #666666; font-style: italic;">#Only use prococol 2</span>
Protocol <span style="color: #000000;">2</span>
HostKey <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>ssh_host_rsa_key
UsePrivilegeSeparation <span style="color: #c20cb9; font-weight: bold;">yes</span>
KeyRegenerationInterval <span style="color: #000000;">3600</span>
ServerKeyBits <span style="color: #000000;">768</span>
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime <span style="color: #000000;">20</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#We want to allow root to execute some commands (rsycn) from other servers.</span>
PermitRootLogin forced-commands-only
&nbsp;
<span style="color: #666666; font-style: italic;">#Make sure the user's directory has the proper permissions</span>
StrictModes <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
RSAAuthentication <span style="color: #c20cb9; font-weight: bold;">yes</span>
PubkeyAuthentication <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#You can force the users to authenticate only via keys</span>
<span style="color: #666666; font-style: italic;">#Save the user keys into /etc/ssh/users/%u/authorized_keys where %u is the user name</span>
<span style="color: #666666; font-style: italic;">#and set PasswordAuthentication no</span>
<span style="color: #666666; font-style: italic;">#AuthorizedKeysFile     /etc/ssh/users/%u/authorized_keys</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Standard setup, modify to fix your needs:</span>
IgnoreRhosts <span style="color: #c20cb9; font-weight: bold;">yes</span>
RhostsRSAAuthentication no
HostbasedAuthentication no
<span style="color: #666666; font-style: italic;">#IgnoreUserKnownHosts yes</span>
PermitEmptyPasswords no
ChallengeResponseAuthentication no
<span style="color: #666666; font-style: italic;">#PasswordAuthentication no</span>
<span style="color: #666666; font-style: italic;">#KerberosAuthentication no</span>
<span style="color: #666666; font-style: italic;">#KerberosGetAFSToken no</span>
<span style="color: #666666; font-style: italic;">#KerberosOrLocalPasswd yes</span>
<span style="color: #666666; font-style: italic;">#KerberosTicketCleanup yes</span>
<span style="color: #666666; font-style: italic;">#GSSAPIAuthentication no</span>
<span style="color: #666666; font-style: italic;">#GSSAPICleanupCredentials yes</span>
X11Forwarding <span style="color: #c20cb9; font-weight: bold;">yes</span>
X11DisplayOffset <span style="color: #000000;">10</span>
PrintMotd <span style="color: #c20cb9; font-weight: bold;">yes</span>
PrintLastLog <span style="color: #c20cb9; font-weight: bold;">yes</span>
TCPKeepAlive <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;">#UseLogin no</span>
<span style="color: #666666; font-style: italic;">#MaxStartups 10:30:60</span>
Banner <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>issue.net
&nbsp;
<span style="color: #666666; font-style: italic;"># Allow client to pass locale environment variables</span>
AcceptEnv LANG LC_<span style="color: #000000; font-weight: bold;">*</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#We only allow users of the sshusers grup to access the system</span>
AllowGroups sshusers
UsePAM <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Here we define that users that belong to sftpweb can only access the secure-ftp subsystem</span>
<span style="color: #666666; font-style: italic;">#Note we give them access to a subdirectory of their home dir and we do not let them do TCP</span>
<span style="color: #666666; font-style: italic;">#forwarding, etc.</span>
Subsystem sftp internal-sftp
Match Group sftpweb
  ChrootDirectory <span style="color: #000000; font-weight: bold;">%</span>h<span style="color: #000000; font-weight: bold;">/</span>data
  X11Forwarding no
  AllowAgentForwarding no
  AllowTcpForwarding no
  ForceCommand internal-sftp</pre></td></tr></table></div>

<p>With this setup, the sshd daemon will be ready to prevent shell access to the users we add to both the sshusers and the sftpweb groups.Make sure you reload the sshd server to reflect the changes.</p>
<p>We will see in following entries how to create a user to have only SFTP access. As a small spoiler, 3 thins are needed:</p>
<ol>
<li>Create the user with the shell <code>/bin/false</code></li>
<li>Add the user to the <strong>sshusers</strong> and <strong>sftweb</strong> groups</li>
<li>Make sure the directories above <code>/home/user/data</code> (including it) belong to root. This is necessary for the SFTP to set up the jail correctly. So yes, <code>/home, /home/user and /home/user/data</code> must belong to <strong>root<br />
</strong></li>
</ol>
<p>As an example, we can create a user and test the setup:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Descargar <a href="http://www.kus.es/wp-content/plugins/wp-codebox/wp-codebox.php?p=220&amp;download=examples_ssh">examples_ssh</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2206"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p220code6"><pre class="bash" style="font-family:monospace;">groupadd sshusers
groupadd sftpweb
&nbsp;
<span style="color: #666666; font-style: italic;">#Add any user you want to be able to access via ssh to the sshusers group</span>
<span style="color: #666666; font-style: italic;">#Add any user you want to be restricted to sftp to both sshusers and sftpweb</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Let's create a test user:</span>
useradd <span style="color: #660033;">-G</span> sshusers,sftpweb <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;Test SFTP user&quot;</span> <span style="color: #660033;">-m</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>testsftpuser <span style="color: #660033;">-s</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;">false</span> testsftpuser
<span style="color: #c20cb9; font-weight: bold;">passwd</span> testsftpuser
<span style="color: #7a0874; font-weight: bold;">&#40;</span>...<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>testsftpuser<span style="color: #000000; font-weight: bold;">/</span>data
<span style="color: #c20cb9; font-weight: bold;">chown</span> root <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>testsftpuser
<span style="color: #c20cb9; font-weight: bold;">chown</span> root <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>testsftpuser<span style="color: #000000; font-weight: bold;">/</span>data
<span style="color: #c20cb9; font-weight: bold;">ssh</span> testsftpuser<span style="color: #000000; font-weight: bold;">@</span>localhost
<span style="color: #7a0874; font-weight: bold;">&#40;</span>Should fail...Permission denied<span style="color: #7a0874; font-weight: bold;">&#41;</span>
sftp testsftpuser<span style="color: #000000; font-weight: bold;">@</span>localhost
<span style="color: #7a0874; font-weight: bold;">&#40;</span>Should work...<span style="color: #7a0874; font-weight: bold;">&#41;</span>
userdel testsftpuser</pre></td></tr></table></div>

<p>That user should not be able to access the system via ssh, but would be able to transfer files via SFTP into (and only into) the <code>/home/testsftpuser/data</code> directory. <strong>Once the tests have been completed, I&#8217;d suggest to remove that user</strong>.<br />
There are multiple references on the web about this topic:</p>
<ol>
<li><a href="http://ubuntuforums.org/showthread.php?t=858475">http://ubuntuforums.org/showthread.php?t=858475</a></li>
<li><a href="http://www.debian-administration.org/articles/590">http://www.debian-administration.org/articles/590</a></li>
</ol>
<p>Previous:  <a href="https://www.kus.es/2011/09/12/proof-of-concept-build-my-own-web-provider-at-home-i-the-idea/">The idea</a></p>
<p>Next:  <a title="Stunnel" href="https://www.kus.es/2011/11/22/proof-of-concept-build-my-own-web-provider-at-home-iii-%E2%80%93-stunnel/">Stunnel</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2011/09/25/proof-of-concept-build-my-own-web-provider-at-home-ii-%e2%80%93-sshd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proof of Concept: Build my own Web Provider at home I &#8211; The idea</title>
		<link>http://www.kus.es/2011/09/12/proof-of-concept-build-my-own-web-provider-at-home-i-the-idea/</link>
		<comments>http://www.kus.es/2011/09/12/proof-of-concept-build-my-own-web-provider-at-home-i-the-idea/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 15:53:56 +0000</pubDate>
		<dc:creator>Kus</dc:creator>
				<category><![CDATA[IT]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=194</guid>
		<description><![CDATA[Personal notes about how to run a LAMP system at home using stunnel and HAProxy]]></description>
			<content:encoded><![CDATA[<h2>The idea</h2>
<p>I&#8217;ve run web servers at home for a quite long time. I used to have my LAMP system (compiled to fit my needs) running on <code>Slackware</code> and it covered all my needs for many years. But during the last years I found myself running very different flavors of Application Servers and I found that my LAMP setup was not flexible enough to deal with such an heterogeneous systems.</p>
<p>I wanted to have a solution that would allow me to run different web servers (<code>Apache, nginx, Jetty</code>&#8230;), different Application Servers (<code>Tomcat, WebLogic, JBoss, Django</code>, perl scripts, etc..) all of them isolated as much as possible from the others.</p>
<p><a href="http://www.kus.es/wp-content/uploads/2011/09/wh.jpg"><img class="aligncenter size-full wp-image-222" title="wh" src="http://www.kus.es/wp-content/uploads/2011/09/wh.jpg" alt="" width="317" height="189" /></a></p>
<p>Since this is a home solution and I cannot afford to have a rack full of blades at home, all these services should run in commodity hardware. I&#8217;ve chosen to run it on a laptop, that gives me a UPS service (battery) although it has the drawback of not much CPU power and (most important)  not much RAM. Of course, the solution could be extrapolated to multiple machines, having the ability to grow either horizontally or vertically. But for now, this solution will be confined into a single server <img src='http://www.kus.es/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /><br />
My ideal solution should, if possible, cover these needs:</p>
<p><span id="more-194"></span></p>
<div>
<ul>
<li>
<div>Minimize the administration time &amp; effort, using &#8211; if possible  &#8211; a standard, updated, with a good life cycle and well documented Operating System.<code></code></div>
</li>
<li>
<div>Federate each Web Instance in such a way that it should be independent from any other:</div>
<ul>
<li>
<div>Each Web Instance can run its own software product (We can have <code>Apache 2.2, Jetty, iPlanet</code> etc. as Web Servers serving content)</div>
</li>
<li>
<div>Each Web instance should run under its own UNIX account and should run in its the userspace.</div>
</li>
<li>
<div>Each Web instance that use the same product (say Apache or nginx) should share the same binaries (easy upgrade process) but should use its own configuration (for instance, each apache instance can load only the modules it needs)</div>
</li>
<li>
<div>Each Apache instance can load only the modules it needs. The idea of Debian&#8217;s VirtualHosts solution is not desirable, as all the VHosts will have the modules loaded. It makes no sense to me that an Apache instance used as a Tomcat front-end (using <code>mod_jk</code>) should also need to load the PHP5 module, only b/c other VHost uses it.</div>
</li>
<li>
<div>Each Web instance, if using <acronym title="Hypertext Preprocessor">PHP</acronym>, should have its own <code>php.ini</code> file.</div>
</li>
<li>
<div>The UNIX accounts used to run the instances should be either not accessible or only accessible via <code>SFTP<code></code></code></div>
</li>
</ul>
</li>
<li>Two networks, one for the service and a second one for administration, backups, etc.</li>
<li>
<div>Two <code>sshd</code> daemons, the one that comes with the OS and a secondary one (static) to be used only in case of issues with the first one.</div>
</li>
<li>
<div>A Software Load Balancer (<code>haproxy</code>)</div>
</li>
<li>
<div><acronym title="Secure Sockets Layer">SSL</acronym> offloading (<code>stunnel</code>)</div>
</li>
<li>
<div>Cache service (<code>varnish</code>, but the lack of RAM may not allow it)</div>
</li>
<li>
<div><acronym title="Structured Query Language">SQL</acronym> Cache system (<code>memcached</code>) for those applications that can benefit from it (again, the RAM constrictions can be an issue here)</div>
</li>
<li>Multiple <code>MySQL</code> instances (either manually done or using <code>multi-mysql</code>)</li>
<li>
<div><strong>Optional</strong>: File system encryption</div>
</li>
</ul>
</div>
<p>This solution adds also a extra burden. We are not using a single web server with multiple Vrtual Hosts, so we need to add a software that gives us that ability. Our candidate is HAProxy. It will take care of the multiple domain names and also will be a good solution for doing load balancing/failover solutions.</p>
<p>Let&#8217;s have a look at a diagram to get an idea of who the elements interact:</p>
<div id="attachment_211" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.kus.es/wp-content/uploads/2011/09/web-setup-home.png"><img class="size-full wp-image-211 " title="web setup home" src="http://www.kus.es/wp-content/uploads/2011/09/web-setup-home.png" alt="" width="450" height="191" /></a><p class="wp-caption-text">Overview of the services and how they interact</p></div>
<p>The reader will realize there are some elements that have been added to avoid <a href="http://en.wikipedia.org/wiki/Single_point_of_failure">single point of failures</a> (as the redundant router) that will be quite hard to implement in a home network; Other services as stunnel, HAProxy, Web servers and DB backends are easier to  set up in high availability. But since I&#8217;m going to install all of this into a single server, there is a HUGE <a href="http://en.wikipedia.org/wiki/Single_point_of_failure">SPOF</a> : The server itself! I just wanted to demonstrate that, having the necessary resources, the setup can be built in a a high-availability fashion.</p>
<p>So, what are the requirements?</p>
<h2>Requirements</h2>
<ul>
<li>A Server. I&#8217;ve chosen a Laptop (its batteries are my UPS system <img src='http://www.kus.es/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   (the more memory, the better!) It may be desireable to have two NICs (my second one is a JME 1xGigabit installed in the ExpressCard expansion slot). If you want to play in a more controlled environment, any virtual setup will work too.</li>
<li>A Linux/UNIX distro. I&#8217;ve chosen Ubutu 10.04 LTS Server because it worked fine with my laptop hw. Slackware, Debian Stable, Fedora, or any other Linux Distro will work fine too. Of course, the BSD  family is an excellent choice too.</li>
<li>Have that distro installed on the server.</li>
<li>An Internet connection (DSL will work, don&#8217;t expect to be fast if your upload is low).</li>
<li>Redirect some ports from your router to the Server.</li>
<li>A DNS domain working (we will cover other day how to run tinydns). If you have a dynamic IP,you may want to use any of the free dynamic DNS solutions available in the net.</li>
<li>A bit of free time.</li>
<li>Coffee, tea, lemonade&#8230;</li>
</ul>
<h2>Operating System</h2>
<p>If you have chosen Ubuntu, make sure you install the Apache, PHP and MySQL packages. You will find yourself with an Apache web server running on port 80 and all its config files located at <code>/etc/apache2</code>. These files will be used as our foundation for our setup.<br />
If you have chosen to have two networks, configure them and do not setup any kind on NAT over them. This is not really necessary but it is always good to have an administration network that can be used for monitoring (Zabbix? Hyperic?), backup (bacula?) and general management.</p>
<h3>A bit of security</h3>
<p>The following lines just give you some extra features that I recommend to tighten a bit more the security of a Linux setup. Please note that your system may not be secure by only following these instructions. There are many places int he web where you can find very useful documentation about to create a <a href="http://en.wikipedia.org/wiki/Sarbanes-Oxley_Act">SOX </a>or <a href="http://www.sas70.com/about.htm">SAS70</a> complaint system.</p>
<h4>Firewall</h4>
<p>Configure your firewall to allow only TCP access to, at least, only the following ports:</p>
<ul>
<li>TCP 80 HTTP</li>
<li>TCP 443 HTTPS</li>
<li>TCP 22 SSH</li>
<li>TCP 2222 SSH static</li>
</ul>
<p>If you don&#8217;t want to allow access to SSH from the outside, just open the HTTP and HTTPS ports, or allow SSH only to your trusted IPs. I&#8217;d also recommend to add a ny extra IPTables setup to avoid flood attacks, port scannings, etc.</p>
<h4>DenyHosts</h4>
<p>Id&#8217; recommend to install this simple but powerful HIPS service<acronym> that audits the ssh accesses and blocks IPs if a user tried to access incorrectly several times. Follow your distribution instructions to install it. In Ubuntu, it is easy:</acronym></p>
<p style="padding-left: 30px;"><code>$&gt; sudo apt-get install denyhosts</code></p>
<p>Configure it editing the file <code>/etc/denyhosts.conf</code></p>
<p>You can block all services:</p>
<p style="padding-left: 30px;"><code>BLOCK_SERVICE = ALL</code></p>
<p>&#8230;but also to add your internal network IPs to the white list file:<code></code></p>
<p style="padding-left: 30px;"><code>/var/lib/denyhosts/allowed-hosts</code></p>
<h4> accton</h4>
<p>This tool keeps a log of the commands executed in the server. Quite useful if you need to find clues after suffering a security event.<br />
<code></code></p>
<p style="padding-left: 30px;"><code>$&gt; apt-get install accton</code><br />
<code>$&gt; lastcomm</code></p>
<p>Next chapter : <a href="https://www.kus.es/2011/09/25/proof-of-concept-build-my-own-web-provider-at-home-ii-%e2%80%93-sshd/">the SSHD daemon setup!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2011/09/12/proof-of-concept-build-my-own-web-provider-at-home-i-the-idea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kactus Jack</title>
		<link>http://www.kus.es/2011/09/10/179/</link>
		<comments>http://www.kus.es/2011/09/10/179/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 09:43:50 +0000</pubDate>
		<dc:creator>Kus</dc:creator>
				<category><![CDATA[Ocio]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=179</guid>
		<description><![CDATA[Concierto Kactus Jack head crawl]]></description>
			<content:encoded><![CDATA[<p>Hace unos días me pasaron un enlace con unas fotos de cuando teníamos el pelo un poco más oscuro y la perilla algo más larga&#8230;<br />
Esta foto es de ~1996 en el Bar Zero en un concierto de <a href="http://www.youtube.com/watch?v=DlnOriMsjE4&amp;feature=player_detailpage#t=178s">Kactus Jack</a>, una banda ls bandas que marcaron mi juventud y que era nexo de unión para toda la panda, para la peña Kactus&#8230;</p>
<div id="attachment_180" class="wp-caption aligncenter" style="width: 685px"><a href="http://www.kus.es/wp-content/uploads/2011/09/kactus-zero-1.jpg"><img class="size-full wp-image-180" title="kactus-zero-kus" src="http://www.kus.es/wp-content/uploads/2011/09/kactus-zero-1.jpg" alt="" width="675" height="413" /></a><p class="wp-caption-text">Concierto de Kactus</p></div>
<p>Cada uno se ha ido, más o menos, por su lado y ahora ya nos vemos poco, pero estas fotos me siguen pareciendo la caña (¿Dónde estará esa camiseta que llevaba de Faith No More?)<br />
Por supuesto, la foto es propiedad de Luisa Colado.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2011/09/10/179/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WLST – Scripting para WebLogic vía bash (II)</title>
		<link>http://www.kus.es/2010/10/25/wlst-%e2%80%93-scripting-para-weblogic-via-bash-ii/</link>
		<comments>http://www.kus.es/2010/10/25/wlst-%e2%80%93-scripting-para-weblogic-via-bash-ii/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 13:25:32 +0000</pubDate>
		<dc:creator>Kus</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[WLST]]></category>

		<guid isPermaLink="false">https://www.kus.es/?p=118</guid>
		<description><![CDATA[Pues hace ya algunos días que habíamos dejado macerando en el artículo anterior el script de python getRunningserver.py que nos enseñaba la lista de instancias WebLogic que están corriendo (modo RUNNING). Vamos a ver ahora si podemos integrar este script en otro de bash, de forma que podamos fácilmente ejecutarlo desde la línea de comandos. Teníamos este comando para ejecutar nuestro script (ojo, acordáos que en en el artículo anterior [...]]]></description>
			<content:encoded><![CDATA[<p>Pues hace ya algunos días que habíamos dejado macerando en el <a href="https://www.kus.es/2010/09/06/wlst-scripting-para-weblogic-via-bash/" target="_self">artículo anterior</a> el script de python <em>getRunningserver.py</em> que nos enseñaba la lista de instancias WebLogic que están corriendo (modo <em>RUNNING</em>). Vamos a ver ahora si podemos integrar este script en otro de bash, de forma que podamos fácilmente ejecutarlo desde la línea de comandos.</p>
<p>Teníamos este comando para ejecutar nuestro script (ojo, acordáos que en en el artículo anterior habíamos definido una serie de variables de entorno!) :</p>
<pre>${JAVA_HOME}/bin/java -Dpython.cachedir=/tmp weblogic.WLST \
getRunningservers.py userconfig.properties userkey.properties \
t3://localhost:7001
</pre>
<p>Vale, la jugada ahora es integrar todos los requisitos que necesitamos para lanzar este script desde otro de bash, a saber:</p>
<ul>
<li>Cargar las variables de entorno de WebLogic vía  setDomainEnv,sh</li>
<li>Definir la JVM en caso de que queramos usar otra que la que usa WL</li>
<li>Definir los archivos de autorización de WLST</li>
<li>Definir la URL de administración de WL</li>
</ul>
<p>Vamos allá<br />
<span id="more-118"></span></p>
<h2>El archivo de configuración</h2>
<p>Crearemos un archivo de configuración para almacenar los datos propios del dominio con el que vamos a trabajar. De esta forma, sólo tendremos que modificar este archivo y no el de la lógica de proceso si queremos usarlo con otro sistema.</p>
<p>El archivo podría quedar así:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Descargar <a href="http://www.kus.es/wp-content/plugins/wp-codebox/wp-codebox.php?p=118&amp;download=getRunningservers.conf">getRunningservers.conf</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1189"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code" id="p118code9"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Configuracion  - getRunningServers</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Usuario UNIX que puede ejecutar el script</span>
<span style="color: #007800;">GOODUSER</span>=weblogic
&nbsp;
<span style="color: #666666; font-style: italic;">#nombre de Dominio de WebLogic</span>
<span style="color: #007800;">DOMAIN_NAME</span>=midominio
&nbsp;
<span style="color: #666666; font-style: italic;">#Directorio del dominio de Weblogic</span>
<span style="color: #007800;">DOMAIN_DIR</span>=<span style="color: #ff0000;">&quot;/home/weblogic/bea103/user_projects/domains/<span style="color: #007800;">${DOMAIN_NAME}</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Path del script para cargar las variables de entorno del dominio</span>
<span style="color: #007800;">WL_ENV_FILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${DOMAIN_DIR}</span>/bin/setDomainEnv.sh&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#URL de adminustracion</span>
<span style="color: #007800;">WL_ADMIN_URL</span>=<span style="color: #ff0000;">&quot;t3://127.0.0.1:7001&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Archivos de credenciales</span>
<span style="color: #007800;">userFile</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/scripts/userconfig.properties&quot;</span>
<span style="color: #007800;">userKey</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/scripts/userkey.properties&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Localización del script de python</span>
<span style="color: #007800;">getStuckThreadsScript</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HOME}</span>/scripts/getRunningServers.py&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Opciones de SSL para el WLST (depende de tu setup pueden variar, para este</span>
<span style="color: #666666; font-style: italic;">#ejemplo, no usamos SSL)</span>
<span style="color: #666666; font-style: italic;">#SSL_OPTS=&quot;-Dweblogic.security.SSL.trustedCAKeyStore=${DOMAIN_DIR}/trust.jks -Dweblogic.security.SSL.ignoreHostnameVerification=true&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Opciones para WLST (incluye las de SSL)</span>
<span style="color: #007800;">WLST_OPTS</span>=<span style="color: #ff0000;">&quot;-Dpython.cachedir=/tmp <span style="color: #007800;">${SSL_OPTS}</span>&quot;</span></pre></td></tr></table></div>

<p>Nada extraño, ¿verdad? Simplemente un archivo de configuración donde definiremos las variables específicas del dominio.</p>
<h2>El archivo de ejecución</h2>
<p>Bueno, ahora la cosa es crear un script de bash que amalgame todo lo anterior. Intentaremos hacerlo modular y añadirle algo de elegancia aplicando códigos de escape ANSI.</p>
<p><strong>Ojo:</strong>, este script, aunque funcional, carece de alguna funcionalidad bastante útil que más adelante añadiremos.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Descargar <a href="http://www.kus.es/wp-content/plugins/wp-codebox/wp-codebox.php?p=118&amp;download=getRunningservers.sh">getRunningservers.sh</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p11810"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
</pre></td><td class="code" id="p118code10"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Descripción</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Author: Carlos Carus - Kus - kus_at_kus.es</span>
<span style="color: #666666; font-style: italic;"># Name: getRunningServers.sh - borrador 1</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Descripcion:</span>
<span style="color: #666666; font-style: italic;"># Obtiene la lista de instancias activas de un dominio de WebLogic</span>
<span style="color: #666666; font-style: italic;"># No es definitivo, le faltan cosas ;-)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Listado de cambios</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># git+ssh://git-url</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 2010/09/28</span>
<span style="color: #666666; font-style: italic;"># VERSION 0.01 -</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #007800;">VERSION</span>=<span style="color: #000000;">0.01</span>
&nbsp;
<span style="color: #007800;">nombreScript</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">nombreConfig</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${DefaultMonitorName}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/\(.*\)\..*/\1/'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.conf
&nbsp;
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Función de Debug</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
showDebug<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;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${MYDEBUG}</span> == <span style="color: #ff0000;">&quot;Y&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">-e</span> <span style="color: #ff0000;">&quot;\e[1;33m[DEBUG]\e[0m $@&quot;</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;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Argumentos de entrada</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #007800;">vars</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #000000; font-weight: bold;">@`</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">z</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> option <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${vars[@]}</span>
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">z</span>=z+<span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #666666; font-style: italic;">#apuntamos al siguiente token</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${option}</span> == <span style="color: #ff0000;">&quot;-h&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${option}</span> == <span style="color: #ff0000;">&quot;--help&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${nombreScript}</span>: Obtiene la lista de instancias activas de un dominio de WebLogic&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Uso: <span style="color: #007800;">${nombreScript}</span> [OPTION]...&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Las variables pasadas como parámetro tienen preferencia sobre las del archivo de configuración<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span> -c, --config FILE:<span style="color: #000099; font-weight: bold;">\t</span>Archivo de configuración. Por defecto <span style="color: #007800;">${nombreConfig}</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span> -d, --debug:<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>Activa el modo debug&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span> -h, --help<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>Muestra esta ayuda&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${option}</span> == <span style="color: #ff0000;">&quot;-d&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${option}</span> == <span style="color: #ff0000;">&quot;--debug&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">MYDEBUG</span>=Y
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${option}</span> == <span style="color: #ff0000;">&quot;-c&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${option}</span> == <span style="color: #ff0000;">&quot;--conf&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">CONF</span>=<span style="color: #800000;">${vars[z]}</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Tenemos todo?</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${CONF}</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">CONF</span>=<span style="color: #800000;">${nombreConfig}</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: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$CONF</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">source</span> <span style="color: #800000;">${CONF}</span>
    showDebug <span style="color: #ff0000;">&quot;Main: cargado el archivo de configuracion <span style="color: #007800;">${CONF}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;El archvio de configuracion <span style="color: #007800;">${CONF}</span> no ha sido encontrado.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Use <span style="color: #007800;">$(basename $0)</span> --help para ver las opciones&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Variables genéricas</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Colores</span>
<span style="color: #007800;">RED</span>=<span style="color: #ff0000;">'\e[1;31m'</span>
<span style="color: #007800;">BLUE</span>=<span style="color: #ff0000;">'\e[1;34m'</span>
<span style="color: #007800;">CYAN</span>=<span style="color: #ff0000;">'\e[1;36m'</span>
<span style="color: #007800;">YELLOW</span>=<span style="color: #ff0000;">'\e[1;33m'</span>
<span style="color: #007800;">GREEN</span>=<span style="color: #ff0000;">'\e[0;32m'</span>
<span style="color: #007800;">NC</span>=<span style="color: #ff0000;">'\e[0m'</span>              <span style="color: #666666; font-style: italic;"># No Color</span>
<span style="color: #007800;">BOLD</span>=<span style="color: #ff0000;">'\e[1m'</span>
<span style="color: #007800;">UNDERLINE</span>=<span style="color: #ff0000;">'\e[4m'</span>
<span style="color: #007800;">BLINK</span>=<span style="color: #ff0000;">'\e[5m'</span>
<span style="color: #007800;">INVERSE</span>=<span style="color: #ff0000;">'\e[7m'</span>
<span style="color: #007800;">NF</span>=<span style="color: #ff0000;">'\e[m'</span>               <span style="color: #666666; font-style: italic;"># No format</span>
<span style="color: #007800;">RES_COL</span>=<span style="color: #000000;">70</span>
<span style="color: #007800;">RES_CO2</span>=<span style="color: #000000;">30</span>
<span style="color: #007800;">MOVE_TO_COL</span>=<span style="color: #ff0000;">&quot;\\033[<span style="color: #007800;">${RES_COL}</span>G&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Funciones</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
checkID<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;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${GOODUSER}</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #800000;">${LOGNAME}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</span>
    showDebug <span style="color: #ff0000;">&quot;checkID: Ejecutado como <span style="color: #007800;">${LOGNAME}</span>, esperando <span style="color: #007800;">${GOODUSER}</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[ERROR] Este script debe ser ejecutado como el usuario  <span style="color: #007800;">${GOODUSER}</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
compruebaCredenciales<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>
  showDebug <span style="color: #ff0000;">&quot;compruebaCredenciales: Comprobando <span style="color: #007800;">${userFile}</span> y <span style="color: #007800;">${userKey}</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${userFile}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${userKey}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${RED}</span>[ERROR]<span style="color: #007800;">${NF}</span> Los archivos de credenciales <span style="color: #007800;">${userFile}</span> o <span style="color: #007800;">${userKey}</span> no son accesibles&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
compruebaScriptPython<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>
  showDebug <span style="color: #ff0000;">&quot;compruebaScriptPython: Comprobando el script de python <span style="color: #007800;">${getStuckThreadsScript}</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${getStuckThreadsScript}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${RED}</span>[ERROR]<span style="color: #007800;">${NF}</span> El script <span style="color: #007800;">${getStuckThreadsScript}</span> no es accesible&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
cargaEntornoWLST<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>
    showDebug <span style="color: #ff0000;">&quot;cargaEntornoWLST: Cargando el entorno <span style="color: #007800;">${WL_ENV_FILE}</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #800000;">${WL_ENV_FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #800000;">${WL_ENV_FILE}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</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;">source</span> <span style="color: #800000;">${WL_ENV_FILE}</span>
        <span style="color: #666666; font-style: italic;">#JAVA_HOME es cargada por el script de WL</span>
        <span style="color: #007800;">JAVAWLST</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${JAVA_HOME}</span>/bin/java <span style="color: #007800;">${WLST_OPTS}</span> weblogic.WLST&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${RED}</span>[ERROR]<span style="color: #007800;">${NF}</span> El script de carga el entorno <span style="color: #007800;">${WL_ENV_FILE}</span> no es accesible o ejecutable&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
getRunningservers<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>
  showDebug <span style="color: #ff0000;">&quot;getRunningservers: Obteniendo la lista de instacias activas&quot;</span>
  <span style="color: #800000;">${JAVAWLST}</span> <span style="color: #800000;">${getStuckThreadsScript}</span> <span style="color: #800000;">${userFile}</span> <span style="color: #800000;">${userKey}</span> <span style="color: #800000;">${WL_ADMIN_URL}</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
<span style="color: #666666; font-style: italic;"># Lógica principal</span>
<span style="color: #666666; font-style: italic;">#------------------------------------------------------------------------------</span>
&nbsp;
checkID
compruebaCredenciales
compruebaScriptPython
cargaEntornoWLST
getRunningservers
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<h2>La ejecución</h2>
<p>Si lo ejecutamos con el modo de DEBUG activo (-d), nos saldría algo como esto:</p>
<pre>
weblogic@:scripts/&gt; ./getRunningServers.sh -d
[DEBUG] Main: cargado el archivo de configuracion getRunningServers.conf
[DEBUG] compruebaCredenciales: Comprobando /home/weblogic/scripts/userconfig.properties y /home/weblogic/scripts/userkey.properties
[DEBUG] compruebaScriptPython: Comprobando el script de python /home/weblogic/scripts/getRunningServers.py
[DEBUG] cargaEntornoWLST: Cargando el entorno /home/weblogic/bea103/user_projects/domains/midominio/bin/setDomainEnv.sh
[DEBUG] getRunningservers: Obteniendo la lista de instacias activas

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to http://localhost:7001 with userid admin_user ...
Successfully connected to Admin Server 'admin' that belongs to domain 'midominio'.

Location changed to serverRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainConfig)

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)

[INFO] The server admin is running
[INFO] The server server1 is running
Disconnected from weblogic server: admin
weblogic:~/scripts&gt;
</pre>
<p>Vale, parece que funciona, pero para hacerlo más bonito o &#8220;reusable&#8221;, habría que evitar que salga por pantalla todo esa literatura que los scripts de WLST generan al arranque. No será nada complicado, pero eso lo veremos en el siguiente artículo, donde cambiaremos el script de python para que no genere tanta verborrea y haremos que nuestro script en bash recoga toda esa salida y la &#8220;parsee&#8221; tal y como queramos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2010/10/25/wlst-%e2%80%93-scripting-para-weblogic-via-bash-ii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Las boyas</title>
		<link>http://www.kus.es/2010/09/07/las-boyas/</link>
		<comments>http://www.kus.es/2010/09/07/las-boyas/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 11:06:05 +0000</pubDate>
		<dc:creator>nacho</dc:creator>
				<category><![CDATA[Náutica]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=94</guid>
		<description><![CDATA[Las boyas y su significado están muy bien explicadas en la WikiPedia. Un tipo especial de boyas son las usadas por la IALA (International Association of Lighthouse Authorities) ó AISM (Asociación Internacional de Señalización Marítima). La Wikipedia también cuenta con un excelente artículo en español sobre ellas, que serían las señales de tráfico del mar.]]></description>
			<content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 527px"><img title="Boya Cardinal Oeste (wikipedia)" src="http://upload.wikimedia.org/wikipedia/commons/1/1b/BoyaPartes.PNG" alt="Boya Cardinal" width="517" height="540" /><p class="wp-caption-text">Boya Cardinal Oeste (wikipedia)</p></div>
<p>Las boyas y su significado están muy bien explicadas en la <a href="http://es.wikipedia.org/wiki/Sistema_de_boyado_mar%C3%ADtimo_IALA#Se.C3.B1ales_cardinales">WikiPedia</a>. </p>
<p>Un tipo especial de boyas son las usadas por la IALA (<strong>I</strong>nternational <strong>A</strong>ssociation of <strong>L</strong>ighthouse <strong>A</strong>uthorities) ó AISM (<strong>A</strong>sociación <strong>I</strong>nternacional de <strong>S</strong>eñalización <strong>M</strong>arítima). La <a href="http://es.wikipedia.org/wiki/Sistema_de_boyado_mar%C3%ADtimo_IALA">Wikipedia</a> también cuenta con un excelente artículo en español sobre ellas, que serían las señales de tráfico del mar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2010/09/07/las-boyas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Las cartas náuticas</title>
		<link>http://www.kus.es/2010/09/07/las-cartas-nauticas/</link>
		<comments>http://www.kus.es/2010/09/07/las-cartas-nauticas/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 10:57:27 +0000</pubDate>
		<dc:creator>nacho</dc:creator>
				<category><![CDATA[Náutica]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=88</guid>
		<description><![CDATA[La española de exámen, el estrecho de Gibraltar: Y en Francia es muy típica la bahía de Quiberon:]]></description>
			<content:encoded><![CDATA[<p>La española de exámen, el estrecho de Gibraltar:</p>
<p><img class="aligncenter" title="Gibraltar" src="http://www.clubdelamar.org/Estrecho%20con%20Vicente.jpg" alt="Gibraltar" width="645" height="466" /></p>
<p>Y en Francia es muy típica la bahía de Quiberon:</p>
<p><img class="aligncenter" title="Quiberon" src="http://nautisme-quiberon.com/shom.jpg" alt="Quiberon" width="697" height="377" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2010/09/07/las-cartas-nauticas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Los transportadores náuticos</title>
		<link>http://www.kus.es/2010/09/07/los-transportadores-nauticos/</link>
		<comments>http://www.kus.es/2010/09/07/los-transportadores-nauticos/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 10:38:48 +0000</pubDate>
		<dc:creator>nacho</dc:creator>
				<category><![CDATA[Náutica]]></category>
		<category><![CDATA[transportador angulo]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=84</guid>
		<description><![CDATA[El español que conocemos: Este es el inglés: Y éste es el francés: Y aquí hay varios modelos.]]></description>
			<content:encoded><![CDATA[<p>El español que conocemos:<br />
<img class="aligncenter" title="trans_es" src="http://www.libreriadenautica.com/portadas/MTC-10.jpg" alt="Transportador español" width="224" height="227" /></p>
<p>Este es el inglés:</p>
<div id="attachment_85" class="wp-caption aligncenter" style="width: 528px"><a href="http://www.kus.es/wp-content/uploads/2010/09/ScrShot501.jpg"><img class="size-full wp-image-85" title="trans_en" src="http://www.kus.es/wp-content/uploads/2010/09/ScrShot501.jpg" alt="" width="518" height="180" /></a><p class="wp-caption-text">Transportador inglés</p></div>
<p>Y éste es el francés:<br />
<img class="aligncenter" title="trans_fr" src="http://cpagranville.net/imgs/CMS/1237385281.jpg" alt="Transportador francés" width="400" height="286" /></p>
<p>Y <a href="http://www.topoplastic.com/listeproduits.php?SSCAT=14">aquí hay varios modelos</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2010/09/07/los-transportadores-nauticos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Y la regata &#8220;Le Figaro&#8221; volvió a Gijón 6 años después..</title>
		<link>http://www.kus.es/2010/09/07/y-la-regata-le-figaro-volvio-a-gijon-6-anos-despues/</link>
		<comments>http://www.kus.es/2010/09/07/y-la-regata-le-figaro-volvio-a-gijon-6-anos-despues/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 10:16:26 +0000</pubDate>
		<dc:creator>nacho</dc:creator>
				<category><![CDATA[Náutica]]></category>
		<category><![CDATA[figaro gijon]]></category>

		<guid isPermaLink="false">http://www.kus.es/?p=82</guid>
		<description><![CDATA[Años después una de las más famosas Regatas del mundo vuelve a apostar por Gijón como uno de os puntos de atraque (la primera etapa será entre Le Habre y Gijón). Uno de los elementos más bonitos de Le Figaro es que es una regata para navegantes en solitario. En esta ocación 48 navegantes participarán el ella. Referencias: http://www.absolutgijon.com/le-figaro-vuelve-a-gijon/ http://www.elmundo.es/elmundo/2010/06/10/nautica/1276185693.html http://www.elmundo.es/elmundo/2010/07/31/nautica/1280599996.html http://www.elperiodiconautico.com/?p=33086]]></description>
			<content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 460px"><img title="Recorrido de Le Figaro" src="http://blog.gruponavega.eu/wp-content/uploads/recorridos-le-solitaire-du-figarojpg.jpeg" alt="Recorrido de Le Figaro" width="450" height="633" /><p class="wp-caption-text">Recorrido de Le Figaro</p></div>
<p>Años después una de las más famosas Regatas del mundo <a href="http://www.absolutgijon.com/le-figaro-vuelve-a-gijon/">vuelve </a>a apostar por Gijón como uno de os puntos de atraque (la primera etapa será entre <a id="aptureLink_gMDpUbrUhG" href="http://maps.google.com/maps?om=0&amp;iwloc=addr&amp;f=q&amp;ll=49.4925909%2C0.1065027&amp;hl=en&amp;z=11&amp;ie=UTF8">Le Habre</a> y <a id="aptureLink_ZkNasbjspa" href="http://maps.google.com/maps?om=0&amp;iwloc=addr&amp;f=q&amp;ll=43.5452608%2C-5.6619264&amp;hl=en&amp;z=11&amp;ie=UTF8">Gijón</a>). Uno de los elementos más bonitos de Le Figaro es que es una regata para navegantes en solitario. En esta ocación 48 navegantes participarán el ella.</p>
<p>Referencias:<br />
<a href="http://www.lefigaro.fr/"></a><a href="http://www.absolutgijon.com/le-figaro-vuelve-a-gijon/">http://www.absolutgijon.com/le-figaro-vuelve-a-gijon/</a><br />
<a href="http://www.elmundo.es/elmundo/2010/06/10/nautica/1276185693.html">http://www.elmundo.es/elmundo/2010/06/10/nautica/1276185693.html</a><br />
<a href="http://www.elmundo.es/elmundo/2010/07/31/nautica/1280599996.html">http://www.elmundo.es/elmundo/2010/07/31/nautica/1280599996.html</a><br />
<a href="http://www.elperiodiconautico.com/?p=33086">http://www.elperiodiconautico.com/?p=33086</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kus.es/2010/09/07/y-la-regata-le-figaro-volvio-a-gijon-6-anos-despues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

