<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Megalomaniacal - howto tag</title>
  <link>http://www.megalomaniacal.net/tags/howto/</link>
  <description>Better than the best and harder than the rest.</description>
  <language>en</language>
  <copyright>drogoh</copyright>
  <lastBuildDate>Mon, 14 Jul 2008 21:26:34 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>SCSI bus rescan</title>
    <link>http://www.megalomaniacal.net/2007/10/16/1192570674686.html</link>
    
      
        <description>
          Here&#039;s a good one that I had to deal with recently.&amp;nbsp; Two drives being removed and one going in its place.&amp;nbsp; The kicker is that they wanted zero downtime.&amp;nbsp; Cool, except there&#039;s no RAID and it&#039;s just a bunch of drives in the box.&amp;nbsp; Here&#039;s what I wound up following in order to re-read the new drive and flush out the old data:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################### TO REMOVE DRIVE&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;scsi remove-single-device 0 1 2 3&amp;quot; &amp;gt; /proc/scsi/scsi&lt;br /&gt;
(replace &amp;quot;0 1 2 3&amp;quot; with your &amp;quot;Host Channel Id Lun&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- for us:&lt;br /&gt;
(SU-recover1)/var/log&amp;gt;cat /proc/scsi/scsi&lt;br /&gt;
Attached devices:&lt;br /&gt;
Host: scsi0 Channel: 00 Id: 00 Lun: 00&lt;br /&gt;
Vendor: FUJITSU Model: MAS3184NC Rev: 5B08&lt;br /&gt;
Type: Direct-Access ANSI SCSI revision: 03&lt;br /&gt;
Host: scsi0 Channel: 00 Id: 03 Lun: 00&lt;br /&gt;
Vendor: SEAGATE Model: ST336753LC Rev: 0006&lt;br /&gt;
Type: Direct-Access ANSI SCSI revision: 03&lt;br /&gt;
Host: scsi0 Channel: 00 Id: 05 Lun: 00&lt;br /&gt;
Vendor: SEAGATE Model: ST336753LC Rev: 0006&lt;br /&gt;
Type: Direct-Access ANSI SCSI revision: 03&lt;br /&gt;
Host: scsi0 Channel: 00 Id: 06 Lun: 00&lt;br /&gt;
Vendor: PE/PV Model: 1x6 SCSI BP Rev: 1.1&lt;br /&gt;
Type: Processor ANSI SCSI revision: 02&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- want to remove the first seagate, after disabling in slot&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;scsi remove-single-device 0 0 3 0&amp;quot; &amp;gt; /proc/scsi/scsi&lt;br /&gt;
&lt;br /&gt;
############## TO RESTART&lt;br /&gt;
After you replace the drive and restart it&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;scsi add-single-device 0 1 2 3&amp;quot; &amp;gt; /proc/scsi/scsi&lt;br /&gt;
&lt;br /&gt;
It&#039;s rather straightforward for the technically minded folks.&amp;nbsp; Shame it requires echoing crap to /proc, since there be dragons in /proc
        </description>
      
      
    
    
    
    <comments>http://www.megalomaniacal.net/2007/10/16/1192570674686.html#comments</comments>
    <guid isPermaLink="true">http://www.megalomaniacal.net/2007/10/16/1192570674686.html</guid>
    <pubDate>Tue, 16 Oct 2007 21:37:54 GMT</pubDate>
  </item>
  
  <item>
    <title>DomainKeys for Postfix on Red Hat ES 4</title>
    <link>http://www.megalomaniacal.net/2007/10/16/1192570009033.html</link>
    
      
        <description>
          *** Note: This is only tested on RHEL4.&amp;nbsp; RHEL5 has a newer version out of the box.&amp;nbsp; RHEL3 might require some touching in the wrong places.&lt;br /&gt;
&lt;br /&gt;
* Requires Postfix 2.3 and above for milter support&lt;br /&gt;
* http://www.postfix.org/MILTER_README.html&lt;br /&gt;
* http://sourceforge.net/projects/dk-milter&lt;br /&gt;
* http://postfix.wl0.org/en/&lt;br /&gt;
&lt;br /&gt;
Quick &amp;amp; dirty steps (developed on RHEL4):&lt;br /&gt;
&lt;br /&gt;
1. Upgrade Postfix using SRPM from postfix.wl0.org since you want SASL auth enabled&lt;br /&gt;
&lt;br /&gt;
2. Configure Postfix to acknowledge the milter in main.cf:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; smtpd_milters = inet:localhost:4442&lt;br /&gt;
&lt;br /&gt;
3. Fetch and compile dk-milter from source, don&#039;t worry about RPMing this.&lt;br /&gt;
&lt;br /&gt;
4. Generate a private/public key pair using OpenSSL:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openssl genrsa -out private.key 1024&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; openssl rsa -in private.key -pubout -out public.key&lt;br /&gt;
&amp;nbsp;&amp;nbsp; Pick a selector name: ie. selector1&lt;br /&gt;
&amp;nbsp;&amp;nbsp; Add the public-key data in DNS for the domain using the selector name you picked. Take the contents of the public.key file and remove the PEM header and footer, and concatenate the lines of the file into one big line. Then create a TXT entry, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selector1._domainkey IN TXT &amp;quot;k=rsa; p=MHwwDQYJK ... OprwIDAQAB; t=y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where selector1 is the name of the selector chosen and the p= parameter contains the public-key as one long string of characters.&lt;br /&gt;
&lt;br /&gt;
5.&amp;nbsp; Start dk-milter.&amp;nbsp; I set up a user &#039;dkfilter&#039; so it doesn&#039;t run as root and also set a pid file.&amp;nbsp; I also used an init script found via Google, which works great for Red Hat systems.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # dk-filter -u dkfilter -b s -p inet:4442@localhost -l -P /var/run/dk-milter/pid -s /etc/postfix/dk-milter/private.key -d mydomain.com -S selector1 -m smtp -c nofws&lt;br /&gt;
&lt;br /&gt;
**** Note - -m needs to be -m smtp so that dk-filter signs mail going out over smtp.&amp;nbsp; It will not sign messages otherwise.&lt;br /&gt;
&lt;br /&gt;
init script:&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# &amp;quot;/etc/rc.d/init.d/dk-filter&amp;quot;&lt;br /&gt;
# Start/stop script for the dk-filter daemon on RedHat Linux&lt;br /&gt;
#&lt;br /&gt;
# chkconfig: - 79 31&lt;br /&gt;
# description: Acts as the &amp;quot;dk-filter&amp;quot; InputMailFilter (milter) for the \&lt;br /&gt;
# Sendmail MTA to provide DomainKeys service&lt;br /&gt;
&lt;br /&gt;
########################################################################&lt;br /&gt;
#&lt;br /&gt;
# Be sure to edit these values:&lt;br /&gt;
#&lt;br /&gt;
KEYFILE=&amp;quot;/etc/postfix/dk-milter/private.key&amp;quot;&lt;br /&gt;
DOMAIN=&amp;quot;mydomain.com&amp;quot;&lt;br /&gt;
SELECTOR=&amp;quot;selector1&amp;quot;&lt;br /&gt;
USER=&amp;quot;dkfilter&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
########################################################################&lt;br /&gt;
&lt;br /&gt;
PIDFILE=&amp;quot;/var/run/dk-milter/pid&amp;quot;&lt;br /&gt;
SUBMISSION_DAEMON=&amp;quot;smtp&amp;quot;&lt;br /&gt;
PORT=4442&lt;br /&gt;
&lt;br /&gt;
# Source function library. Provides the &amp;quot;status&amp;quot; option&lt;br /&gt;
. /etc/init.d/functions&lt;br /&gt;
&lt;br /&gt;
test -x `which dk-filter` || exit 0&lt;br /&gt;
&lt;br /&gt;
RETVAL=0&lt;br /&gt;
&lt;br /&gt;
start() {&lt;br /&gt;
echo -n $&amp;quot;Starting dk-filter: &amp;quot;&lt;br /&gt;
COMMAND=&amp;quot;dk-filter -u $USER -b s -p inet:$PORT@localhost -l -P $PIDFILE -s $KEYFILE -d $DOMAIN -S $SELECTOR -m $SUBMISSION_DAEMON -c nofws&amp;quot;&lt;br /&gt;
# echo -e &amp;quot;Now executing\n&amp;quot;$COMMAND&amp;quot;&amp;quot;&lt;br /&gt;
daemon $COMMAND&lt;br /&gt;
RETVAL=$?&lt;br /&gt;
echo&lt;br /&gt;
[ $RETVAL -eq 0 ] &amp;amp;&amp;amp; touch /var/lock/subsys/dk-filter&lt;br /&gt;
return $RETVAL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
stop() {&lt;br /&gt;
echo -n $&amp;quot;Stopping dk-filter: &amp;quot;&lt;br /&gt;
killproc dk-filter&lt;br /&gt;
RETVAL=$?&lt;br /&gt;
echo&lt;br /&gt;
[ $RETVAL -eq 0 ] &amp;amp;&amp;amp; rm -f $PIDFILE /var/lock/subsys/dk-filter&lt;br /&gt;
return $RETVAL&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
restart() {&lt;br /&gt;
stop&lt;br /&gt;
start&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;$1&amp;quot; in&lt;br /&gt;
start)&lt;br /&gt;
start&lt;br /&gt;
;;&lt;br /&gt;
stop)&lt;br /&gt;
stop&lt;br /&gt;
;;&lt;br /&gt;
status)&lt;br /&gt;
status dk-filter&lt;br /&gt;
;;&lt;br /&gt;
restart)&lt;br /&gt;
restart&lt;br /&gt;
;;&lt;br /&gt;
*)&lt;br /&gt;
echo $&amp;quot;Usage: $0 {start|stop|status|restart}&amp;quot;&lt;br /&gt;
exit 1&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
exit $?
        </description>
      
      
    
    
    
    <comments>http://www.megalomaniacal.net/2007/10/16/1192570009033.html#comments</comments>
    <guid isPermaLink="true">http://www.megalomaniacal.net/2007/10/16/1192570009033.html</guid>
    <pubDate>Tue, 16 Oct 2007 21:26:49 GMT</pubDate>
  </item>
  
  </channel>
</rss>
