<?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>jason schaefer</title>
	<atom:link href="http://jasonschaefer.com/feed" rel="self" type="application/rss+xml" />
	<link>http://jasonschaefer.com</link>
	<description>documentation and stuff :(){ :&#124;:&#38; };:</description>
	<lastBuildDate>Fri, 11 May 2012 20:16:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>* Backup Scripts in bash and batch</title>
		<link>http://jasonschaefer.com/archives/448?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=backup-scripts-in-bash-and-batch</link>
		<comments>http://jasonschaefer.com/archives/448#comments</comments>
		<pubDate>Tue, 06 Dec 2011 20:40:38 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[blat]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[jsbk]]></category>
		<category><![CDATA[pg_dump]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[stunnel]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=448</guid>
		<description><![CDATA[Here is a bash script that I use to do simple and transparent backups of all sorts of data. I use it primarily to backup to multiple external hard drives, plugged in via USB. It uses regular mount or gnome volume manager. It also sends logs via email using &#8220;mail&#8221; and a local MTA like <a href='http://jasonschaefer.com/archives/448' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Here is a bash script that I use to do simple and transparent backups of all sorts of data.<br />
I use it primarily to backup to multiple external hard drives, plugged in via USB. It uses regular mount or gnome volume manager. It also sends logs via email using &#8220;mail&#8221; and a local MTA like postfix. Please modify to fit your needs. Leave a comment if you want. Its also here http://jasonschaefer.com/stuff/jsbk.sh.txt</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">##jsbk.sh 12-07-11</span>
<span style="color: #666666; font-style: italic;">##email: jason [at] schaeferconsulting [dot] com</span>
<span style="color: #666666; font-style: italic;">##505.570.1114</span>
&nbsp;
<span style="color: #666666; font-style: italic;">########################## USER EDIT BEGINS #############################</span>
<span style="color: #666666; font-style: italic;">## Email to, comma separated list for multiple recipients. host needs to be able to relay local mail. postfix recommended.</span>
<span style="color: #007800;">to</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #666666; font-style: italic;">## Set &quot;yes&quot; to rely on gnome volume manager (/media/[drivename]). Set to &quot;no&quot; for manual mount/umount (requires root priv. and will mount to /mnt)</span>
<span style="color: #007800;">automount</span>=<span style="color: #ff0000;">&quot;yes&quot;</span>
<span style="color: #666666; font-style: italic;">## Name of drive. If you have multiple backup drives, they should be named the same.</span>
<span style="color: #007800;">drivename</span>=<span style="color: #ff0000;">&quot;mybackupdrive&quot;</span>
<span style="color: #666666; font-style: italic;">## Name of directory to write backups in. Leave blank to write to the root of backup drive.</span>
<span style="color: #007800;">bkdir</span>=<span style="color: #ff0000;">&quot;mybackups&quot;</span>
<span style="color: #666666; font-style: italic;">## Cleanup backup files when drive reaches this percent</span>
<span style="color: #007800;">cleanafter</span>=<span style="color: #ff0000;">&quot;99&quot;</span> <span style="color: #666666; font-style: italic;">#percent</span>
<span style="color: #666666; font-style: italic;">## When backup is full, delete how many days of backups?</span>
<span style="color: #007800;">deletedaysold</span>=<span style="color: #ff0000;">&quot;30&quot;</span> <span style="color: #666666; font-style: italic;">#days</span>
<span style="color: #666666; font-style: italic;">## If you are in need of assistance, please contact [the following string]</span>
<span style="color: #007800;">support</span>=<span style="color: #ff0000;">&quot;Schaefer Consulting at 505.570.1114&quot;</span>
<span style="color: #666666; font-style: italic;">## To bypass the backup commands, for debug purposes. yes/no</span>
<span style="color: #007800;">bypassbk</span>=<span style="color: #ff0000;">&quot;no&quot;</span>
backup_commands <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: #666666; font-style: italic;">########################## START BACKUP COMMANDS ########################</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Running backup commands now...&quot;</span>   <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #666666; font-style: italic;">## Enter backup line's here i.e., cp, ssh, rsync ####</span>
<span style="color: #666666; font-style: italic;">## append &quot;||check&quot; to the end of the command to verify if the command ran successfully</span>
<span style="color: #666666; font-style: italic;">## exmpl:    /bin/tar zcvf $bklocation/`date +%F`.tar.gz --exclude media/* /home ||check 2&gt;&gt; $log</span>
<span style="color: #666666; font-style: italic;">## exmpl:    /bin/cp -rvu /home/ $bklocation/new-n-changed ||check 2&gt;&gt; $log</span>
<span style="color: #666666; font-style: italic;">## exmpl:    /usr/bin/rsync -av --delete --stats --exclude media/* /home/ $bklocation/rsync-mirror ||check 2&gt;&gt; $log</span>
<span style="color: #666666; font-style: italic;">## exmpl:    /usr/bin/pg_dump -Z 9 -p 5432 -h hostname -U username dbname &gt; $bklocation/dbname_`date +%F_%T`.sqldump.gz ||check 2&gt;&gt; $log</span>
<span style="color: #666666; font-style: italic;">##			         postgres auth uses ~/.pgpass containing localhost:5432:db:dbuser:dbpass</span>
<span style="color: #666666; font-style: italic;">## BACKUP over SMB</span>
<span style="color: #666666; font-style: italic;">## exmpl:		 cd $bklocation/backup-destination &amp;&amp; /usr/bin/smbget -URq smb://user:password@hostname/share 2&gt;&gt; $log</span>
&nbsp;
<span style="color: #666666; font-style: italic;">########################### END BACKUP COMMANDS #########################</span>
<span style="color: #666666; font-style: italic;">########################### USER EDIT ENDS ##############################</span>
<span style="color: #666666; font-style: italic;">########################### CRON REFERENCE ##############################</span>
<span style="color: #666666; font-style: italic;">## setup to run on a schedule with cron</span>
<span style="color: #666666; font-style: italic;">## minutes (0-59) | hours (0-23) | day of month (1-31) | month (1-12) | day of week (0-6 or Sun-Sat 0,6) | command</span>
<span style="color: #666666; font-style: italic;">## 0 2 * * * /usr/local/bin/jsbk.sh</span>
<span style="color: #666666; font-style: italic;">## will run at 2:00am every day</span>
<span style="color: #666666; font-style: italic;">## 0 2 1,15 * * /usr/local/bin/jsbk.sh</span>
<span style="color: #666666; font-style: italic;">## will run at 2:00am 1st and 15th of the month</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#if you want to see the log on your screen, use log=&quot;/dev/stdout&quot; instead</span>
<span style="color: #007800;">log</span>=<span style="color: #ff0000;">&quot;/tmp/jsbk.backup.log&quot;</span>
<span style="color: #666666; font-style: italic;">#log=&quot;/dev/stdout&quot;</span>
<span style="color: #007800;">subject</span>=<span style="color: #ff0000;">&quot;Backup Log from <span style="color: #780078;">`hostname`</span>&quot;</span>
<span style="color: #666666; font-style: italic;">#mountpoint, for easy reference later</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> = <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">mp</span>=<span style="color: #ff0000;">&quot;/media/<span style="color: #007800;">$drivename</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #007800;">mp</span>=<span style="color: #ff0000;">&quot;/mnt&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #666666; font-style: italic;">#mount point plus backup dir, for easy reference in backup commands</span>
<span style="color: #007800;">bklocation</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$mp</span>/<span style="color: #007800;">$bkdir</span>&quot;</span>
<span style="color: #666666; font-style: italic;">#determine percent that drive is full</span>
<span style="color: #007800;">percentfull</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$mp</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5}'</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s:%::g'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">starttime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">trap</span> caughtsig <span style="color: #000000;">1</span> <span style="color: #000000;">2</span> <span style="color: #000000;">3</span> <span style="color: #000000;">6</span>
caughtsig <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: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;******************** Caught INTERUPT SIG 1,2,3, or 6. **********************&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">#check if backup is still running or exited without cleanup.</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$log</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: #ff0000;">&quot;log (<span style="color: #007800;">$log</span>) exists, this indicates that $0 may be running or exited uncleanly. verify with ps aux |grep $0 and if not running, delete <span style="color: #007800;">$log</span>.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  error
  emailend
<span style="color: #000000; font-weight: bold;">fi</span>
check <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: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: A command FAILED!&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #007800;">failed</span>=<span style="color: #ff0000;">&quot;failed&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
error <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: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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><span style="color: #000099; font-weight: bold;">\t</span> * Backup is NOT working!&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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><span style="color: #000099; font-weight: bold;">\t</span> * Contact technician for service.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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><span style="color: #000099; font-weight: bold;">\t</span> * Keep this message for diagnoses&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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><span style="color: #000099; font-weight: bold;">\t</span> * Backup Failed on <span style="color: #780078;">`date +%c`</span>&quot;</span>   <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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> Diagnoses:&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #666666; font-style: italic;">#mount &gt;&gt; $log 2&gt;&amp;1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> Mount Point: <span style="color: #007800;">$mp</span>   <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
emailend <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: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #666666; font-style: italic;">#calculate running time of backup</span>
  <span style="color: #007800;">endtime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #007800;">elapsed</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$endtime</span> - <span style="color: #007800;">$starttime</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;Running time: &quot;</span><span style="color: #000000; font-weight: bold;">%</span><span style="color: #c20cb9; font-weight: bold;">dh</span>:<span style="color: #000000; font-weight: bold;">%</span>dm:<span style="color: #000000; font-weight: bold;">%</span>ds<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$elapsed</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3600</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$elapsed</span><span style="color: #000000; font-weight: bold;">%</span>3600<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$elapsed</span><span style="color: #000000; font-weight: bold;">%</span>60<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;---&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;If you are in need of assistance, please contact <span style="color: #007800;">$support</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> = no <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #007800;">$mp</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Error: Removing hard drive failed<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Emailing logs...&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$to</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">then</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;">cat</span> <span style="color: #007800;">$log</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mail <span style="color: #660033;">-v</span> <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$subject</span>&quot;</span> <span style="color: #007800;">$to</span>
    <span style="color: #000000; font-weight: bold;">else</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;">mv</span> <span style="color: #007800;">$log</span> <span style="color: #007800;">$log</span><span style="color: #000000; font-weight: bold;">/</span>last.log
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #c20cb9; font-weight: bold;">yes</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= no <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> ERROR: <span style="color: #007800;">automount</span>=<span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #007800;">$automount</span><span style="color: #000000; font-weight: bold;">\&quot;</span> is not valid. choose <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">yes</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> or <span style="color: #7a0874; font-weight: bold;">&#91;</span>no<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> error <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> emailend
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$drivename</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> ERROR: drivename is not declared <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> error <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> emailend
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$bkdir</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> fyi, bkdir is not declared
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$support</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> fyi, support string is empty
<span style="color: #666666; font-style: italic;">#begin</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;BACKUP LOG&quot;</span>   <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;server: <span style="color: #780078;">`hostname`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;Backup BEGAN on <span style="color: #780078;">`date +%c`</span> <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>   <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$mp</span>&quot;</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: #ff0000;">&quot;Mount point <span style="color: #007800;">$mp</span> does not exist!&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> = <span style="color: #ff0000;">&quot;yes&quot;</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: #ff0000;">&quot;be sure drivename=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$drivename</span><span style="color: #000099; font-weight: bold;">\&quot;</span> is correct and gnome volume mounting is working. Or switch to automount=<span style="color: #000099; font-weight: bold;">\&quot;</span>no<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> = <span style="color: #ff0000;">&quot;no&quot;</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: #ff0000;">&quot;check that <span style="color: #007800;">$mp</span> exists&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>; <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Also, be sure the drive is plugged in or turned on.&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
error
emailend
<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: #ff0000;">&quot;<span style="color: #007800;">$automount</span>&quot;</span> = <span style="color: #ff0000;">&quot;no&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #666666; font-style: italic;">#mount drive manually at /mnt</span>
  <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-L</span> <span style="color: #007800;">$drivename</span> <span style="color: #007800;">$mp</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ERROR: mounting hard drive failed. Be sure drivename=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\&quot;</span> is correct and drive is plugged in or turned on.&quot;</span>;error;emailend;<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</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;">\n</span> +++ START LOG +++ <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>bklocation= <span style="color: #007800;">$bklocation</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$bklocation</span>&quot;</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: #007800;">bklocation</span>=<span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #007800;">$bklocation</span><span style="color: #000000; font-weight: bold;">\&quot;</span> exists, moving on
  <span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">bklocation</span>=<span style="color: #000000; font-weight: bold;">\&quot;</span><span style="color: #007800;">$bklocation</span><span style="color: #000000; font-weight: bold;">\&quot;</span> is not a directory. stripping bkdir, will <span style="color: #c20cb9; font-weight: bold;">write</span> files to root of <span style="color: #007800;">$mp</span>
  <span style="color: #007800;">bkdir</span>=<span style="color: #ff0000;">&quot;&quot;</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: #ff0000;">&quot;<span style="color: #007800;">$bypassbk</span>&quot;</span> = <span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$bklocation</span><span style="color: #000000; font-weight: bold;">/</span>bypassbk.test
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Bypassing all backup commands for debug purposes&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  emailend
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #666666; font-style: italic;">#determine percent that drive is full</span>
<span style="color: #007800;">percentfull</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$mp</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $5}'</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s:%::g'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Checking if drive has reached <span style="color: #007800;">$cleanafter</span>% full&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$percentfull</span> <span style="color: #660033;">-gt</span> <span style="color: #007800;">$cleanafter</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: #ff0000;">&quot;Drive has exceeded <span style="color: #007800;">$cleanafter</span>% and all backups older than <span style="color: #007800;">$deletedaysold</span> will be deleted&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #007800;">$bklocation</span><span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #660033;">-mtime</span> +<span style="color: #007800;">$deletedaysold</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-fr</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;  <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;backup drive storage has not exceeded <span style="color: #007800;">$cleanafter</span>%, proceeding as usual. Drive currently has <span style="color: #007800;">$percentfull</span>% used&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #666666; font-style: italic;">#user backup commands function</span>
  backup_commands
<span style="color: #000000; font-weight: bold;">fi</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;">\n</span> +++ END LOG +++ <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #666666; font-style: italic;">#check to see if $failed equals zero, if it is then all commands were successfull. If not, something failed.</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$failed</span>&quot;</span> = failed <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: #ff0000;">&quot;ERROR: A problem was detected!&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  error
  emailend
<span style="color: #000000; font-weight: bold;">else</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> SUCCESS: Backup Complete!&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</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><span style="color: #000099; font-weight: bold;">\t</span> &quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$log</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
  emailend
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Here is my batch script I use for MS Windows boxen. Batch scripting is nasty but surprisingly this script has come in handy many a time. Here is a direct link http://jasonschaefer.com/stuff/jsbkwin.bat.txt</p>

<div class="wp_syntax"><div class="code"><pre class="winbatch" style="font-family:monospace;"><span style="color: #66cc66;">@</span>echo <span style="color: #0080FF; font-weight: bold;">off</span>
echo jsbkwin <span style="color: #cc66cc;">12</span><span style="color: #66cc66;">-</span>07<span style="color: #66cc66;">-</span><span style="color: #cc66cc;">11</span>
<span style="color: #FF1010; font-weight: bold;">:: INSTRUCTIONS:</span>
<span style="color: #FF1010; font-weight: bold;">:: Save this file to it. Remove the .txt from the name.</span>
<span style="color: #FF1010; font-weight: bold;">:: Download blat http://www.blat.net/ and copy the 3 files (blat.exe, blat.dll, blat.lib) into c:\winnt or c:\windows</span>
<span style="color: #FF1010; font-weight: bold;">:: Ideally, blat will just send the mail. But more and more ISP's are blocking this. You can request that your ISP allow smtp or send on another port or use a remote mail server.</span>
<span style="color: #FF1010; font-weight: bold;">:: Use http://www.stunnel.org/ to make secure (tls) connections for sending mail. See example stunnel.conf at bottom</span>
<span style="color: #FF1010; font-weight: bold;">:: Also, http://www.cygwin.com/ for rsync, ssh and unix2dos on windows.</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">:: Edit file according to your needs and run.</span>
<span style="color: #FF1010; font-weight: bold;">:: This can be run automatically with &quot;at&quot; or &quot;scheduled tasks&quot;,</span>
<span style="color: #FF1010; font-weight: bold;">:: You can uncomment the pause's for debugging.</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">::uncomment options as needed (connecting to outside MTA, for example)</span>
set <span style="color: #800080;">to</span>=<span style="color: #ff0000;">&quot;&quot;</span>
set from=<span style="color: #ff0000;">&quot;&quot;</span>
set smtp_server=<span style="color: #ff0000;">&quot;127.0.0.1&quot;</span>
<span style="color: #FF1010; font-weight: bold;">::set smtp_port=&quot;4465&quot;</span>
<span style="color: #FF1010; font-weight: bold;">::set username=&quot;&quot;</span>
<span style="color: #FF1010; font-weight: bold;">::set password=&quot;&quot;</span>
set subject=<span style="color: #ff0000;">&quot;Backup logs from %computername%&quot;</span>
set log=<span style="color: #ff0000;">&quot;jsbkwin_log.txt&quot;</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">::File extensions to be excluded, uncomment and modify as needed.</span>
<span style="color: #FF1010; font-weight: bold;">::echo .avi &gt;&gt; exclude.txt</span>
<span style="color: #FF1010; font-weight: bold;">::echo .mp3 &gt;&gt; exclude.txt</span>
echo exclude.txt <span style="color: #66cc66;">&gt;&gt;</span> exclude.txt
&nbsp;
<span style="color: #FF1010; font-weight: bold;">::XCOPY help</span>
<span style="color: #FF1010; font-weight: bold;">:: /s   copied recursively except empty dirs</span>
<span style="color: #FF1010; font-weight: bold;">:: /e   copies empty dirs</span>
<span style="color: #FF1010; font-weight: bold;">:: /v   verifies file writes</span>
<span style="color: #FF1010; font-weight: bold;">:: /y   answers yes with out prompt</span>
<span style="color: #FF1010; font-weight: bold;">:: /i   assumes dirs are dirs (duhh)</span>
<span style="color: #FF1010; font-weight: bold;">:: /h   copies hidden and system files</span>
<span style="color: #FF1010; font-weight: bold;">:: /d   copies new or changed files</span>
<span style="color: #FF1010; font-weight: bold;">:: /EXCLUDE:[file]    files or strings to exclude</span>
<span style="color: #FF1010; font-weight: bold;">::  &gt;&gt; %log% 2&gt;&amp;1     redirects standard out and error and appends to log</span>
&nbsp;
echo.
echo Press <span style="color: #ff0000;">&quot;X&quot;</span> at top right of window <span style="color: #800080;">to</span> <span style="color: #0080FF; font-weight: bold;">cancel</span>.
echo backup screen will be blank throughout backup process. <span style="color: #0080FF; font-weight: bold;">Check</span> log <span style="color: #800080;">for</span>
echo activity and results.
echo log location<span style="color: #FF1010; font-weight: bold;">: %log%</span>
<span style="color: #FF1010; font-weight: bold;">::uncomment &quot;pause&quot; for running manual or troubleshooting</span>
<span style="color: #FF1010; font-weight: bold;">::pause</span>
echo.
&nbsp;
echo <span style="color: #66cc66;">----------</span>BEGIN<span style="color: #66cc66;">----------</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span>
echo <span style="color: #0000FF;">Version</span><span style="color: #FF1010; font-weight: bold;">: %version% &gt;&gt; %log%</span>
date <span style="color: #66cc66;">/</span>t <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&gt;&amp;</span><span style="color: #cc66cc;">1</span>
time <span style="color: #66cc66;">/</span>t <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&gt;&amp;</span><span style="color: #cc66cc;">1</span>
echo.
echo Backed up files<span style="color: #FF1010; font-weight: bold;">:</span>
echo.
&nbsp;
echo running rsync<span style="color: #66cc66;">-</span>mirror backup now <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&gt;&amp;</span><span style="color: #cc66cc;">1</span>
<span style="color: #FF1010; font-weight: bold;">::example</span>
<span style="color: #FF1010; font-weight: bold;">:: C:\cygwin\bin\rsync -rut --delete --stats &quot;/cygdrive/c/DATA&quot; &quot;/cygdrive/e/daily/rsync-mirror&quot; &gt;&gt; %log% 2&gt;&amp;1</span>
<span style="color: #FF1010; font-weight: bold;">:: C:\cygwin\bin\rsync -rut --delete --stats &quot;/cygdrive/c/MT0&quot; &quot;/cygdrive/e/daily/MT0&quot; &gt;&gt; %log% 2&gt;&amp;1</span>
<span style="color: #FF1010; font-weight: bold;">::echo. &gt;&gt; %log% 2&gt;&amp;1</span>
<span style="color: #FF1010; font-weight: bold;">::echo. &gt;&gt; %log% 2&gt;&amp;1</span>
<span style="color: #FF1010; font-weight: bold;">::echo running new-n-changed backup now &gt;&gt; %log% 2&gt;&amp;1</span>
<span style="color: #FF1010; font-weight: bold;">::echo. &gt;&gt; %log% 2&gt;&amp;1</span>
<span style="color: #FF1010; font-weight: bold;">:: xcopy /s/e/v/y/i/h/d/EXCLUDE:exclude.txt &quot;c:\DATA&quot; &quot;e:\daily\new-n-changed&quot; &gt;&gt; %log% 2&gt;&amp;1</span>
&nbsp;
echo.
date <span style="color: #66cc66;">/</span>t <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&gt;&amp;</span><span style="color: #cc66cc;">1</span>
time <span style="color: #66cc66;">/</span>t <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&gt;&amp;</span><span style="color: #cc66cc;">1</span>
echo <span style="color: #66cc66;">----------</span>END<span style="color: #66cc66;">----------</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span>
echo.
&nbsp;
C<span style="color: #FF1010; font-weight: bold;">:\cygwin\bin\unix2dos.exe %log%</span>
&nbsp;
echo mail log
blat <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span><span style="color: #800080;">to</span> <span style="color: #66cc66;">%</span>to<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>subject <span style="color: #66cc66;">%</span>subject<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>hostname <span style="color: #66cc66;">%</span>computername<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span><span style="color: #0080FF; font-weight: bold;">server</span> <span style="color: #66cc66;">%</span>smtp_server<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>f <span style="color: #66cc66;">%</span>from<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>port <span style="color: #66cc66;">%</span>smtp_port<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>u <span style="color: #66cc66;">%</span>username<span style="color: #66cc66;">%</span> <span style="color: #66cc66;">-</span>pw <span style="color: #66cc66;">%</span>password<span style="color: #66cc66;">%</span>
&nbsp;
del exclude.txt
del <span style="color: #66cc66;">%</span>log<span style="color: #66cc66;">%</span>
echo.
echo BACKUP COMPLETE
<span style="color: #FF1010; font-weight: bold;">::uncomment &quot;pause&quot; for troubleshooting</span>
<span style="color: #FF1010; font-weight: bold;">::pause</span>
&nbsp;
<span style="color: #FF1010; font-weight: bold;">::stunnel.conf example:</span>
<span style="color: #FF1010; font-weight: bold;">::client = yes</span>
<span style="color: #FF1010; font-weight: bold;">::debug = debug</span>
<span style="color: #FF1010; font-weight: bold;">::[pop3s]</span>
<span style="color: #FF1010; font-weight: bold;">::accept = 127.0.0.1:9995</span>
<span style="color: #FF1010; font-weight: bold;">::connect = pop3s.myisp.com:995</span>
<span style="color: #FF1010; font-weight: bold;">::[imaps]</span>
<span style="color: #FF1010; font-weight: bold;">::accept = 127.0.0.1:9993</span>
<span style="color: #FF1010; font-weight: bold;">::delay = yes</span>
<span style="color: #FF1010; font-weight: bold;">::connect = imaps.myisp.com:993</span>
<span style="color: #FF1010; font-weight: bold;">::[smtps]</span>
<span style="color: #FF1010; font-weight: bold;">::accept = 127.0.0.1:4465</span>
<span style="color: #FF1010; font-weight: bold;">::connect = smtps.myisp.com:465</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/448/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Random Tech Notes</title>
		<link>http://jasonschaefer.com/archives/396?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=random-tech-notes</link>
		<comments>http://jasonschaefer.com/archives/396#comments</comments>
		<pubDate>Fri, 04 Mar 2011 20:33:53 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[forfiles]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[mbr]]></category>
		<category><![CDATA[rdp]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xfs]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=396</guid>
		<description><![CDATA[Here are some random notes that I find useful. I also tend to forget and use as reference. [] Vim reference :e filename (open filename) :q! (quit, don&#8217;t save) :x (write if changed, otherwise exit) a (insert after) A (insert after line) h j k l (left, down, up, right) $ (move to end of <a href='http://jasonschaefer.com/archives/396' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Here are some random notes that I find useful. I also tend to forget and use as reference.</p>
<p><strong>[] Vim reference</strong></p>
<p>:e filename (open filename)<br />
:q! (quit, don&#8217;t save)<br />
:x (write if changed, otherwise exit)<br />
a (insert after)<br />
A (insert after line)<br />
h j k l (left, down, up, right)<br />
$ (move to end of line)<br />
^ or 0 (move to beginning of line)<br />
G (move to end of file)<br />
:n (move to &#8220;n&#8221; line, n=number)<br />
x (delete to the right)<br />
X (delete to the left)<br />
D (delete to the end of line)<br />
dd (delete current line)<br />
yy (yank/copy current line)<br />
V (begin highlight, up and down to select &#8220;y&#8221; to yank selection)<br />
vn (yank &#8220;n&#8221; lines below cursor, n=number)<br />
p (put/paste)<br />
u (undo)<br />
/string (search for &#8220;string&#8221;)<br />
n (search for next string match)<br />
:s/yellow/green/gc (replace yellow with green, g is for global, each match is replaced in a line, instead of the first match in a line. c is for confirm/ask)<br />
:%s/yellow/green/g (replaces yellow with green on the entire page)<br />
:s:/usr/local/bin:/opt/users/bin:g (use something other than / as delineation so you don&#8217;t have to escape &#8220;/&#8221;. Like this nasty example: :s/\/usr\/local\/bin/\/usr\/loca\/bin)</p>
<p>[] <strong>find command</strong><br />
find . -name &#8220;name&#8221; -exec [command goes here] {} \;<br />
find . -type d -exec chmod 750 {} \;<br />
find . -type f -exec chmod 760 {} \;<br />
find /home/BACKUP -mtime +14 -exec rm -fr {} \;<br />
-mtime options:<br />
n exactly n days<br />
+n more than n days<br />
-n less than n days</p>
<p>to convert all backslash \ to forward slash /<br />
find . -type f -iname *.xml -exec sed -i &#8216;s:\\:/:g&#8217; {} \;</p>
<p><strong>[] Rename multiple files</strong></p>
<p>remove space from all files ending in .mp3<br />
rename &#8216;s/ //&#8217;g *.mp3</p>
<p>rename all files ending in .ZIP to .zip<br />
rename &#8216;s:\.ZIP:\.zip:&#8217; *.ZIP</p>
<p>[] <strong>Sending mail with telnet:</strong><br />
telnet hostname 25<br />
helo me<br />
mail from:myaddress@mydom.com<br />
rcpt to:youraddress@yourdom.com<br />
data<br />
This is a test<br />
.<br />
(thats a newline [enter] &#8211; period &#8211; and another newline [enter])</p>
<p><strong>[] Fix MBR for windows</strong></p>
<p>http://ms-sys-free.sourceforge.net/</p>
<p>from gnulinux:<br />
ms-sys -m /dev/hda</p>
<p>from msdos or nt recovery console:<br />
fdisk /mbr</p>
<p><strong>[] Batch and snippets</strong> (yuck)</p>
<p>http://www.allenware.com/icsw/icswidx.htm</p>
<p>echo Cleanup .bak files older than 7 days<br />
forfiles /p d:\backup /m *.bak /d -7 /c &#8220;cmd /c del /q @path&#8221;</p>
<p>echo Set variable date as yyyymmdd<br />
set date=%date:~-4,4%%date:~4,2%%date:~-7,2%<br />
echo %date%</p>
<p><strong>[] Filesystem stuff</strong></p>
<p>make image of sda<br />
dd if=/dev/sda of =sda.img bs=1M<br />
backup mbr<br />
dd if=/dev/sda of=mbr.backup bs=512 count=1<br />
mount image<br />
losetup /dev/loop0 sda.img<br />
mount /dev/loop0 /mnt</p>
<p><strong>xfs filesystem and xfsprogs</strong><br />
Determine the amount of fragmentation on sda2<br />
xfs_db -c frag -r /dev/sda2</p>
<p>Filesystem re-organizer, by default, with no arguments. It re-organizes files in mounted partitions for 2 hours. Use -t to change the time.)<br />
xfs_fsr</p>
<p><strong>[] Recover Files</strong><br />
testdisk (recover lost partitions)<br />
photorec (part of the testdisk suite)<br />
foremost sda.img<br />
-t (type doc,jpg,exe etc. all is default)<br />
-a (no error detection, recovers partial files)<br />
-d (indirect block, use for nix filesystems)<br />
-o (output dir)<br />
-T (timestamp output dir)</p>
<p><strong>[] KVM Virtualization</strong></p>
<p>Interface config for bridging to virtualized client /etc/network/interfaces<br />
auto eth0<br />
iface eth0 inet dhcp<br />
auto br0<br />
iface br0 inet dhcp<br />
bridge_ports eth0<br />
bridge_stp off<br />
bridge_maxwait 5</p>
<p><strong>[] KVM with Windows</strong></p>
<p>The best way to get virtio is on install. Download the block driver floppy image and attach it, I use virt-manager. Set your hard drive to type virtio and start your windows install. It will will prompt you to press f6 to install third party drivers. Then press S (you have a disk from a third party manufacturer, your floppy image)</p>
<p>If you already have a disk type IDE and want it to be virtio (better). Then do this:<br />
1. Create a temporary image<br />
kvm-img create -f qcow2 temp-virtio.img 1G<br />
2. Shutdown your virtual machine and attach temp-virtio.img as a hard drive, as type virtio.<br />
3. Attach the virtio-win-x.x.x.vfd (i used the one from fedoraproject.org, see below) to you virtual machine<br />
4. Boot up and install the drivers<br />
5. Shutdown, remove the old hard drive image and re-add it as type virtio<br />
6. Boot up and since you already installed the drivers it will boot. Otherwise, you get BSOD..<br />
(You can remove the temp-virtio.img and floppy image).. All done.</p>
<p>For network drivers.. Shutdown, set the &#8220;device model&#8221; to virtio. Attach the NETKVM-xxxx.iso as a cdrom. Bootup and install drivers. yay!</p>
<p>virtio network drivers, quamranet</p>
<p>http://sourceforge.net/projects/kvm/files/kvm-driver-disc/</p>
<p>virtio block device drivers (aka, hard drive)<br />
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/ or</p>
<p>http://sourceforge.net/projects/kvm/files/kvm-guest-drivers-windows/</p>
<p><strong>[] Windows Policy</strong></p>
<p>run gpedit.msc to edit policy</p>
<p>to backup or move to new host, copy the following<br />
%systemroot%\system32\GroupPolicy\Machine and User dirs</p>
<p>to apply changed policy&#8217;s<br />
gpupdate /force</p>
<p><strong>[] RDP tricks</strong></p>
<p>SeamlessRDP http://www.cendio.com/seamlessrdp/<br />
rdesktop -A -s &#8220;c:\seamlessrdp\seamlessrdpshell.exe c:\program files\internet explorer\iexplore.exe&#8221; -u username -p password hostname</p>
<p><strong>[] Self Signed certificate on debian, the easiest way possible</strong></p>
<p>make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/hostcert.crt<br />
This script will ask for a domain and write the certificate.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/396/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Installing OpenVPN client on Windows Vista and 7</title>
		<link>http://jasonschaefer.com/archives/312?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-openvpn-on-windows-vista-and-windows-7</link>
		<comments>http://jasonschaefer.com/archives/312#comments</comments>
		<pubDate>Thu, 28 Oct 2010 19:20:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[vpn]]></category>
		<category><![CDATA[openvpn]]></category>
		<category><![CDATA[untangle]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=312</guid>
		<description><![CDATA[These are the manual instructions for installing and configuring OpenVPN client See the Section at the end if you are using untangle. Download openvpn gui at http://openvpn.net/index.php/open-source/downloads.html#latest-stable Run installer Leave the components section as default. Accept the TAP driver install Right click on OpenVPN GUI and select properties Go to Compatibility tab and select &#8220;run <a href='http://jasonschaefer.com/archives/312' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>These are the manual instructions for installing and configuring OpenVPN client</p>
<p>See the Section at the end if you are using untangle.</p>
<p>Download openvpn gui at <a href="http://openvpn.net/index.php/open-source/downloads.html#latest-stable">http://openvpn.net/index.php/open-source/downloads.html#latest-stable</a></p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/10/get-latest-stable.png"><img class="alignnone size-medium wp-image-339" title="get-latest-stable" src="http://jasonschaefer.com/wp-content/uploads/2010/10/get-latest-stable-300x263.png" alt="" width="300" height="263" /></a></p>
<p>Run installer</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/run-installer.png"><img class="alignnone size-medium wp-image-349" title="run-installer" src="http://jasonschaefer.com/wp-content/uploads/2010/11/run-installer-300x188.png" alt="" width="300" height="188" /></a></p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/install.png"><img class="alignnone size-full wp-image-345" title="install" src="http://jasonschaefer.com/wp-content/uploads/2010/11/install.png" alt="" width="200" height="157" /></a></p>
<p>Leave the components section as default.</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/install-defaults.png"><img class="alignnone size-medium wp-image-346" title="install-defaults" src="http://jasonschaefer.com/wp-content/uploads/2010/11/install-defaults-300x234.png" alt="" width="300" height="234" /></a></p>
<p>Accept the TAP driver install</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/TAP-install.png"></a><a href="http://jasonschaefer.com/wp-content/uploads/2010/10/TAP-install.png"><img class="alignnone size-medium wp-image-358" title="TAP-install" src="http://jasonschaefer.com/wp-content/uploads/2010/10/TAP-install-300x182.png" alt="" width="300" height="182" /></a></p>
<p>Right click on OpenVPN GUI and select properties</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/properties.png"><img class="alignnone size-medium wp-image-353" title="properties" src="http://jasonschaefer.com/wp-content/uploads/2010/11/properties-219x300.png" alt="" width="219" height="300" /></a></p>
<p>Go to Compatibility tab and select &#8220;run this program as administrator&#8221;<br />
(It requires admin priviledges because it needs to write routes for the new VPN tunnel. Without, it will connect but won&#8217;t know how to reach the other network.)</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/run-as-admin.png"><img class="alignnone size-medium wp-image-354" title="run-as-admin" src="http://jasonschaefer.com/wp-content/uploads/2010/11/run-as-admin-208x300.png" alt="" width="208" height="300" /></a></p>
<p>Get your OpenVPN configuration files from the system administrator. Copy and paste them into C:\Program Files\OpenVPN\config</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/10/config1.png"><img class="alignnone size-medium wp-image-370" title="config" src="http://jasonschaefer.com/wp-content/uploads/2010/10/config1-300x95.png" alt="" width="300" height="95" /></a><br />
ca.crt (certificate authority)<br />
jason.crt (client certificate)<br />
jason.key (client secret key)<br />
jason.ovpn (client configuration). Here are the contents of jason.ovpn:</p>
<pre class="brush:plain">client
dev tun0
cert jason.crt
key jason.key
ca ca.crt
remote vpn.server 1194
</pre>
<p>Now you can launch OpenVPN GUI by double clicking the icon on the desktop (the one we just set to run as admin). This will launch the OpenVPN GUI into the system tray.</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/10/systray-icon.png"><img class="size-medium wp-image-363 alignnone" title="systray-icon" src="http://jasonschaefer.com/wp-content/uploads/2010/10/systray-icon-282x300.png" alt="" width="282" height="300" /></a></p>
<p>Click on system tray, right click on OpenVPN GUI, left click &#8220;Connect&#8221;.</p>
<p>If all goes well, you will successfully connect. The OpenVPN GUI systray icon turns green. Now you are on the Virtual Private Network!</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/systray-icon.png"></a><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/systray-connected.png"><img class="size-full wp-image-355 alignnone" title="systray-connected" src="http://jasonschaefer.com/wp-content/uploads/2010/11/systray-connected.png" alt="" width="125" height="164" /></a></p>
<p><strong>Troubleshooting:</strong></p>
<p>If you can&#8217;t connect, double check you have the correct config files in</p>
<p>&nbsp;</p>
<h1>Untangle: Download or Distribute OpenVPN clients<strong><br />
</strong></h1>
<p>If you happen to be using untangle as the OpenVPN server you can   download the untangle openvpn client and configs from the untangle administration web interface. This greatly simplifies your setup as everything is bundled inside the setup.exe. Just download and install and connect.  This requires untangle version 7.4.1 or   higher to be compatible with Vista or Win 7. If you are using an older version, click &#8220;download a key for all other clients&#8221; (see screenshot below) and follow the instructions from the top of this page. If you want more control, you can use the above instructions for new versions of Untangle too.</p>
<p><strong>From untangle web interface:</strong></p>
<p>1. From main Untangle screen. OpenVPN rack, click on Settings<br />
2. Clients Tab<br />
3. Click &#8220;Distribute Clients&#8221;<br />
<a href="http://jasonschaefer.com/wp-content/uploads/2010/11/untangle-distribute.png"><br />
<img class="size-medium wp-image-360 alignnone" title="untangle-distribute" src="http://jasonschaefer.com/wp-content/uploads/2010/11/untangle-distribute-300x16.png" alt="" width="300" height="16" /></a></p>
<p>4. Then click to download OR enter the email address to send it to.</p>
<p><a href="http://jasonschaefer.com/wp-content/uploads/2010/11/untangle-download-config.png"><img class="size-medium wp-image-361 alignnone" title="untangle-download-config" src="http://jasonschaefer.com/wp-content/uploads/2010/11/untangle-download-config-300x210.png" alt="" width="300" height="210" /></a></p>
<p>5. Install on client computer and connect. Everything is done for you..</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/312/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Creating a custom wordlist for john the ripper</title>
		<link>http://jasonschaefer.com/archives/255?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-a-custom-wordlist-for-john-the-ripper</link>
		<comments>http://jasonschaefer.com/archives/255#comments</comments>
		<pubDate>Thu, 08 Apr 2010 18:32:11 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[cracking]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[john the ripper]]></category>
		<category><![CDATA[jtr]]></category>
		<category><![CDATA[passwd]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[shadow]]></category>
		<category><![CDATA[tr]]></category>
		<category><![CDATA[unshadow]]></category>
		<category><![CDATA[wordlist]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=255</guid>
		<description><![CDATA[I wanted a larger wordlist than the default /usr/share/john/password.lst, with only 3115 words. Openwall sells a really great wordlist, but if you don&#8217;t need anything that fancy you can follow these instructions. The apt-get bit is debian specific. I will install dictionaries and then concatenate them all into one file, remove duplicates, lower case and <a href='http://jasonschaefer.com/archives/255' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I wanted a larger wordlist than the default /usr/share/john/password.lst, with only 3115 words. Openwall sells a really <a href="http://www.openwall.com/wordlists/">great wordlist</a>, but if you don&#8217;t need anything that fancy you can follow these instructions. The apt-get bit is debian specific. I will install dictionaries and then concatenate them all into one file, remove duplicates, lower case and configure john to use the new list.</p>
<pre class="brush:plain">
apt-get install john wamerican-huge wamerican-insane wamerican-large wamerican-small wamerican aspell
aspell dump master > custom-wordlist
cat /usr/share/john/password.lst >> custom-wordlist
cat /usr/share/dict/american-english* >> custom-wordlist
</pre>
<p>  You can concatenate more wordlists into the custom-wordlist file as you find them. Debian has lots more dictionary type packages. For instance, apt-cache search wordlists. Use dpkg -L [installed-package-name] to find where the actual word list file is installed.<br />
  Lets count how many lines (words) are in our wordlist so far:</p>
<pre class="brush:plain">wc -l custom-wordlist</pre>
<p>  I got 1484152, There must be tons of duplicates. Lets get rid of them. We can also lowercase everything, since john toggles case automatically for us.</p>
<pre class="brush:plain">tr A-Z a-z < custom-wordlist.txt > custom-wordlist_lowercase</pre>
<p>  Now we remove the duplicates</p>
<pre class="brush:plain">sort -u custom-wordlist_lowercase > custom-wordlist_lowercase_nodups</pre>
<p>  How many lines do we have now?</p>
<pre class="brush:plain">wc -l custom-wordlist_lowercase_nodups
613517</pre>
<p>  Now we can set john up to use our custom wordlist file. </p>
<pre class="brush:plain">Edit the file /etc/john/john.conf
Wordlist = [path to custom-wordlist_lowercase_nodups]</pre>
<p>  Now we are ready to crack some passwords! First, combine the passwd and shadow files. This will allow john to use the GECOS information from the passwd file. GECOS is the user information fields such as first, last and phone. These fields will be used by john to make a more educated guess as to what that users password might be.</p>
<pre class="brush:plain">unshadow passwd shadow > unshadow.txt</pre>
<p>  run john against the resulting unshadow.txt file</p>
<pre class="brush:plain">john unshadow.txt
Loaded 15 password hashes with 15 different salts (FreeBSD MD5 [32/64 X2])</pre>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/255/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>* Flashing a BIOS update using only free tools (FreeDOS, etc)</title>
		<link>http://jasonschaefer.com/archives/209?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flashing-a-bios-update-using-only-free-tools-freedos</link>
		<comments>http://jasonschaefer.com/archives/209#comments</comments>
		<pubDate>Fri, 12 Mar 2010 08:52:41 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[freedos]]></category>
		<category><![CDATA[gpl]]></category>
		<category><![CDATA[unzip]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[wodim]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=209</guid>
		<description><![CDATA[The wonderful world of motherboard BIOS updates, is still old fashioned. Updates are often still built for Microsoft Windows environments. Often requiring MS DOS. Those of us who don&#8217;t have DOS, a floppy drive, an install of Windows 98 to create a bootable floppy, cheesy Pâté, or MS Windows for that matter &#8230;.. Here is <a href='http://jasonschaefer.com/archives/209' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>The wonderful world of motherboard BIOS updates, is still old fashioned. Updates are often still built for Microsoft Windows environments. Often requiring MS DOS. Those of us who don&#8217;t have DOS, a floppy drive, an install of Windows 98 to create a bootable floppy, cheesy Pâté, or MS Windows for that matter &#8230;.. Here is a way one can flash that BIOS of your mobo using, our favorite free software licensed, operating systems and tools.</p>
<p>DISCLAIMER: Don&#8217;t attempt this unless you know what you are doing. I have never had problems doing this, BUT many things can go wrong and you CAN easily &#8220;brick&#8221; your hardware. Proceed at your own risk!!</p>
<p>We will be using <a href="http://www.freedos.org/">FreeDOS</a>, a wonderfully free and royalty exempt Microsoft DOS compatible operating system. Licensed under the General Public License (GPL).<br />
Note: As usual, my posts require some knowledge of the command line.</p>
<pre class="brush:plain">
wget http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz
gunzip FDOEM.144.gz
mkdir floppy
sudo mount -o loop FDOEM.144 floppy/
ls floppy
</pre>
<p>you should see these files:<br />
AUTOEXEC.BAT  COMMAND.COM  CONFIG.SYS  KERNEL.SYS  README  sys.com</p>
<p>Download your BIOS update file from the manufacturer or vendor.<br />
Note: Sometimes, the update will be distributed as a .exe (Windows Executable) file. Most likely it will actually be a compressed zip archive. You can use unzip to extract the .exe file.</p>
<p>Download the update using wget, then unzip the resulting image file &#8220;FDOEM.144&#8243; into the mounted folder: &#8220;floppy/&#8221;</p>
<pre class="brush:plain">
wget http://path-to-your-bios-update/BIOS_UPDATE.zip
sudo unzip BIOS_UPDATE.zip -d floppy/
</pre>
<p>In this case, the following files are extracted from the BIOS_UPDATE.zip file:<br />
inflating: BIOS.WPH<br />
inflating: OEMPHL.EXE<br />
inflating: OPTIONS.BAT<br />
inflating: PHLASH16.EXE<br />
inflating: releasenotes.txt<br />
inflating: 1.BAT</p>
<p>now, move to the previous directory (cd ..), and un-mount the FDOEM.144 image:</p>
<pre class="brush:plain">
cd ..
sudo umount floppy/
</pre>
<p>generate the iso image:</p>
<pre class="brush:plain">
genisoimage -o flashboot.iso -b FDOEM.144 FDOEM.144
</pre>
<p>Now burn flashboot.iso to CD using wodim:</p>
<pre class="brush:plain">
wodim flashboot.iso
</pre>
<p>Now you can boot from that cd and run your flash utility!! Read the BIOS update instructions on how to do this.. </p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/209/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Transition away from MBR to GPT booting</title>
		<link>http://jasonschaefer.com/archives/190?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=transition-away-from-mbr-to-gpt-booting</link>
		<comments>http://jasonschaefer.com/archives/190#comments</comments>
		<pubDate>Fri, 19 Feb 2010 06:44:48 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[EFI]]></category>
		<category><![CDATA[gpt]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[grub-install]]></category>
		<category><![CDATA[grub2]]></category>
		<category><![CDATA[lenny]]></category>
		<category><![CDATA[parted]]></category>
		<category><![CDATA[partition]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=190</guid>
		<description><![CDATA[Recently, I was installing debian on a new server and grub2 would not install gave me this error: &#8220;This GPT partition label has no BIOS Boot Partition; embedding won&#8217;t be possible! grub-setup: error: Embedding is not possible, but this is required when the root device is on a RAID array or LVM volume.&#8221; Of course, <a href='http://jasonschaefer.com/archives/190' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I was installing debian on a new server and grub2 would not install gave me this error:</p>
<p>&#8220;This GPT partition label has no BIOS Boot Partition; embedding won&#8217;t be possible! grub-setup: error: Embedding is not possible, but this is required when the root device is on a RAID array or LVM volume.&#8221;</p>
<p>Of course, it being grub2, I jumped to the conclusion that grub2 was the problem. I installed legacy grub and got nowhere.<br />
Doing the usual<br />
grub&gt; root (hd0,0)<br />
grub&gt; setup (hd0)<br />
produces this error:<br />
&#8220;file /boot/grub/stage1 not read correctly&#8221;</p>
<p>No matter what I did, it would not install. So, I went back to the original message and gave grub2 its due process. Turns out this Dell T410 uses GPT (GUID Partition Table) which is an extension of EFI. The &#8220;BIOS Boot Partition&#8221; is an actual partition on the hard drive. Grub2 embeds the core.img (multiboot boot kernel) into this BIOS boot partition instead of the MBR.<br />
Here are two great resources on this subject:<br />
<a href="http://www.rodsbooks.com/gdisk/index.html"> http://www.rodsbooks.com/gdisk/index.html</a> and<br />
<a href="http://grub.enbug.org/BIOS_Boot_Partition">http://grub.enbug.org/BIOS_Boot_Partition</a></p>
<p><strong>So, the solution:</strong><br />
I had to re-install Debian with a small partition. Apparently it can be under a few hundred KiB. Space is cheap and I didn&#8217;t want to have more problems, so I made mine 5MB and put it at the beginning of the disk. In the Debian partitioner, set the partition under &#8220;use as:&#8221; to &#8220;<strong>Reserved BIOS boot area</strong>&#8220;. Then continue with the rest of your partitions and install. Grub2 installed with no problems this time!</p>
<p>If using an older version of Debian, lenny (v5) or older. The &#8220;use as:&#8221; does not have an option for Reserved BIOS boot area. So, I booted into expert install mode, when you get to &#8220;Load installed components from CD&#8221; select parted. This will install parted in the install environment. Before you get to detect disks, do ctrl+alt+f2. On the command line you can manually create a bios boot area.</p>
<p>The following parted commands.</p>
<pre class="brush: plain">parted -a optimal /dev/sda mkpart 1 1 6</pre>
<p>The above command creates the first (1) partition from 1MB of the drive to 6MB. -a optimal sets the block alignment for best performance. If you start the partition at 0 the alignment is wrong and parted will Warn: &#8220;The resulting partition is not properly aligned for best performance. Ignore/Cancel?&#8221;</p>
<pre class="brush: plain">parted /dev/sda set 1 bios_grub on</pre>
<p>This sets /dev/sda1 as GPT grub bios partition. This partition will be found and used by grub on install.</p>
<p>Now, ctrl+alt+f1, and continue the install. Select manual partitioning and be sure not to delete the primary partition (gpt, grub bios) when creating your new partitions.</p>
<p>Do this to all drives in a raid!</p>
<p>After you boot into the fresh install, you can manually install to the other disks.</p>
<pre class="brush: plain">grub-install /dev/sdb</pre>
<p>Now its installed on sda and sdb. In case sda fails, it should be able to boot from sdb.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/190/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>* Thunderbird &amp; Lightning &#124; contacts, calendar, mail syncing for gmail</title>
		<link>http://jasonschaefer.com/archives/143?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=thunderbird-lightning-zindus-and-imap-for-gmail</link>
		<comments>http://jasonschaefer.com/archives/143#comments</comments>
		<pubDate>Sat, 19 Dec 2009 23:50:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[contacts]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[lightning]]></category>
		<category><![CDATA[syncing]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=143</guid>
		<description><![CDATA[. Automatic email setup add-on: Gmail IMAP Account Setup THUNDERBIRD VERSION 3 HAS NATIVE SUPPORT FOR GMAIL. Manual email instructions: Setup Thunderbird according to gmail&#8217;s imap instructions At the bottom of gmail&#8217;s instructions you will see &#8220;recommended settings&#8220;. Don&#8217;t follow the first recommendation, regarding deleting. Instead of actually (permanently) deleting email we can have it <a href='http://jasonschaefer.com/archives/143' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>.<br />
<strong>Automatic email setup add-on:</strong> <a href="https://addons.mozilla.org/en-US/thunderbird/addon/6381">Gmail IMAP Account Setup</a> THUNDERBIRD VERSION 3 HAS NATIVE SUPPORT FOR GMAIL.</p>
<p><strong>Manual email instructions:</strong> Setup Thunderbird according to <a href="http://mail.google.com/support/bin/answer.py?hl=en&amp;answer=77662">gmail&#8217;s imap instructions</a></p>
<p>At the bottom of gmail&#8217;s instructions you will see &#8220;<a href="http://mail.google.com/support/bin/answer.py?answer=78892#">recommended settings</a>&#8220;. Don&#8217;t follow the first recommendation, regarding deleting. Instead of actually (permanently) deleting email we can have it moved to the Trash folder, as if you were using the gmail web interface. Gmail has strange folders structure in imap. Here are a few steps to work with gmail folders (Of course, they call them labels :-)</p>
<p>Under Account settings -&gt; Copies and Folders<br />
1. un-check &#8220;place a copy in&#8230; sent&#8221;<br />
2. change  &#8220;drafts and templates&#8221; to Other -&gt; [your gmail address] -&gt; [Gmail] -&gt; Drafts<br />
<strong>Note:</strong> Sent and Drafts will automatically show up in their respective folders, as long as you send mail through smtp.gmail.com.<br />
3. Go to Options/Preferences (under tools or edit menu). Go to Advanced -&gt; Config Editor. In the Filter box, type &#8220;mail.server.server&#8221; and look for the gmail address. Whichever number is in the X place of mail.server.serverX, is what you want to use for the new value.<br />
Right click New -&gt; String &#8220;enter mail.server.serverX.trash_folder_name&#8221; (X is the number that correlates to your gmail account, from above). Next enter &#8220;[Gmail]/Trash&#8221;. Restart Thunderbird. Delete something, if it does not go into the [Gmail]/Trash folder restart again. It should work after that. Now you can delete the Trash folder (represented as [Imap]/Trash in gmail)</p>
<p><strong>Contact syncing:</strong> A few options.<br />
A very popular and stable add-on <a href="https://addons.mozilla.org/en-US/thunderbird/addon/6095">Zindus</a> Its great but does not support the address field syncing. (Enter your user/pass under Tools -&gt; Zindus)<br />
<a href="https://addons.mozilla.org/en-US/thunderbird/addon/8451">gContactSync</a> has support for the address field but is very early in development. If any contacts have an empty email field it adds a @nowhere.invalid email address in Tbird. Thankfully this is not synced to your gmail account!<br />
Also, This looks promising but does not work with Tbird3 <a href="https://addons.mozilla.org/en-US/thunderbird/addon/7307">Google Contacts</a>.<br />
BACKUP CONTACTS BEFORE SYNCING!</p>
<p><strong>Calendar Sharing:</strong> Use the add-on <a href="https://addons.mozilla.org/en-US/thunderbird/addon/2313">Lightning</a> (aka sunbird as a Tbird add on).  Lightning 1.0b1 does not integrate with Thunderbird 3 toolbar layout very well. It messed up the &#8220;file&#8221; &#8220;edit&#8221; and &#8220;view&#8221; menus. Although, they aren&#8217;t really missed by anyone and are sort of accessible if you really need them. Try it for yourself, its not too bad.<br />
For native support follow the <a href="http://www.google.com/support/calendar/bin/answer.py?hl=en&amp;answer=99358">Google sunbird instructions for CalDav</a> (recommended)<br />
There is also another plugin called <a href="https://addons.mozilla.org/en-US/thunderbird/addon/4631">Provider for Google Calendar</a> that can be used..</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/143/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Spoof MAC address in Windows or gnu/linux</title>
		<link>http://jasonschaefer.com/archives/56?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spoof-mac-address-in-windows</link>
		<comments>http://jasonschaefer.com/archives/56#comments</comments>
		<pubDate>Tue, 13 Oct 2009 21:25:34 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[ifconfig]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[ipconfig]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[regedit]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[spoof]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=56</guid>
		<description><![CDATA[start -> run -> regedit make a backup, if you want. goto: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318} look through the list of subkeys (0000, 0001, etc) DriverDesc keyword will tell you which network adapter. For example, &#8220;NVIDIA nForce Networking Controller&#8221; when you find it, right click and add -> new -> string value new keyword: Value Name: = NetworkAddress <a href='http://jasonschaefer.com/archives/56' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>start -> run -> <strong>regedit</strong><br />
make a backup, if you want.<br />
goto:</p>
<pre class="brush: plain">
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}
</pre>
<p>look through the list of subkeys (0000, 0001, etc)<br />
<strong>DriverDesc</strong> keyword will tell you which network adapter. For example, &#8220;NVIDIA nForce Networking Controller&#8221;<br />
when you find it, right click and <strong>add -> new -> string value</strong></p>
<p>new keyword:</p>
<pre class="brush: plain">
Value Name: = NetworkAddress
Value Data: = your new MAC, with no space or : For example, 0019DB71C830
</pre>
<p>then type:</p>
<pre class="brush: plain">
ipconfig /release
ipconfig /renew
ipconfig /all   (to verify the new mac took)
</pre>
<p>Now your a l33t Winblows H4|<3r! If you want to go back to your hardware MAC, remove the NetworkAddress key and restart the interface.</p>
<p>FYI, in gnu/linux follow these simple steps to change your MAC address</p>
<pre class="brush: plain">ifconfig eth0 hw ether 00:19:DB:71:C8:30</pre>
<p>if you get this error</p>
<pre class="brush: plain">SIOCSIFHWADDR: Device or resource busy - you may need to down the interface</pre>
<p>do this</p>
<pre class="brush: plain">ifconfig eth0 down</pre>
<p>and try to change the MAC again.</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/56/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Free Wireless in Santa Fe, NM</title>
		<link>http://jasonschaefer.com/archives/41?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=free-wireless-in-santa-fe-nm</link>
		<comments>http://jasonschaefer.com/archives/41#comments</comments>
		<pubDate>Mon, 12 Oct 2009 18:13:21 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[wireless]]></category>
		<category><![CDATA[santa fe]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=41</guid>
		<description><![CDATA[Here is a list of free wireless spots in Santa Fe. I&#8217;m sure I will miss some or make errors, please let me know. I don&#8217;t list locations that use a password, as it irritates me when people inconvenience patrons for some ignorant reason. * Santa Fe Baking Company (one of the first and best <a href='http://jasonschaefer.com/archives/41' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Here is a list of free wireless spots in Santa Fe. I&#8217;m sure I will miss some or make errors, please let me know. I don&#8217;t list locations that use a password, as it irritates me when people inconvenience patrons for some ignorant reason.</p>
<p>* <a href="http://maps.google.com/places/us/nm/santa-fe/w-cordova-rd/504/-santa-fe-baking-co-&amp;-cafe?gl=us">Santa Fe Baking Company</a> (one of the first and best wireless spots in town, lots of seating and ample power, food and kitchen smell can be harsh)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/w-cordova-rd/505/-pyramid-cafe?gl=us">Pyramid Cafe</a> (VERY fast internet, Amazing Mediterranean food)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/2nd-st/1814/-second-street-brewery?gl=us">Second Street Brewery</a> (very solid reliable connection, inside or out. great beer too!)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/baca-st/930/-counter-culture?hl=en&amp;gl=us">Counter Culture Cafe</a> (the qwest connection goes down a lot, the ap is too far from the seating area, but great place to hang, eat and work)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/canyon-rd/821/-teahouse?hl=en&amp;gl=us">Teahouse</a> (The best selection of teas and generally good internet, very relaxing place. great food too)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/aztec-st/317/-aztec-cafe?hl=en&amp;gl=us">Aztec Cafe</a> (small but friendly environment, good coffee and sandwiches)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/cerrillos-rd/4056/-blue-corn-cafe-&amp;-brewery?hl=en&amp;gl=us">Blue Corn</a> (the bar downtown has it, ask the bar tender for password (indiapaleale). The southside is open AP and I think the essid is jaguar)<br />
* <a href="http://maps.google.com/maps/place?cid=11633852963867287663&amp;q=flying%2Bstar%2Bsanta%2Bfe%2Bnm&amp;hl=en&amp;gl=us">Flying Star Cafe</a> (the wireless is always slow, food is overpriced and not very good. They use sputnik as a captive portal, its annoying to ask users to sign up for internet. I login with user: free pass: wireless There is a lot of space and the air is fresh)<br />
* <a href="http://maps.google.com/maps/place?cid=4963057524569207422&amp;q=santa%2Bfe%2Bbrewing%2Bcompany%2Bsanta%2Bfe%2Bnm&amp;hl=en&amp;gl=us">Santa Fe Brewing Company</a> (its awesome they provide internet so far out of town)<br />
* <a href="http://maps.google.com/places/us/nm/santa-fe/bisbee-ct/5/-backroad-pizza?hl=en&amp;gl=us">Backroad Pizza</a> (south side location has it, not sure about the 2nd street location)<br />
* <a href="http://maps.google.com/maps/place?cid=13338196817836186161&amp;q=joes+diner+santa+fe+nm&amp;gl=us&amp;hl=en&amp;cd=1&amp;cad=src:pplink,view:map&amp;ei=_WPkS8OSFYf4M53S-IoN">Joe&#8217;s</a> Good food, friendly staff, good internet<br />
* <a href="http://maps.google.com/maps/place?oe=utf-8&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a&amp;um=1&amp;ie=UTF-8&amp;q=body+of+santa+fe+nm&amp;fb=1&amp;gl=us&amp;hq=body+of&amp;hnear=Santa+Fe,+NM&amp;cid=4750373795995985444">Body</a> (great healthy food, limited seating in front cafe area, back dining area reserved for no computers and no cell phones :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/41/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Linux-Libre and Realtime patch</title>
		<link>http://jasonschaefer.com/archives/21?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-libre-and-realtime-patch</link>
		<comments>http://jasonschaefer.com/archives/21#comments</comments>
		<pubDate>Sun, 11 Oct 2009 21:48:31 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[fakeroot]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[libre]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[linux-libre]]></category>
		<category><![CDATA[linuxlibre]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[realtime]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=21</guid>
		<description><![CDATA[I wanted to share some notes on patching the Linux Libre kernel with realtime capabilities. The Linux-Libre project pulls out all the un-free bits from standard Linux. Contrary to popular belief, Linux has many non-free parts, small binary or obfuscated pieces of code for various hardware. I have a Lenovo T61 laptop. I removed the <a href='http://jasonschaefer.com/archives/21' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I wanted to share some notes on patching the Linux Libre kernel with realtime capabilities. The Linux-Libre project pulls out all the un-free bits from standard Linux. Contrary to popular belief, Linux has many non-free parts, small binary or obfuscated pieces of code for various hardware. I have a Lenovo T61 laptop. I removed the Intel wireless pci express card and put in a Atheros AR5008 wifi card using ath9k completely free wireless driver. Now my system (as far as I can tell:-) is completely free.</p>
<p>I make music and the realtime patch makes the latency of my system and soundcard very low. This is a unique advantage that the gnu/linux operating system gives its users. I highly recommend a realtime patch for anyone working with audio and video on gnu/linux.</p>
<p>Start by getting the rt patch <a href="http://www.kernel.org/pub/linux/kernel/projects/rt/">http://www.kernel.org/pub/linux/kernel/projects/rt/</a> for the kernel version you want to compile.<br />
Then get the corresponding Linux-Libre version <a href="http://www.linux-libre.fsfla.org/pub/linux-libre/releases/">http://www.linux-libre.fsfla.org/pub/linux-libre/releases/</a></p>
<pre class="brush: plain">
tar xfvj linux-2.6.29.6-libre1.tar.bz2
cd linux-2.6.29.6
bzcat ../patch-2.6.29.6-rt23.bz2 | patch -p1
</pre>
<p>Now Linux is patched with realtime<br />
now its time for</p>
<pre class="brush: plain">make menuconfig</pre>
<p>from the <a href="http://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO">RT How to</a>:<br />
* enable CONFIG_PREEMPT_RT<br />
* activated the High-Resolution-Timer Option (Attention, the amount of supported platforms by the HR timer is still very limited. Right now the option is only supported on x86 systems, PowerPC and ARM Support are however in queue.)<br />
* disabled all Power Management Options like ACPI or APM (not all ACPI functions are &#8220;bad&#8221;, but you will have to check very carefully to find out which function will affect your real time system. Thus it&#8217;s better to simply disable them all if you don&#8217;t need them. APM, however, is a no-go.) NOTE: Since rt patch 2.6.18-rt6 you will probably have to activate ACPI option to activate high resolution timer. Since the TSC timer on PC platforms, as used in the previous versions, are now marked as unsuitable for hrt mode due to many lacks of functionalities and reliabilties, you will need i.E. pm_timer as provided by ACPI to use as clock source. To activate the pm_timer, you can just activate the ACPI_SUPPORT in menuconfig and deactivate all other sub modules like &#8220;fan&#8221;, &#8220;processor&#8221; or &#8220;button&#8221;. If you have an old pc, which lacks ACPI support, you migh have problems using the high resolution timer.</p>
<p>I personally have not removed my power management options, as I use a laptop and want these features. I don&#8217;t notice any problems but have not tried it without them to know what I&#8217;m missing.</p>
<p>then compile the kernel, the debian way</p>
<pre class="brush: plain">fakeroot make-kpkg kernel_image</pre>
<pre class="brush: plain">sudo dpkg -i linux-image-2.6.29.6-libre1-lapkah_2.6.29.6-libre1-lapkah-10.00.Custom_i386.deb</pre>
<p>Here is my latest <a href="http://jasonschaefer.com/stuff/config_linux-libre_and_realtime_2.6.33_.config_for_Lenovo_T61">config </a> and the <a href="http://jasonschaefer.com/stuff/linux-image-2.6.33-libre-lapkah_2.6.33-libre-lapkah-10.00.Custom_i386.deb">debian package for libre realtime for lenovo t61</a></p>
<p>~ May your kernel build and your modules have your back ~</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/21/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* Silverlight (Microsoft) and Moonlight (Novell) Digital Restrictions Management frustrations</title>
		<link>http://jasonschaefer.com/archives/10?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=silverlight-microsoft-and-moonlight-novel-digital-restrictions-management-frustrations</link>
		<comments>http://jasonschaefer.com/archives/10#comments</comments>
		<pubDate>Sat, 10 Oct 2009 21:43:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Content Control]]></category>
		<category><![CDATA[DRM]]></category>
		<category><![CDATA[moonlight]]></category>
		<category><![CDATA[netflix]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=10</guid>
		<description><![CDATA[Moonlight is a Free implementation of Microsoft Silverlight. Its a Mono project, http://www.mono-project.com/Moonlight. I have read rumors that 2.0 will have support for Netflix. I went to install the 2.0 dev (currently 1.99.5). Logged into netflix and was denied. I was confused because moonlights dev website says that 1.99.5 is complete except for bug testing <a href='http://jasonschaefer.com/archives/10' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Moonlight is a Free implementation of Microsoft <a href="http://en.wikipedia.org/wiki/Silverlight">Silverlight</a>. Its a Mono project, <a href="http://www.mono-project.com/Moonlight">http://www.mono-project.com/Moonlight</a>. I have read rumors that 2.0 will have support for Netflix. I went to install the 2.0 dev (currently 1.99.5). Logged into netflix and was denied. I was confused because moonlights dev website says that 1.99.5 is complete except for bug testing and a security audit. I did more reading and found that its not a limitation of moonlight at all, its the DRM (Digital Restrictions Management) that Netflix licenses from Microsoft called Play Ready. This is why we can&#8217;t watch Netflix with Moonlight. Another case where the end user suffers at the hands of DRM. The industry again is trying to control the user and hope no one cares. So what, if people save the movie streams from Netflix, you can copy as many dvd&#8217;s as you want when they show up in the mail! What happened to Fair Use? The move to hosted content is highly desireable by these industries. Now they can tell you what, how and when. Since its hosted on their servers, you can&#8217;t do a thing about it (other than not use it). Ugghh. I am disappointed&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/10/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>* openwrt, firewall to block public wireless from private lan</title>
		<link>http://jasonschaefer.com/archives/3?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openwrt-firewall-public-wireless-from-private-lan</link>
		<comments>http://jasonschaefer.com/archives/3#comments</comments>
		<pubDate>Thu, 08 Oct 2009 02:14:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[firewall]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[kamikaze]]></category>
		<category><![CDATA[openwrt]]></category>

		<guid isPermaLink="false">http://jasonschaefer.com/?p=3</guid>
		<description><![CDATA[A while ago Second Street Brewery asked for a good stable public wireless internet connection. Of course, the solution was obvious, openwrt on a linksys wrt54gl. The office, point of sale and public networks all share the same gateway. The problem was segregating the public wireless network from the private office lan. Sam (http://thepromisedlan.org) and <a href='http://jasonschaefer.com/archives/3' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>A while ago Second Street Brewery asked for a good stable public wireless internet connection. Of course, the solution was obvious, openwrt on a linksys wrt54gl. The office, point of sale and public networks all share the same gateway. The problem was segregating the public wireless network from the private office lan. Sam (<a href="http://thepromisedlan.org">http://thepromisedlan.org</a>) and I set out to setup a firewall to protect them. This is what we came up with:</p>
<p>check if the following is in /etc/config/firewall otherwise, add it</p>
<pre class="brush: plain">
config include
option path /etc/firewall.user
</pre>
<p>and in /etc/firewall.user we put:</p>
<pre class="brush: plain">
#Insert this into the chain, so 10.1.10.0/24 (office) can connect to public 192.168.10.0/24.
#This rule gets repeated by the setup script /etc/init.d/firewall.
iptables -I FORWARD 1 -m state --state RELATED,ESTABLISHED -j ACCEPT

#block all traffic to any possible private network address (10.*.*.*, 172.16-32.*.*, 192.168.*.*)
iptables -I FORWARD 2 -d 192.168.0.0/16 -j DROP
iptables -I FORWARD 2 -d 172.16.0.0/12 -j DROP
iptables -I FORWARD 2 -d 10.0.0.0/8 -j DROP
</pre>
<p>If you would like to have remote administration on the openwrt so you can access the luci web interface and ssh from the wan side of the router, you can change /etc/config/firewall wan zone to allow it. !!WARNING!! If you are directly connected to the internet, this will expose your open ports to the world. You should take precautions to secure them before changing this firewall rule.</p>
<pre class="brush: plain">
config 'zone'
option 'name' 'wan'
option 'input' 'REJECT' #<- change this to ACCEPT
option 'output' 'ACCEPT'
option 'forward' 'REJECT'
option 'masq' '1'
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jasonschaefer.com/archives/3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

