<?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>James&#039; Tools and Tricks</title>
	<atom:link href="http://jrudd.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://jrudd.org</link>
	<description>Tools, Tips and Hints for managing a network.</description>
	<lastBuildDate>Sat, 27 Apr 2013 11:22:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Moodle Assignment Editor showing HTML instead of GUI editor</title>
		<link>http://jrudd.org/2012/06/moodle-assignment-editor-showing-html-instead-of-gui-editor/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=moodle-assignment-editor-showing-html-instead-of-gui-editor</link>
		<comments>http://jrudd.org/2012/06/moodle-assignment-editor-showing-html-instead-of-gui-editor/#comments</comments>
		<pubDate>Fri, 22 Jun 2012 02:49:37 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Moodle]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=386</guid>
		<description><![CDATA[Recently one of teachers noticed that some Assignments that had been copied between courses would show the assignment introduction as a plaint ext box with html markup visible. I tracked this down to Moodle recording the wrong format for the intro. To fix all &#8230; <a href="http://jrudd.org/2012/06/moodle-assignment-editor-showing-html-instead-of-gui-editor/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently one of teachers noticed that some Assignments that had been copied between courses would show the assignment introduction as a plaint ext box with html markup visible.</p>
<p>I tracked this down to Moodle recording the wrong format for the intro. To fix all instances of this in the database I ran the following query:</p>
<pre class="brush: sql; title: ; notranslate">UPDATE `mdl_assignment`
SET `introformat` = 1
WHERE `introformat` = 0 AND `intro` like '%&lt;p%'
</pre>
<p>This updated the format for the 1400 or so assignments that had been copied and had this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2012/06/moodle-assignment-editor-showing-html-instead-of-gui-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPMI Configuration on Rocks Cluster</title>
		<link>http://jrudd.org/2012/03/ipmi-configuration-on-rocks-cluster/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ipmi-configuration-on-rocks-cluster</link>
		<comments>http://jrudd.org/2012/03/ipmi-configuration-on-rocks-cluster/#comments</comments>
		<pubDate>Sun, 11 Mar 2012 01:51:08 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Intelligent Platform Management Interface]]></category>
		<category><![CDATA[ipmi]]></category>
		<category><![CDATA[ipmitool]]></category>
		<category><![CDATA[rocks]]></category>
		<category><![CDATA[Rocks Cluster]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=350</guid>
		<description><![CDATA[The following is a step by step guide on setting up IPMI management on a Rocks Cluster. It is based on several great posts on Rocks Mailing list and Rocks userguide presentation Update: On Rocks Mailing list Philip Papadopoulos mentioned &#8230; <a href="http://jrudd.org/2012/03/ipmi-configuration-on-rocks-cluster/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The following is a step by step guide on setting up IPMI management on a Rocks Cluster. It is based on several great posts on Rocks Mailing list and Rocks userguide <a href="http://git.rocksclusters.org/git/core/base/src/usersguide/advanced/ipmi.sgml">presentation </a></p>
<p>Update: On <a href="https://groups.google.com/d/msg/rocks-clusters/Vx8YqVaRpXI/scIUBPcnzJ4J">Rocks Mailing list</a> Philip Papadopoulos mentioned a <a href="http://git.rocksclusters.org/cgi-bin/gitweb.cgi?p=triton/scar/.git;a=blob;f=src/root-scripts/sbin/addInterface;h=d07652082875e986816467e73f511773d7f7116c;hb=e2497feb8e350a28042436408fb95ea974c8cb40">Python Script</a> that will automatically add IPMI interface by matching the last 2 octets to that of node: <a href="http://git.rocksclusters.org/cgi-bin/gitweb.cgi?p=triton/scar/.git;a=blob;f=src/root-scripts/sbin/addInterface;h=d07652082875e986816467e73f511773d7f7116c;hb=e2497feb8e350a28042436408fb95ea974c8cb40">Script</a></p>
<h2>1. Create the IPMI Network</h2>
<pre class="brush: plain; title: ; notranslate">rocks add network ipmi subnet=10.2.0.0 netmask=255.255.0.0 servedns=true</pre>
<h2>2. Add access on head node</h2>
<p>The IPMI network is sharing the same vlan as data, so I will multihome the Frontend with a second IP on IPMI subnet</p>
<p>This adds it to Rocks config, but it appears to have no effect so I also ran it manually</p>
<pre class="brush: plain; title: ; notranslate">rocks add host interface localhost iface=eth0:1 ip=10.2.1.1 subnet=ipmi name=ipmi-frontend</pre>
<p>Manually:</p>
<pre class="brush: plain; title: ; notranslate">ifcfg eth0:1 add 10.2.1.1/16</pre>
<p>Add a script to make it start at reboot</p>
<p>Just copy /etc/sysconfig/network-scripts/ifcfg-eth0 to ifcfg-eth0:1 and change the device and IP address.</p>
<pre class="brush: plain; title: ; notranslate">DEVICE=eth0:1
HWADDR=00:xx:xx:xx:xx:xx
IPADDR=10.2.1.1
NETMASK=255.255.0.0
BOOTPROTO=static
ONBOOT=yes
MTU=1500</pre>
<h2>3. Set Password for IPMI</h2>
<p>You can set a custom password for the IPMI system or use the default of admin</p>
<pre class="brush: plain; title: ; notranslate">rocks set attr ipmi_password &quot;password&quot; shadow=yes</pre>
<h2>4. Add IPMI info for each node</h2>
<p>Updated way:<br />
Download the latest <a href="http://git.rocksclusters.org/cgi-bin/gitweb.cgi?p=triton/scar/.git;a=blob;f=src/root-scripts/sbin/addInterface">addInterface</a> and <a href="http://git.rocksclusters.org/cgi-bin/gitweb.cgi?p=triton/scar/.git;a=blob;f=src/root-scripts/lib/ScarScript.py">ScarScript.py</a> and run the following to add matching IP for each node.<br />
If you are running Rocks 6.0/6.1 addInterface will not work for nodes whose card is not card eth0 (e.g. instead is em1). To fix this change line 67 to
<pre class="brush: plain; title: ; notranslate">&quot;rocks list host interface %s | grep 'private ' | awk ' {print $4}'&quot; %</pre>
<pre class="brush: plain; title: ; notranslate">
for n in {0..6}; do
./addInterface compute-0-$n ipmi ipmi ipmi-0-$n
rocks set host interface channel compute-0-$n iface=ipmi channel=1;
done</pre>
<p>Old Way:</p>
<pre class="brush: plain; title: ; notranslate">node=0
for n in {254..245}; do
rocks add host interface compute-0-$node iface=ipmi ip=10.2.255.$n \
module=1 subnet=ipmi name=ipmi-0-$node;
rocks set host interface channel compute-0-$node iface=ipmi channel=1;
let node=$node+1;
done</pre>
<p>Sync it</p>
<pre class="brush: plain; title: ; notranslate">rocks sync host network</pre>
<p>If you have every had DRAC set to use DHCP it needs to be set to static.</p>
<pre class="brush: plain; title: ; notranslate">rocks run host &quot;ipmitool lan set 1 ipsrc static&quot; collate=yes</pre>
<p>I also wanted to set the default gateway which is not set by the generated script and it will complain about network config if not set.</p>
<pre class="brush: plain; title: ; notranslate">rocks run host &quot;ipmitool lan set 1 defgw ipaddr 10.2.1.1&quot; collate=yes</pre>
<h2>5. IPMI root Password</h2>
<p>When I tried to connect using ipmitool and set password it reported NULL account disabled. To get around this is used the root account (id=2) and set a password for this.</p>
<pre class="brush: plain; title: ; notranslate">rocks run host &quot;ipmitool user set password 2 &lt;password&gt;&quot;</pre>
<h2>6. Run the generated script on each node</h2>
<pre class="brush: plain; title: ; notranslate">rocks run host &quot;sh /etc/sysconfig/ipmi&quot;
</pre>
<h2>7. Testing</h2>
<p>ipmitool -I lan -H ipmi-0-0.ipmi -U root -P &lt;password&gt; chassis status</p>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2012/03/ipmi-configuration-on-rocks-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compilation notes for Rocks cluster</title>
		<link>http://jrudd.org/2011/12/compilation-notes-for-rocks-cluster/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=compilation-notes-for-rocks-cluster</link>
		<comments>http://jrudd.org/2011/12/compilation-notes-for-rocks-cluster/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 01:50:49 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[BLAS]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[CPP]]></category>
		<category><![CDATA[espresso]]></category>
		<category><![CDATA[FFTW]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[openmpi]]></category>
		<category><![CDATA[rocks]]></category>
		<category><![CDATA[VASP]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=296</guid>
		<description><![CDATA[This post is more to assist me when upgrading software on our Rocks cluster, but may be useful to others who are compiling similar software. Our cluster only has AMD nodes so we use PGI compilers. Also the backbone is &#8230; <a href="http://jrudd.org/2011/12/compilation-notes-for-rocks-cluster/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This post is more to assist me when upgrading software on our <a href="http://www.rocksclusters.org">Rocks cluster</a>, but may be useful to others who are compiling similar software. Our cluster only has AMD nodes so we use PGI compilers. Also the backbone is only 1Gb/s so I don&#8217;t need to enable any IB options for OpenMPI. I use <a href="http://modules.sourceforge.net/">Modules</a> as a contrib module with a compute-node.xml file to add a /share/apps/modulefiles path to the local config. I have copies of my <a href="https://github.com/ruddj/UNSW-Rocks-Config/tree/master/modulefiles">ModuleFiles </a>synced with Git <a href="https://github.com/ruddj/UNSW-Rocks-Config/tree/master/modulefiles">here</a>.</p>
<p>Also because our head node where compilation occurs uses a AMD Barcelona CPU and the work nodes use an older model I need to add a CFLAG of -tp k8-64</p>
<h2>PGI Compilers</h2>
<p>PGI have some info on common compilation optimisation at <a href="http://www.pgroup.com/support/compile.htm" target="_blank">PGI Compilation</a></p>
<ol>
<li>Download from <a href="http://www.pgroup.com/support/downloads.php">Portland Group</a> and save to ~/install/pgi. To download over SSH I use <a href="https://secure.wikimedia.org/wikipedia/en/wiki/ELinks">elinks</a> as these can be left open in a disconnected screen session</li>
<li>Create a new directory and tar xzvf from there as it is a messy tar</li>
<li>Root: run ./install &#8211; 1. Single System Install</li>
<li>install dir: /share/apps/opt/pgi</li>
<li>add ACML, CUDA</li>
<li>update 2011 links</li>
<li>MPICH1, ssh</li>
<li>License keys, /share/apps/opt/pgi/license.dat</li>
<li>Copy an existing /share/apps/modulefiles/pgi version and update it for new version. Also update .version to new version.</li>
</ol>
<h2>OpenMPI</h2>
<ol>
<li>Download latest from <a href="http://www.open-mpi.org/">OpenMPI</a> and extract in ~/install/openmpi with tar xjvf</li>
<li>mkdir build;cd build</li>
<li>module load pgi</li>
<li>configure with
<pre class="brush: plain; title: ; notranslate">env CC=pgcc FC=pgfortran F77=pgfortran CXX=pgcpp CFLAGS='-fast -tp=k8-64' FCFLAGS='-fast -tp=k8-64' FFLAGS='-fast -tp=k8-64' CXXFLAGS='-fast -tp=k8-64' \
../configure --prefix=/share/apps/opt/openmpi/1.4.4-pgi-11.10 --with-gnu-ld --with-sge --enable-static \
--without-openib --disable-openib-ibcm --disable-ipv6 --disable-openib-connectx-xrc --disable-openib-rdmacm --disable-io-romio</pre>
<p>Compiling with Torque on Ethernet Cluster</p>
<pre class="brush: plain; title: ; notranslate">
export MYINSTALLDIR=/share/apps/mpi/openmpi/1.6.4-pgi-13.04
export CC=pgcc
export CXX=pgcpp
export F77=pgfortran
export FC=${F77}
export CFLAGS='-tp=bulldozer-64,barcelona-64,nehalem-64'
export CXXFLAGS=${CFLAGS}
export FFLAGS=${CFLAGS}
export FCFLAGS=${FFLAGS}
 
../configure \
--prefix=${MYINSTALLDIR} \
--without-openib \
--with-tm=/opt/torque \
--disable-ipv6 \
--enable-static \
--with-gnu-ld \
--disable-io-romio \
2&gt;&amp;1 | tee configure-`date +%y%m%d-%H%M`.log</pre>
</li>
<li>make -j 8</li>
<li>make check</li>
<li>root: module load pgi; make install</li>
<li>Copy an existing /share/apps/modulefiles/openmpi/ version and update it for new version. Also update .version to new version and recreate symlink.</li>
</ol>
<h2>MPICH2</h2>
<p>These instructions are for PGI and Torque</p>
<ol>
<li>Download latest <a href="http://www.mcs.anl.gov/research/projects/mpich2/">MPICH2</a> and extract</li>
<li>module load pgi</li>
<li>Configure with
<pre class="brush: plain; title: ; notranslate">
export MYINSTALLDIR=/share/apps/mpi/mpich2/3.0.3-pgi-13.04
export CC=pgcc
export CXX=pgcpp
export F77=pgfortran
export FC=pgf90
unset F90
export CFLAGS='-tp=bulldozer-64,barcelona-64,nehalem-64'
export CXXFLAGS=${CFLAGS}
export FFLAGS=${CFLAGS}
export FCFLAGS=${FFLAGS}
unset F90FLAGS
./configure --prefix=${MYINSTALLDIR}  \
--with-pbs=/opt/torque \
2&gt;&amp;1 | tee configure-`date +%y%m%d-%H%M`.log</pre>
</li>
<li>make -j 40</li>
<li>root: module load pgi; make install; make install-examples</li>
<li>Copy an existing /share/apps/modulefiles/mpich2/ version and update it for new version.</li>
</ol>
<h2>FFTW3</h2>
<ol>
<li>Download latest stable from http://www.fftw.org/download.html</li>
<li>module load pgi openmpi</li>
<li>
<pre class="brush: plain; title: ; notranslate">
./configure --enable-openmp --enable-mpi --prefix=/share/apps/opt/fftw/3.3.3-pgi-13.04 \
CFLAGS=&quot;-O3 -fastsse -Mvect=sse -tp=k8-64e,bulldozer-64&quot; F90=pgf90 CC=pgcc FC=pgfortran F77=pgfortran CXX=pgcp
</pre>
</li>
<li>make -j 8</li>
<li>root: make install</li>
<li>Copy an existing /share/apps/modules/other/fftw version and update it for new version. Also update .version to new version.</li>
</ol>
<h2>OpenBLAS</h2>
<p>This replaces GotoBLAS2 as the BLAS library as Goto is no longer maintained.</p>
<p>To keep source up to date I use a GIT mirror, created with <em>git clone git://github.com/xianyi/OpenBLAS</em> I have also modified Makefile.rule and committed it to local mirror. In Makefile.rule I also needed to set architecture as head node is slightly different to compute nodes</p>
<ol>
<li><em>cd ~/install/openblas/OpenBLAS</em></li>
<li><em>git pull</em> to update source</li>
<li>module load pgi</li>
<li>make</li>
<li>root: make install PREFIX=/share/apps/opt/OpenBLAS/0.1-pgi-11.10</li>
<li>Copy an existing /share/apps/modulefiles/openblas version and update it for new version. Also update .version to new version.</li>
</ol>
<h2>VASP</h2>
<p>Download latest version from VASP FTP server</p>
<h3>VASP Lib</h3>
<p>Vasp uses a shared library that is common across multiple versions. This only needs to be compiled once, and the makefile does not need any modification. I added a -tp k8-64 to FFLAGS and a clean section but they are not required.</p>
<ol>
<li>extract vasp.5.lib for a new install and cd vasp.5.lib</li>
<li>module load pgi</li>
<li>make</li>
</ol>
<h3>VASP Executable</h3>
<p>The VASP executable makefile has 2 sections for a standalone run time and an MPI runtime. In each of these sections you can build a complex versions and a gamma point only version. So if you compile them all there are 4 combinations used. I use the same make file but comment out the MPI section when compiling standalone. Alternatively you can have separate makefiles and latter use make -f filename</p>
<pre class="brush: plain; auto-links: false; collapse: true; light: false; title: vasp makefile; toolbar: true; notranslate">.SUFFIXES: .inc .f .f90 .F
#-----------------------------------------------------------------------
# Makefile for Portland Group F90/HPF compiler release 3.0-1, 3.1
# and release 1.7
# (http://www.pgroup.com/ &amp; ftp://ftp.pgroup.com/x86/, you need
#  to order the HPF/F90 suite)
#  we have found no noticable performance differences between
#  any of the releases, even Athlon or PIII optimisation does
#  not seem to improve performance
#
# The makefile was tested only under Linux on Intel platforms
# (Suse X,X)
#
# it might be required to change some of library pathes, since
# LINUX installation vary a lot
# Hence check ***ALL**** options in this makefile very carefully
#-----------------------------------------------------------------------
#
# Mind that some Linux distributions (Suse 6.1) have a bug in
# libm causing small errors in the error-function (total energy
# is therefore wrong by about 1meV/atom). The recommended
# solution is to update libc.
#
# Mind that some Linux distributions (Suse 6.1) have a bug in
# libm causing small errors in the error-function (total energy
# is therefore wrong by about 1meV/atom). The recommended
# solution is to update libc.
#
# BLAS must be installed on the machine
# there are several options:
# 1) very slow but works:
#   retrieve the lapackage from ftp.netlib.org
#   and compile the blas routines (BLAS/SRC directory)
#   please use g77 or f77 for the compilation. When I tried to
#   use pgf77 or pgf90 for BLAS, VASP hang up when calling
#   ZHEEV  (however this was with lapack 1.1 now I use lapack 2.0)
# 2) most desirable: get an optimized BLAS
#   for a list of optimized BLAS try
#     http://www.kachinatech.com/~hjjou/scilib/opt_blas.html
#
# the two most reliable packages around are presently:
# 3a) Intels own optimised BLAS (PIII, P4, Itanium)
#     http://developer.intel.com/software/products/mkl/
#   this is really excellent when you use Intel CPU's
#
# 3b) or obtain the atlas based BLAS routines
#     http://math-atlas.sourceforge.net/
#   you certainly need atlas on the Athlon, since the  mkl
#   routines are not optimal on the Athlon.
#
#-----------------------------------------------------------------------

# all CPP processed fortran files have the extension .f
SUFFIX=.f

#-----------------------------------------------------------------------
# fortran compiler and linker
#-----------------------------------------------------------------------
FC=pgf90
# fortran linker
FCL=$(FC)

#-----------------------------------------------------------------------
# whereis CPP ?? (I need CPP, can't use gcc with proper options)
# that's the location of gcc for SUSE 5.3
#

CPP_ =  ./preprocess $*$(SUFFIX)

#-----------------------------------------------------------------------
# possible options for CPP:
# possible options for CPP:
# NGXhalf             charge density   reduced in X direction
# wNGXhalf            gamma point only reduced in X direction
# avoidalloc          avoid ALLOCATE if possible
# IFC                 work around some IFC bugs
# CACHE_SIZE          1000 for PII,PIII, 5000 for Athlon, 8000 P4
# RPROMU_DGEMV        use DGEMV instead of DGEMM in RPRO (usually  faster)
# RACCMU_DGEMV        use DGEMV instead of DGEMM in RACC (faster on P4)
#  **** definitely use -DRACCMU_DGEMV if you use the mkl library
#-----------------------------------------------------------------------

CPP    = $(CPP_) -DHOST=\&quot;LinuxPgi\&quot; \
          -DNGXhalf -DCACHE_SIZE=2000 -DPGF90 -Davoidalloc \
          -DRPROMU_DGEMV  \
#		  -DwNGXhalf

#-----------------------------------------------------------------------
# general fortran flags  (there must a trailing blank on this line)
# the -Mx,119,0x200000 is required if you use older pgf90 versions
# on a more recent LINUX installation
# the option will not do any harm on other 3.X pgf90 distributions
#-----------------------------------------------------------------------

#FFLAGS =  -Mfree -Mx,119,0x200000  -tp k8-64 -I/share/apps/opt/fftw/3.3.0-pgi-11.10/include
#Need k8-64 to allow it to run on older Opertons
#FFLAGS =  -Mfree  -tp k8-64,barcelona-64   # doubles exec size (36M-&gt;50M)
FFLAGS =  -Mfree  -tp k8-64

#-----------------------------------------------------------------------
# optimization,
# we have tested whether higher optimisation improves
# the performance, and found no improvements with -O3-5 or -fast
# (even on Athlon system, Athlon specific optimistation worsens performance)
#-----------------------------------------------------------------------

#OFLAG  = -O0 -g -DDEBUG
#OFLAG = -O3 -fastsse
OFLAG = -O2  -fastsse

#OFLAG_HIGH = $(OFLAG)
OFLAG_HIGH = -O3
OBJ_HIGH = nonlr.o nonl.o

OFLAG_LOW = -O1
OBJ_LOW = broyden.o

OBJ_NOOPT =
#DEBUG  = -g -O0
DEBUG  = -O0
INLINE = $(OFLAG)

#-----------------------------------------------------------------------
# the following lines specify the position of BLAS  and LAPACK
# what you chose is very system dependent
# P4: VASP works fastest with Intels mkl performance library
# Athlon: Atlas based BLAS are presently the fastest
# P3: no clue
#-----------------------------------------------------------------------

#BLAS=   -lacml
# Following allows linking with modules
#BLAS=  -lopenblas -L/share/apps/opt/OpenBLAS/0.1-pgi-11.10/lib
# Hard code link
BLAS=  /share/apps/opt/OpenBLAS/0.1-pgi-11.10/lib/libopenblas.a
# use specific libraries (default library path points to other libraries)

# use the mkl Intel libraries for p4 (www.intel.com)
#BLAS=-L/opt/intel/mkl/lib/32 -lmkl_p4  -lpthread

# LAPACK, simplest use vasp.5.lib/lapack_double
#LAPACK= ../vasp.5.lib/lapack_double.o

# use atlas optimized part of lapack
#LAPACK= ../vasp.5.lib/lapack_atlas.o  -llapack -lblas -lacml
#LAPACK= ../vasp.5.lib/lapack_atlas.o  -llapack -lacml
#LAPACK= ../vasp.5.lib/lapack_atlas.o

# use the mkl Intel lapack
#LAPACK= -lmkl_lapack

#-----------------------------------------------------------------------

LIB  = -L../vasp.5.lib -ldmy \
     ../vasp.5.lib/linpack_double.o $(LAPACK) \
     $(BLAS) -lfftw3 -L/share/apps/opt/fftw/3.3.0-pgi-11.10/lib

# options for linking (none required)
#LINK    =  -tp k8-64

#-----------------------------------------------------------------------
# fft libraries:
# VASP.4.5 can use FFTW (http://www.fftw.org)
# since the FFTW is very slow for radices 2^n the fft3dlib is used
# in these cases
# if you use fftw3d you need to insert -lfftw in the LIB line as well
# please do not send us any querries reltated to FFTW (no support)
# if it fails, use fft3dlib
#-----------------------------------------------------------------------

FFT3D   = fft3dfurth.o fft3dlib.o  /share/apps/opt/fftw/3.3.0-pgi-11.10/lib/libfftw3.a
#FFT3D   = fftw3d+furth.o fft3dlib.o

#=======================================================================
# MPI section, uncomment the following lines
#
# one comment for users of mpich or lam:
# You must *not* compile mpi with g77/f77, because f77/g77
# appends *two* underscores to symbols that contain already an
# underscore (i.e. MPI_SEND becomes mpi_send__).  The pgf90
# compiler however appends only one underscore.
# Precompiled mpi version will also not work !!!
#
# We found that mpich.1.2.1 and lam-6.5.X are stable
# mpich.1.2.1 was configured with
#  ./configure -prefix=/usr/local/mpich_nodvdbg -fc=&quot;pgf77 -Mx,119,0x200000&quot;  \
# -f90=&quot;pgf90 -Mx,119,0x200000&quot; \
# --without-romio --without-mpe -opt=-O \
#
# lam was configured with the line
#  ./configure  -prefix /usr/local/lam-6.5.X --with-cflags=-O -with-fc=pgf90 \
# --with-f77flags=-O --without-romio
#
# lam was generally faster and we found an average communication
# band with of roughly 160 MBit/s (full duplex)
#
# please note that you might be able to use a lam or mpich version
# compiled with f77/g77, but then you need to add the following
# options: -Msecond_underscore (compilation) and -g77libs (linking)
#
# !!! Please do not send me any queries on how to install MPI, I will
# certainly not answer them !!!!
#=======================================================================
#-----------------------------------------------------------------------
# fortran linker for mpi: if you use LAM and compiled it with the options
# suggested above,  you can use the following lines
#-----------------------------------------------------------------------

FC=mpif90
FCL=$(FC)

#-----------------------------------------------------------------------
# additional options for CPP in parallel version (see also above):
# NGZhalf               charge density   reduced in Z direction
# wNGZhalf              gamma point only reduced in Z direction
# scaLAPACK             use scaLAPACK (usually slower on 100 Mbit Net)
#-----------------------------------------------------------------------

CPP    = $(CPP_) -DMPI  -DHOST=\&quot;LinuxPgi\&quot; \
     -DNGZhalf -DCACHE_SIZE=2000 -DPGF90 -Davoidalloc -DRPROMU_DGEMV \
#     -DwNGZhalf \

#-----------------------------------------------------------------------
# location of SCALAPACK
# if you do not use SCALAPACK simply uncomment the line SCA
#-----------------------------------------------------------------------

SCA=

#-----------------------------------------------------------------------
# libraries for mpi
#-----------------------------------------------------------------------

LIB     = -L../vasp.5.lib -ldmy  \
      ../vasp.5.lib/linpack_double.o $(LAPACK) \
      $(SCA) $(BLAS) -L/share/apps/opt/fftw/3.3.0-pgi-11.10/lib -lfftw3 -lfftw3_mpi

# FFT: only option  fftmpi.o with fft3dlib of Juergen Furthmueller

FFT3D   = fftmpi.o fftmpi_map.o fft3dfurth.o fft3dlib.o

#-----------------------------------------------------------------------
# general rules and compile lines
#-----------------------------------------------------------------------
BASIC=   symmetry.o symlib.o   lattlib.o  random.o

SOURCE=  base.o     mpi.o      smart_allocate.o      xml.o  \
         constant.o jacobi.o   main_mpi.o  scala.o   \
         asa.o      lattice.o  poscar.o   ini.o  mgrid.o  xclib.o  vdw_nl.o  xclib_grad.o \
         radial.o   pseudo.o   gridq.o     ebs.o  \
         mkpoints.o wave.o     wave_mpi.o  wave_high.o  \
         $(BASIC)   nonl.o     nonlr.o    nonl_high.o dfast.o    choleski2.o \
         mix.o      hamil.o    xcgrad.o   xcspin.o    potex1.o   potex2.o  \
         constrmag.o cl_shift.o relativistic.o LDApU.o \
         paw_base.o metagga.o  egrad.o    pawsym.o   pawfock.o  pawlhf.o   rhfatm.o  paw.o   \
         mkpoints_full.o       charge.o   Lebedev-Laikov.o  stockholder.o dipol.o    pot.o \
         dos.o      elf.o      tet.o      tetweight.o hamil_rot.o \
         steep.o    chain.o    dyna.o     sphpro.o    us.o  core_rel.o \
         aedens.o   wavpre.o   wavpre_noio.o broyden.o \
         dynbr.o    rmm-diis.o reader.o   writer.o   tutor.o xml_writer.o \
         brent.o    stufak.o   fileio.o   opergrid.o stepver.o  \
         chgloc.o   fast_aug.o fock.o     mkpoints_change.o sym_grad.o \
         mymath.o   internals.o dynconstr.o dimer_heyden.o dvvtrajectory.o vdwforcefield.o \
         hamil_high.o nmr.o    pead.o     mlwf.o     subrot.o   subrot_scf.o \
         force.o    pwlhf.o  gw_model.o optreal.o   davidson.o  david_inner.o \
         electron.o rot.o  electron_all.o shm.o    pardens.o  paircorrection.o \
         optics.o   constr_cell_relax.o   stm.o    finite_diff.o elpol.o    \
         hamil_lr.o rmm-diis_lr.o  subrot_cluster.o subrot_lr.o \
         lr_helper.o hamil_lrf.o   elinear_response.o ilinear_response.o \
         linear_optics.o linear_response.o   \
         setlocalpp.o  wannier.o electron_OEP.o electron_lhf.o twoelectron4o.o \
         ratpol.o screened_2e.o wave_cacher.o chi_base.o wpot.o local_field.o \
         ump2.o bse_te.o bse.o acfdt.o chi.o sydmat.o dmft.o \
         rmm-diis_mlr.o  linear_response_NMR.o

vasp: $(SOURCE) $(FFT3D) $(INC) main.o
	rm -f vasp
	$(FCL) -o vasp main.o  $(SOURCE)   $(FFT3D) $(LIB) $(LINK)
makeparam: $(SOURCE) $(FFT3D) makeparam.o main.F $(INC)
	$(FCL) -o makeparam  $(LINK) makeparam.o $(SOURCE) $(FFT3D) $(LIB)
zgemmtest: zgemmtest.o base.o random.o $(INC)
	$(FCL) -o zgemmtest $(LINK) zgemmtest.o random.o base.o $(LIB)
dgemmtest: dgemmtest.o base.o random.o $(INC)
	$(FCL) -o dgemmtest $(LINK) dgemmtest.o random.o base.o $(LIB)
ffttest: base.o smart_allocate.o mpi.o mgrid.o random.o ffttest.o $(FFT3D) $(INC)
	$(FCL) -o ffttest $(LINK) ffttest.o mpi.o mgrid.o random.o smart_allocate.o base.o $(FFT3D) $(LIB)
kpoints: $(SOURCE) $(FFT3D) makekpoints.o main.F $(INC)
	$(FCL) -o kpoints $(LINK) makekpoints.o $(SOURCE) $(FFT3D) $(LIB)

clean:
	-rm -f *.g *.f *.o *.L *.mod vasp ; touch *.F

main.o: main$(SUFFIX)
	$(FC) $(FFLAGS)$(DEBUG)  $(INCS) -c main$(SUFFIX)
xcgrad.o: xcgrad$(SUFFIX)
	$(FC) $(FFLAGS) $(INLINE)  $(INCS) -c xcgrad$(SUFFIX)
xcspin.o: xcspin$(SUFFIX)
	$(FC) $(FFLAGS) $(INLINE)  $(INCS) -c xcspin$(SUFFIX)

makeparam.o: makeparam$(SUFFIX)
	$(FC) $(FFLAGS)$(DEBUG)  $(INCS) -c makeparam$(SUFFIX)

makeparam$(SUFFIX): makeparam.F main.F
#
# MIND: I do not have a full dependency list for the include
# and MODULES: here are only the minimal basic dependencies
# if one strucuture is changed then touch_dep must be called
# with the corresponding name of the structure
#
base.o: base.inc base.F
mgrid.o: mgrid.inc mgrid.F
constant.o: constant.inc constant.F
lattice.o: lattice.inc lattice.F
setex.o: setexm.inc setex.F
pseudo.o: pseudo.inc pseudo.F
poscar.o: poscar.inc poscar.F
mkpoints.o: mkpoints.inc mkpoints.F
wave.o: wave.F
nonl.o: nonl.inc nonl.F
nonlr.o: nonlr.inc nonlr.F

$(OBJ_HIGH):
	$(CPP)
	$(FC) $(FFLAGS) $(OFLAG_HIGH) $(INCS) -c $*$(SUFFIX)

$(OBJ_LOW):
	$(CPP)
	$(FC) $(FFLAGS) $(OFLAG_LOW) $(INCS) -c $*$(SUFFIX)

$(OBJ_NOOPT):
	$(CPP)
	$(FC) $(FFLAGS) $(INCS) -c $*$(SUFFIX)

fft3dlib_f77.o: fft3dlib_f77.F
	$(CPP)
	$(F77) $(FFLAGS_F77) -c $*$(SUFFIX)

.F.o:
	$(CPP)
	$(FC) $(FFLAGS) $(OFLAG) $(INCS) -c $*$(SUFFIX)
.F$(SUFFIX):
	$(CPP)
$(SUFFIX).o:
	$(FC) $(FFLAGS) $(OFLAG) $(INCS) -c $*$(SUFFIX)

</pre>
<ol>
<li>extract vasp.5.2.12 for the current version</li>
<li>module load pgi openmpi openblas fftw</li>
<li>Add makefile above or customise your own</li>
<li>In makefile correct paths for libraries and features to enable.</li>
<li>make</li>
<li>Copy the compiled vasp executable to destination. I use vasp and vasp.g for gamma point.</li>
</ol>
<h4>Gamma Point</h4>
<ol>
<li>Use same makefile as above but add -DwNGXhalf to CPP options</li>
</ol>
<h2>Quantum Espresso</h2>
<ol>
<li>Download latest version from <a href="http://www.quantum-espresso.org/download.php" target="_blank">http://www.quantum-espresso.org/download.php</a> as well as the examples</li>
<li>tar xzvf both the src and examples. They end up in same directory</li>
<li>module load pgi openmpi openblas fftw3</li>
<li>
<pre class="brush: plain; title: ; notranslate">./configure F90=pgf90 FC=pgf90 F77=pgf77 CC=pgcc MPIF90=mpif90 \
FFLAGS=&quot;-fast -O2 -tp=k8-64e,bulldozer-64&quot; CFLAGS=&quot;-fast -O3 -tp k8-64e,bulldozer-64&quot; \
FFT_LIBS=&quot;-L/share/apps/opt/fftw/3.3.3-pgi-13.04/lib -lfftw3 -lfftw3_mpi&quot; \
BLAS_LIBS=&quot;-L/share/apps/opt/OpenBLAS/0.2.6-pgi-13.04/lib -lopenblas&quot; \
LAPACK_LIBS=&quot;-L/share/apps/opt/OpenBLAS/0.2.6-pgi-13.04/lib -lopenblas&quot; \
LIBDIRS=&quot;/share/apps/opt/fftw/3.3.3-pgi-13.04/lib /share/apps/opt/OpenBLAS/0.2.6-pgi-13.04/lib&quot;</pre>
</li>
<li>make pw pp -j8</li>
<li>make all -j8</li>
<li>to test: cd examples, modify environment_variables (e.g. tmp dir and mpirun -np ),  ./run_all_examples, then compare example??/results to reference</li>
<li>root: copy entire espresso-4.3.2 directory to /share/apps/opt/espresso/4.3.2/pgi-openmpi</li>
<li>Copy an existing /share/apps/modulefiles/espresso module and update it for new version. Also update .version to new version.</li>
</ol>
<ol>
<li>make -j 8</li>
<li>root: module load pgi; make install</li>
<li>Copy an existing /share/apps/modulefiles/openmpi/ version and update it for new version.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2011/12/compilation-notes-for-rocks-cluster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acrobat X &#8211; Bulk Printing and Custom Header</title>
		<link>http://jrudd.org/2011/10/acrobat-x-bulk-printing-and-custom-header/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=acrobat-x-bulk-printing-and-custom-header</link>
		<comments>http://jrudd.org/2011/10/acrobat-x-bulk-printing-and-custom-header/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 05:14:48 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[action wizard]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>
		<category><![CDATA[bulk PDF]]></category>
		<category><![CDATA[DET]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[pdfs]]></category>
		<category><![CDATA[Printing]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=273</guid>
		<description><![CDATA[Every year we need to print off hundreds of enrolment forms to verify details of new students and current students. Each of these forms is pre-filled with students details and there is a separate PDF for each student. Previously I &#8230; <a href="http://jrudd.org/2011/10/acrobat-x-bulk-printing-and-custom-header/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Every year we need to print off hundreds of enrolment forms to verify details of new students and current students. Each of these forms is pre-filled with students details and there is a separate PDF for each student.</p>
<p>Previously I used <a href="http://www.freewarefiles.com/Multiple-PDF-Printer_program_24346.html">Multiple PDF Printer</a> but this no longer works with Acrobat X. Instead I created an Action Wizard that allows you to select the folder with all the PDFs and it will print them all to your default printer with the default settings.</p>
<p>I then added another step to the action that uses Javascript to extract the student&#8217;s name from the file name and added it as a header to each page of that file. Finally this was modified so that the name is always on the outer edge, when it is printed back to back and stapled on the left.</p>
<p>To create this you can follow the following directions or import the attached action. Note: There is a file embedded within this post, please visit this post to download the file.</p>
<div id="attachment_282" class="wp-caption alignright" style="width: 310px"><a href="http://i0.wp.com/jrudd.org/wp-content/uploads/2011/10/Edit-Action.png" rel="lightbox[273]"><img class="size-medium wp-image-282" title="Acrobat X - Edit Action" src="http://i2.wp.com/jrudd.org/wp-content/uploads/2011/10/Edit-Action.png?resize=300%2C188" alt="" data-recalc-dims="1" /></a><p class="wp-caption-text">Acrobat X - Edit Action</p></div>
<p>In Acrobat X:</p>
<ol>
<li><strong>File</strong> -&gt; <strong>Action Wizard</strong> -&gt; <strong>Create New Action</strong></li>
<li>Click <strong>More Tools</strong> and then click <strong>Execute JavaScript</strong> and then click <strong>Print</strong>.</li>
<li>Change <strong>Start with</strong> to <strong>Ask when Action is Started</strong></li>
<li>Click on the Options button for JavaScript and paste in the following:</li>
</ol>
<pre class="brush: jscript; title: ; notranslate">
var strFilename = this.documentFileName;
// A regular expression to acquire the base name of the file
// Removes everything before last underscore for Ghosted_EnrolmentForm_
var re = /.*\/|.*_|\.pdf$/ig;
// Get student name by stripping path and everything to left of underscore
var strFilename = strFilename.replace(re,&quot;&quot;).replace(&quot;,&quot;,&quot;, &quot;);
var pageAmount = this.numPages; // Finds the length of the PDF

for (i = 0; i 	{
	if (i % 2 == 0) {
		// Odd
		this.addWatermarkFromText({
			cText: strFilename,
			nStart: i,
			nEnd: i,
			nFontSize: 11,
			nTextAlign: app.constants.align.right,
			nHorizAlign: app.constants.align.right,
			nVertAlign: app.constants.align.top,
			nHorizValue: -28, nVertValue: -10
		});
	}	else  {
		// Even
		this.addWatermarkFromText({
			cText: strFilename,
			nStart: i,
			nEnd: i,
			nFontSize: 11,
			nTextAlign: app.constants.align.left,
			nHorizAlign: app.constants.align.left,
			nVertAlign: app.constants.align.top,
			nHorizValue: 28, nVertValue: -10
		});
	}
}</pre>
<ol start="5">
<li>Click <strong>OK</strong>. Then click <strong>Save</strong>and type in a name for the action and a description.
<p><div id="attachment_291" class="wp-caption alignright" style="width: 160px"><a href="http://i2.wp.com/jrudd.org/wp-content/uploads/2011/10/Add-Files.png" rel="lightbox[273]"><img class="size-thumbnail wp-image-291" title="Add Files" src="http://i0.wp.com/jrudd.org/wp-content/uploads/2011/10/Add-Files.png?resize=150%2C150" alt="" data-recalc-dims="1" /></a><p class="wp-caption-text">Add Folders or Files</p></div></li>
<li>Set your default printer and printer settings to how you want your documents to print (e.g. Double sided, Stapled).</li>
<li><strong>File</strong> -&gt; <strong>Action Wizard</strong> -&gt; &lt;Your new action&gt;</li>
<li>Click <strong>Next</strong> on summary screen. You may tick <strong>Don&#8217;t show again</strong> box if you wish.</li>
<li>Click <strong>Add Files&#8230;</strong> drop down and choose<strong> Add Folders&#8230;</strong> and select the folder holding the PDFs.</li>
<li>Click <strong>Next</strong> and it will start adding the header and printing the files.</li>
</ol>
<h3>Useful Links:</h3>
<ul>
<li>Base for the JavaScript header is from Steve Wareham&#8217;s block post on <a href="http://www.stevewareham.com/pdfstamp.php">Adding a Dynamic Stamp to a PDF</a>.</li>
<li>The code to extract file name is from Adobe JavaScript Reference</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2011/10/acrobat-x-bulk-printing-and-custom-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bulk Converting Global Groups to Universal and Mail Enabling</title>
		<link>http://jrudd.org/2011/07/bulk-converting-global-groups-to-universal-and-mail-enabling/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bulk-converting-global-groups-to-universal-and-mail-enabling</link>
		<comments>http://jrudd.org/2011/07/bulk-converting-global-groups-to-universal-and-mail-enabling/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 15:03:48 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[distribution groups]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[exchange]]></category>
		<category><![CDATA[global address book]]></category>
		<category><![CDATA[global groups]]></category>
		<category><![CDATA[Microsoft Exchange Server]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[universal group]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=260</guid>
		<description><![CDATA[We have started trying to better organise our groups into a more role based system, so that membership of one group is based on a role rather than a person. That way if the person holding a position changes (holiday, &#8230; <a href="http://jrudd.org/2011/07/bulk-converting-global-groups-to-universal-and-mail-enabling/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>We have started trying to better organise our groups into a more role based system, so that membership of one group is based on a role rather than a person. That way if the person holding a position changes (holiday, retirement, etc) we just make one change and the replacement user gets all the correct rights. e.g. &lt;user&gt; -&gt; HT Subject -&gt; Executive, rather than &lt;user&gt; -&gt; Executive.</p>
<p>The problem with this is when an email is sent to a mail enabled group, all the member groups of that group must be mail enabled for their members to receive the email. So I needed to bulk mail enable a container of groups, and also hide these new groups from the Address Book as they don&#8217;t need to be visible to staff.</p>
<p>Exchange 2010 only allows you to mail enable a group if it is a Universal group, and then only one at a time from the EMC. To convert all the Global groups in a particular container to universal groups, I used the following Power Shell command.</p>
<pre class="brush: powershell; title: ; notranslate">Import-Module ActiveDirectory
# List Tables
Get-ADGroup -SearchScope Subtree -SearchBase &quot;OU=StaffGroups,OU=Staff,DC=win&quot; -Filter {GroupCategory -eq &quot;Security&quot; -and GroupScope -eq &quot;Global&quot;}  | Format-Table

# Convert Global groups to Universal
Get-ADGroup -SearchScope Subtree -SearchBase &quot;&lt;code&gt;OU=StaffGroups,OU=Staff,DC=win&lt;/code&gt;&quot; -Filter {GroupCategory -eq &quot;Security&quot; -and GroupScope -eq &quot;Global&quot;}  | Set-ADGroup -GroupScope Universal</pre>
<p>Once converted to Universal groups I wanted to Enable the Groups as Distribution groups in Exchange and hide them from the global Address Book. These groups are role based and need to exist for group expansion in Exchange, but I don&#8217;t want them visible to everyone.</p>
<pre class="brush: powershell; title: ; notranslate">
# Load AD Modules
Import-Module ActiveDirectory

# Load Exchange Snapins
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
. $env:ExchangeInstallPath\bin\RemoteExchange.ps1
Connect-ExchangeServer -auto

# Get list of Groups not Mail Enabled
$b = Get-ADGroup -SearchScope Subtree -SearchBase &quot;OU=StaffGroups,OU=Staff,DC=win&quot; -Filter {GroupCategory -eq &quot;Security&quot; -and GroupScope -eq &quot;Universal&quot; -and mail -notlike &quot;*&quot;}

# Enable email for each group, use the Group name without spaces as Alias
$b | ForEach-Object { Enable-DistributionGroup -Identity $_.DistinguishedName -Alias ($_.Name -replace '\s|,|\.') }

# Hide the newly created groups from Global Address book
$b | ForEach-Object { Set-DistributionGroup -Identity $_.DistinguishedName -HiddenFromAddressListsEnabled $true}
 </pre>
<h3>Notes:</h3>
<ul>
<li>Details on replacing letters for alias is from <a title="Removing invalid characters for alias" href="http://www.powershellcommunity.org/Forums/tabid/54/aft/2852/Default.aspx" target="_blank">here</a>.</li>
<li><a title="Managing Exchange 2010 with Remote PowerShell" href="http://www.mikepfeiffer.net/2010/02/managing-exchange-2010-with-remote-powershell/" target="_blank">Mike Pfeiffer&#8217;s blog</a> had great instructions on how to load Exchange snap-ins into a normal PowerShell session, such as in ISE.</li>
<li>I found a few sites that mentioned using get-group instead of get-adgroup. Not sure why the wrong command is given. <a href="http://www.petri.co.il/forums/showthread.php?t=54431">Petri</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2011/07/bulk-converting-global-groups-to-universal-and-mail-enabling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypt Offline Files &#8211; Access Denied</title>
		<link>http://jrudd.org/2011/05/encrypt-offline-files-access-denied/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=encrypt-offline-files-access-denied</link>
		<comments>http://jrudd.org/2011/05/encrypt-offline-files-access-denied/#comments</comments>
		<pubDate>Wed, 18 May 2011 02:56:15 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[offline files]]></category>
		<category><![CDATA[recovery key]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=257</guid>
		<description><![CDATA[On a Windows 7 laptop I was trying to set up Offline Files with encryption enabled. After syncing the files and going into Manage Offline Files -&#62; Encryption -&#62; Encrypt everything seemed to go OK, but it would then keep &#8230; <a href="http://jrudd.org/2011/05/encrypt-offline-files-access-denied/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>On a Windows 7 laptop I was trying to set up Offline Files with encryption enabled. After syncing the files and going into Manage Offline Files -&gt; Encryption -&gt; Encrypt everything seemed to go OK, but it would then keep reporting Access Denied when it tried to sync any new files.<br />
After some searching I found this <a href="http://www.conetrix.com/Blog/post/Access-Denied-Error-Synchronizing-Encrypted-Offline-Files.aspx">post</a> which mentioned an expired Recovery Key in Group Policy. After checking the Group Policy object on the server I discovered there was an old Recovery Key stored in the EFS policy from when it was first set up. After regenerating the key and importing into policy, a gpupdate /force on laptop and reboot fixed the issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2011/05/encrypt-offline-files-access-denied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fuji-Xerox Network Scanning: Error 027-516</title>
		<link>http://jrudd.org/2011/04/fuji-xerox-network-scanning-error-027-516/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fuji-xerox-network-scanning-error-027-516</link>
		<comments>http://jrudd.org/2011/04/fuji-xerox-network-scanning-error-027-516/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 23:55:26 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[ApeosPort-II]]></category>
		<category><![CDATA[ApeosPort-III]]></category>
		<category><![CDATA[fuji xerox]]></category>
		<category><![CDATA[NetBIOS]]></category>
		<category><![CDATA[netbios over tcp ip]]></category>
		<category><![CDATA[Photocopier]]></category>
		<category><![CDATA[smb server]]></category>

		<guid isPermaLink="false">http://jrudd.org/?p=250</guid>
		<description><![CDATA[As part of a test for removing legacy protocols from the network I disabled NetBIOS over TCP/IP to see if any system would be adversely affected. After disabling NetBIOS for the server used by our Fuji-Xeros ApeosPort-II 4000 Photocopier, the &#8230; <a href="http://jrudd.org/2011/04/fuji-xerox-network-scanning-error-027-516/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As part of a test for removing legacy protocols from the network I disabled NetBIOS over TCP/IP to see if any system would be adversely affected.</p>
<div id="attachment_251" class="wp-caption alignleft" style="width: 310px"><a href="http://i1.wp.com/jrudd.org/wp-content/uploads/2011/04/DisableNetBIOS.png" rel="lightbox[250]"><img class="size-medium wp-image-251" title="Disable NetBIOS" src="http://i0.wp.com/jrudd.org/wp-content/uploads/2011/04/DisableNetBIOS.png?resize=300%2C114" alt="" data-recalc-dims="1" /></a><p class="wp-caption-text">Disabled NetBIOS</p></div>
<p>After disabling NetBIOS for the server used by our Fuji-Xeros ApeosPort-II 4000 Photocopier, the Network Scanning feature was unable to upload the scanned file to the SMB server. Instead it would return a 027-516 error code.</p>
<p>To verify the problem I Enabled NetBIOS and it immediately started working again.</p>
<p>I contacted Fuji-Xerox to check if they had a fix for the problem. I was advised that this can only be changed in newer versions, ApeosPort &gt;=3, and that is was considered a &#8220;Feature&#8221;. The only way for an AP-II device to work with a server with NetBIOS disabled is to use the FTP transmit method.</p>
<div id="attachment_252" class="wp-caption alignright" style="width: 310px"><a href="http://i1.wp.com/jrudd.org/wp-content/uploads/2011/04/AP3-MSNetwork.png" rel="lightbox[250]"><img class="size-medium wp-image-252 " title="AP3-MSNetwork" src="http://i0.wp.com/jrudd.org/wp-content/uploads/2011/04/AP3-MSNetwork.png?resize=300%2C179" alt="" data-recalc-dims="1" /></a><p class="wp-caption-text">AP-III NetBIOS Setting</p></div>
<p>After checking on one of our ApeosPort-III C3300, I found the page mentioned that allows the setting to be changed.</p>
<p>It appears that the use of NetBIOS by the APII is hardcoded and although it has DNS settings set, they are ignored for server name resolution. Considering this Photocopier is still being produced and sold I find it interesting that it relies on outdated protocols like NetBIOS. (ApeosPort-II 3000, 4000, 5010, 6000, 7000 are the main black and white photocopiers available to DET NSW Schools)</p>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2011/04/fuji-xerox-network-scanning-error-027-516/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Papercut</title>
		<link>http://jrudd.org/2010/08/papercut/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=papercut</link>
		<comments>http://jrudd.org/2010/08/papercut/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 23:11:23 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Novell]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Papercut]]></category>
		<category><![CDATA[Photocopier]]></category>
		<category><![CDATA[photocopiers]]></category>
		<category><![CDATA[Printer]]></category>
		<category><![CDATA[printer usage]]></category>
		<category><![CDATA[Printing]]></category>
		<category><![CDATA[student laptop]]></category>
		<category><![CDATA[Windows 2008]]></category>
		<category><![CDATA[Windows 2008 R2]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://jrudd.org/wordpress/?p=232</guid>
		<description><![CDATA[I have received a few questions asking about Papercut so here are some of the details about it and what we use it for. Papercut can run on a Windows Server (2003, 2008 or 2008 R2) using windows print queues &#8230; <a href="http://jrudd.org/2010/08/papercut/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://i2.wp.com/jrudd.org/wp-content/uploads/2010/08/Papercut1.png" rel="lightbox[232]"><img class="alignleft size-medium wp-image-242" title="Papercut Accounts" src="http://i2.wp.com/jrudd.org/wp-content/uploads/2010/08/Papercut1.png?resize=294%2C300" alt="" data-recalc-dims="1" /></a>I have received a few questions asking about <a href="http://www.papercut.com">Papercut</a> so here are some of the details about it and what we use it for.</p>
<p>Papercut can run on a Windows Server (2003, 2008 or 2008 R2) using windows print queues or a Novell Linux OES server with <a href="http://www.papercut.com/download/ng/#novell">iPrint</a> (CUPS &amp; SAMBA), it is written in Java with some wrappers for the OS in use.</p>
<p>We originally ran it on a Server 2003 R2 (x86) but have recently updated to a Windows 2008 R2 (x64)print server. The main reason for the upgrade was to provide up to date drivers for Windows 7 32 &amp; 64bit. We also run the <a href="http://www.papercut-mf.com">Papercut MF</a> version which costs A LOT more, but allows you to use it with external devices, such as photocopiers.</p>
<p>Papercut has some really useful features, <a href="http://www.papercut.com/tour/balance-recharge/top-up-cards/">Card recharge</a> allows you to generate top up cards and print them out yourself. Then you just cut them up and given them to the office (or canteen) to sell to the students. Makes recharging much easier and no need for office staff to login to an admin console to top up accounts.</p>
<p>We recently had a student laptop roll-out (NSW DER), these laptops are not on our domain so needed an alternative way to print. Papercut has a feature called <a href="http://www.papercut.com/tour/web-print/">WebPrint </a>which allows students to upload MS office or PDF files to a website and have them printed to the chosen printer. You need to run software for it on a windows pc (server or client) which automatically opens the document and prints it to the chosen printer. As our Print server is running Windows and is a virtual machine we just configured it to auto-login as a limited user we created and installed Office, and Acrobat.</p>
<p>We use the <a href="http://www.papercut.com/tour/reporting-in-detail/">reports</a> function for auditing staff accounts and charging printer usage back to faculties. Staff are automatically added to different charge accounts based on their AD group membership.</p>
<p>We have just started using Advanced Scripting to charge staff different prices than students on shared copiers and printers.<br />
The following script is what we use, as it is based on how faculties are invoiced at the end of each term. It is based on the Papercut recipe &#8220;Discount for staff&#8221; with a few changes.</p>
<pre class="brush: jscript; collapse: true; light: false; title: ; toolbar: true; notranslate">
/*
* Change Pricing for staff
*
* Staff are charged based on cost to school.
*
*/
function printJobHook(inputs, actions) {

var DISCOUNT_GROUP   = &quot;Staff-All&quot;;
var COST_COLOUR  = 0.07; // Click Rate of Colour
var COST_BW  = 0.02;  // Click Rate of B/W
var COST_A4  = 0.01;  // Price per page of A4
var COST_A3  = 0.03;  // Price per page of A3

/*
* This print hook will need access to all job details
* so return if full job analysis is not yet complete.
* The only job details that are available before analysis
* are metadata such as username, printer name, and date.
*
* See reference documentation for full explanation.
*/

if (!inputs.job.isAnalysisComplete) {
	// No job details yet so return.
	return;
}

if (inputs.user.isInGroup(DISCOUNT_GROUP)) {
	// Debug messages are written to [install-path]/server/logs/server.log
	actions.log.debug(&quot;Cost before discount: &quot; + inputs.job.cost);

	// Initial 0
	var newCost = 0;

	// Includes Duplex
	if (inputs.job.paperSizeName == &quot;A4&quot;) {
		newCost = inputs.job.totalSheets * COST_A4;
	}
	else {
		newCost = inputs.job.totalSheets * COST_A3 ;
	}

	newCost += inputs.job.totalGrayscalePages * COST_BW;
	newCost += inputs.job.totalColorPages * COST_COLOUR;

	 actions.job.setCost(newCost);

	actions.log.debug(&quot;Staff Pricing on &quot; + inputs.job.printerName + &quot; For &quot; + inputs.job.totalSheets +
		&quot; sheets had &quot; + inputs.job.totalGrayscalePages + &quot; B/W &amp; &quot; +
		inputs.job.totalColorPages + &quot; Colour, Cost after discount: &quot; + newCost);

	// Record that as discount was applied in the job comment.
	actions.job.addComment(&quot;Staff Pricing applied. Had &quot; + inputs.job.totalGrayscalePages + &quot; B/W &amp; &quot; +
	inputs.job.totalColorPages + &quot; Colour&quot;);
	}
}

</pre>
<p>Other useful features:</p>
<ul>
<li>Students and staff see a summary of how many pages they are going to print, which helps reduce accidental printing of entire chapters of text instead of just a few pages.</li>
<li>Logs and statistics show which printers are getting used, how much is getting printed, and who printed the document but didn&#8217;t collect it.</li>
<li>Great support. I have contacted them over a number of issues and they have always gotten back quickly with good ideas, or have added features in later versions.</li>
</ul>
<p>Downsides:</p>
<ul>
<li>Although the price for education version of <a href="http://www.papercut.com/pricing/education/">Papercut NG </a>is not too bad, to get the MF version which supports copiers it costs around twice as much. Also you then need cost recovery devices for the copiers ~AUD$1,800 each, and there are annual support and maintenance costs ~AUD$1,000/year.</li>
</ul>
<p>If you want to get an idea of how much printing your staff and students or just want to keep a record of who is printing what (like you could do easily with iPrint)  try the free <a href="http://www.papercut.com/products/free_software/print_logger/">Papercut Print Logger</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2010/08/papercut/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pre-populate Users names and email address in Office and Acrobat</title>
		<link>http://jrudd.org/2010/07/pre-populate-users-names-and-email-address-in-office-and-acrobat/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pre-populate-users-names-and-email-address-in-office-and-acrobat</link>
		<comments>http://jrudd.org/2010/07/pre-populate-users-names-and-email-address-in-office-and-acrobat/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 07:01:58 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Adobe Acrobat]]></category>
		<category><![CDATA[adobe acrobat reader]]></category>
		<category><![CDATA[Microsoft Office]]></category>
		<category><![CDATA[simple vbscript]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[Windows Registry]]></category>

		<guid isPermaLink="false">http://jrudd.org/wordpress/?p=211</guid>
		<description><![CDATA[Often you would like some personal information filled in for the user before they start the application. E.g. Why have Office or Acrobat ask for the users name when it is already stored in active directory? Here are some simple &#8230; <a href="http://jrudd.org/2010/07/pre-populate-users-names-and-email-address-in-office-and-acrobat/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Often you would like some personal information filled in for the user before they start the application. E.g. Why have Office or Acrobat ask for the users name when it is already stored in active directory?</p>
<p>Here are some simple VBScripts that can be added to a log on script or similar to pre-fill these for the user. Once you know the registry location where the identity information is  stored it is quite easy to fill those values as part of a login script.</p>
<h3>Microsoft Office</h3>
<pre class="brush: vb; title: ; notranslate">' Original MS Office script written by David Isaacs
Set oShell = CreateObject(&quot;WScript.Shell&quot;)

On Error Resume Next

strUsername = oShell.ExpandEnvironmentStrings(&quot;%USERNAME%&quot;)
strUserdomain = oShell.ExpandEnvironmentStrings(&quot;%USERDOMAIN%&quot;)

Set oUser = GetObject(&quot;WinNT://&quot; &amp; strUserdomain &amp; &quot;/&quot; &amp; strUsername &amp; &quot;,user&quot;)

oShell.RegWrite &quot;HKCU\Software\Microsoft\Office\Common\UserInfo\UserInitials&quot;, strUsername
oShell.RegWrite &quot;HKCU\Software\Microsoft\Office\Common\UserInfo\UserName&quot;, oUser.Fullname</pre>
<h3>Adobe Acrobat Pro and Reader</h3>
<p>This will set the full name, office, email address and your company for multiple versions of Acrobat and Acrobat reader. You can add even more versions by adding extra lines to the array.</p>
<p>Also if you modified Acrobat to install with Acrobat.com disabled, but  now wish to enable it this will enable it. We originally had it disabled, but found email and network form  submission did not work properly until it was enabled.</p>
<p>The method for accessing the AD User object was posted by Mike Walker in this <a href="http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d2d9bf23-e27f-4f30-9199-42833d6919a4">thread</a>.</p>
<pre class="brush: vb; title: ; notranslate">' Configure Adobe Acrobat default settings
' Written by James Rudd
Set oShell = CreateObject(&quot;WScript.Shell&quot;)
Set oFso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

' Set the different registry paths for Acrobat
Dim regPaths(2)
regPaths(0) = &quot;HKEY_CURRENT_USER\Software\Adobe\Adobe Acrobat\9.0\&quot;  'For Acrobat Pro 9
regPaths(1) = &quot;HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\9.0\&quot;  'For Acrobat Reader 9
regPaths(2) = &quot;HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\8.0\&quot;  'Same for Acrobat Reader 8

On Error Resume Next

' Create the ADSystem Information Object
Set objADSystemInfo = CreateObject(&quot;ADSystemInfo&quot;)
' Get the current information into a new Object
Set objUser = GetObject(&quot;LDAP://&quot; &amp; objADSystemInfo.UserName)

For Each regPath In regPaths
 'Enable Acrobat.com by deleting key that contains disabling entries.
 oShell.regdelete regPath &amp; &quot;Workflows\&quot;

 'Set Acrobat Identity Info
 oShell.RegWrite regPath &amp; &quot;Identity\tEMail&quot;, objUser.mail, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tName&quot;, objUser.givenName &amp; &quot; &quot; &amp; objUser.sn, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tFirstName&quot;, objUser.givenName, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tLastName&quot;, objUser.sn, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tCorporation&quot;, &quot;Your Company Name&quot;, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tDepartment&quot;, objUser.physicalDeliveryOfficeName, &quot;REG_SZ&quot;

 'Set Default Acrobat Collaboration details
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tEMail&quot;, objUser.mail, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tFullName&quot;, objUser.givenName &amp; &quot; &quot; &amp; objUser.sn, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tCorporation&quot;, &quot;Your Company Name&quot;, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tDepartment&quot;, objUser.physicalDeliveryOfficeName, &quot;REG_SZ&quot;
Next
</pre>
<h3>Combined</h3>
<p>The following script combines both Office and Acrobat data in to one, and reuses the same data objects rather than use two different connection techniques.</p>
<pre class="brush: vb; title: ; notranslate">
' Configure Adobe Acrobat and MS Office user settings
' Written by James Rudd

Const strCompanyName = &quot;Your School Name&quot;

Set oShell = CreateObject(&quot;WScript.Shell&quot;)
Set oFso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

' Create the ADSystem Information Object
Set objADSystemInfo = CreateObject(&quot;ADSystemInfo&quot;)
' Get the current information into a new Object
Set objUser = GetObject(&quot;LDAP://&quot; &amp; objADSystemInfo.UserName)

On Error Resume Next

'Office Details
oShell.RegWrite &quot;HKCU\Software\Microsoft\Office\Common\UserInfo\UserInitials&quot;, objUser.sAMAccountName, &quot;REG_SZ&quot;
oShell.RegWrite &quot;HKCU\Software\Microsoft\Office\Common\UserInfo\UserName&quot;, objUser.givenName &amp; &quot; &quot; &amp; objUser.sn, &quot;REG_SZ&quot;
' If set by installer Company Name is overidden on load.
oShell.RegWrite &quot;HKCU\Software\Microsoft\Office\Common\UserInfo\Company&quot;, strCompanyName, &quot;REG_SZ&quot;

' Set the different registry paths for Acrobat
Dim regPaths(2)
regPaths(0) = &quot;HKEY_CURRENT_USER\Software\Adobe\Adobe Acrobat\9.0\&quot;  'For Acrobat Pro 9
regPaths(1) = &quot;HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\9.0\&quot;  'For Acrobat Reader 9
regPaths(2) = &quot;HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\8.0\&quot;  'Same for Acrobat Reader 8

For Each regPath In regPaths
 'Enable Acrobat.com by deleting key that contains disabling entries.
 oShell.regdelete regPath &amp; &quot;Workflows\&quot;

 'Set Acrobat Identity Info
 oShell.RegWrite regPath &amp; &quot;Identity\tEMail&quot;, objUser.mail, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tName&quot;, objUser.givenName &amp; &quot; &quot; &amp; objUser.sn, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tFirstName&quot;, objUser.givenName, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tLastName&quot;, objUser.sn, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tCorporation&quot;, &quot;Your Company Name&quot;, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;Identity\tDepartment&quot;, objUser.physicalDeliveryOfficeName, &quot;REG_SZ&quot;

 'Set Default Acrobat Collaboration details
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tEMail&quot;, objUser.mail, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tFullName&quot;, objUser.givenName &amp; &quot; &quot; &amp; objUser.sn, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tCorporation&quot;, strCompanyName, &quot;REG_SZ&quot;
 oShell.RegWrite regPath &amp; &quot;ShareIdentity\tDepartment&quot;, objUser.physicalDeliveryOfficeName, &quot;REG_SZ&quot;
Next
</pre>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2010/07/pre-populate-users-names-and-email-address-in-office-and-acrobat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using BackupPC with DiskShadow to backup open files</title>
		<link>http://jrudd.org/2010/07/using-backuppc-with-diskshadow-to-backup-open-files/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-backuppc-with-diskshadow-to-backup-open-files</link>
		<comments>http://jrudd.org/2010/07/using-backuppc-with-diskshadow-to-backup-open-files/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 14:59:48 +0000</pubDate>
		<dc:creator>James Rudd</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Administrator]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[backuppc]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[DiskShadow]]></category>
		<category><![CDATA[noacl]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[server 2008 R2]]></category>
		<category><![CDATA[snapshots]]></category>
		<category><![CDATA[Task Scheduler]]></category>
		<category><![CDATA[VShadow]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://jrudd.org/wordpress/?p=151</guid>
		<description><![CDATA[This post is to assist in the setup of a BackupPC system able to backup in use files by using MS volume snapshots. It also has the benefit of only having the RSync daemon running during the backup which increases security. <a href="http://jrudd.org/2010/07/using-backuppc-with-diskshadow-to-backup-open-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[
<h1>Introduction</h1>
<p>This post is to assist in the setup of a BackupPC system able to backup in use files by using MS volume snapshots. It also has the benefit of only having the RSync daemon running during the backup which increases security.</p>
<p>This method is based on some other posts I have seen using <a href="http://www.goodjobsucking.com/?p=62">VShadow</a>, <a href="http://www.goodjobsucking.com/?p=62"><em>Backing Up Open Files on Windows with Rsync</em></a>, and some suggestions on <a href="http://www.goodjobsucking.com/?p=62&amp;cpage=2#comment-3159">DiskShadow</a> but goes further in using RSync as a system service giving full access to files, and removing the need to use winexe.</p>
<h2>General Outline</h2>
<ol>
<li>Create a new user <em><strong>backuppc </strong></em>(try to match case of the user on Linux). Very limited rights</li>
<li>Install Cygwin with RSync, OpenSSH and configure them</li>
<li>Create a scheduled task to run as SYSTEM when triggered by a certain event</li>
<li>Set BackupPC server for passwordless login to host and modify Pre/Post Dump Cmds</li>
</ol>

<h1>Overview</h1>
<p>In Windows 7 and Server 2008 R2 elevation is required to create snapshots. As a remote SSH connection cannot bypass UAC a way is needed to create the snapshot, bypassing the elevation prompt. I also wished to run the Rsync Daemon as SYSTEM user so it has rights to view all files.</p>
<p>To do this I moved all the elevated tasks into a Task Scheduler item that is set to run as SYSTEM, and is triggered by an Event log event.</p>
<ol>
<li>BackupPC performs a password-less key SSH logon to client</li>
<li>It runs a script which creates an event log entry and then waits for RSync to start before returning to BackupPC and starting the backup.</li>
<li>Task scheduler is triggered by <a href="http://support.microsoft.com/kb/315410">Event Log</a> and starts DiskShadow as SYSTEM.</li>
<li>Disk shadow creates a shadow of any chosen volumes, mounts them and then starts RSync.<br />
It then waits for a file to be created by BackupPC at the end of the backup telling it to stop RSync and delete the snaphots.</li>
</ol>
<h3>Flow and triggers</h3>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="205"><strong>BackupPC Server</strong></td>
<td colspan="2" valign="top" width="411"><strong>Host PC</strong></td>
</tr>
<tr>
<td valign="top" width="205"><strong>backuppc User</strong></td>
<td valign="top" width="205"><strong>backuppc User</strong></td>
<td valign="top" width="205"><strong>SYSTEM</strong></td>
</tr>
<tr>
<td style="text-align: center;" colspan="3" valign="top" width="411"><strong>Start Backup</strong></td>
</tr>
<tr>
<td valign="top" width="205">SSH to Host PC</td>
<td valign="top" width="205"></td>
<td valign="top" width="205"></td>
</tr>
<tr>
<td valign="top" width="205"></td>
<td valign="top" width="205">Log Event</td>
<td valign="top" width="205">Diskshadow: Snaphsot</td>
</tr>
<tr>
<td valign="top" width="205"></td>
<td valign="top" width="205"></td>
<td valign="top" width="205">Start Rsync</td>
</tr>
<tr>
<td valign="top" width="205"></td>
<td valign="top" width="205">Close and return</td>
<td valign="top" width="205"></td>
</tr>
<tr>
<td valign="top" width="205">Begin Backup</td>
<td valign="top" width="205"></td>
<td valign="top" width="205"></td>
</tr>
<tr>
<td style="text-align: center;" colspan="3" valign="top" width="411"><strong>Finish Backup</strong></td>
</tr>
<tr>
<td valign="top" width="205">SSH to Host PC</td>
<td valign="top" width="205"></td>
<td valign="top" width="205"></td>
</tr>
<tr>
<td valign="top" width="205"></td>
<td valign="top" width="205">Create a Wake.up file</td>
<td valign="top" width="205"></td>
</tr>
<tr>
<td valign="top" width="205"></td>
<td valign="top" width="205"></td>
<td valign="top" width="205">Stop Rsync</td>
</tr>
<tr>
<td valign="top" width="205"></td>
<td valign="top" width="205"></td>
<td valign="top" width="205">Delete Snaphost</td>
</tr>
</tbody>
</table>
<h1>Host PC</h1>
<p>Create a new user, <em><strong>backuppc</strong></em>, you can limit this account further in Security policy after everything is configured.</p>
<p>Create a BackupPC folder and add the following scripts to it. These are also available in a <a href="http://jrudd.org//download/general/BackupPC-Config.zip">zip file</a>. Note: There is a file embedded within this post, please visit this post to download the file. You will need to modify paths depending on where you create the folder. I used C:\cygwin\BackupPC but a better location may be C:\cygwin\usr\share\BackupPC</p>
<p>Most of these scripts are just modified versions of the ones written for <a href="http://www.goodjobsucking.com/?p=62">VShadow</a>, changed to work with DiskShadow and Task Scheduler.</p>
<p><strong>pre-cmd.vbs</strong></p>
<pre class="brush: vb; collapse: true; light: false; title: ; toolbar: true; notranslate">' This file starts the commands
' It will start the snapshot process and quite once RSync is running

Const Rsync = &quot;C:\cygwin\var\run\rsyncd.pid&quot;
Const Flag = &quot;C:\cygwin\var\run\wake.up&quot;
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
'
' Pid file shouldn't be there already
' Check /stop service , still there delete
'
If DoesFileExist(Rsync)=0 Then
	fso.DeleteFile(Rsync)
End If
'
' Nor should &quot;wake.up&quot;
'
If DoesFileExist(Flag)=0 Then
   fso.DeleteFile(Flag)
End If

Set objShell = CreateObject(&quot;WScript.Shell&quot;)
' objShell.Exec &quot;C:\BackupPC\backuppc.cmd &gt; &quot; &amp; Log

' This writes event log entry that triggers task scheduler to start system process
' that takes snapshot and starts RSync
objShell.Exec &quot;Logevent.exe -r &quot;&quot;BackupPC&quot;&quot; -e 10 -s S &quot;&quot;Backup Start&quot;&quot; &quot;
Wscript.Echo &quot;Sent BackupPC Event Log Trigger&quot;

'
' Just sleep until the file &quot;rsyncd.pid&quot; appears
'

While DoesFileExist(Rsync)
   wscript.sleep 10000
Wend

' functions

function DoesFileExist(FilePath)
Dim fso
	Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
	if not fso.FileExists(FilePath) then
		DoesFileExist = -1
	else
		DoesFileExist = 0
	end if
	Set fso = Nothing

end function</pre>
<p><strong>backuppc.cmd</strong></p>
<pre class="brush: plain; collapse: true; light: false; title: ; toolbar: true; notranslate">c:
cd C:\cygwin\BackupPC
diskshadow /s DiskShadowScript.txt /l C:\cygwin\var\log\diskshadow.log
del C:\cygwin\var\tmp\*.cab /q
c:cd C:\cygwin\BackupPCdiskshadow /s DiskShadowScript.txt /l C:\cygwin\var\log\diskshadow.log
del C:\cygwin\var\tmp\*.cab /q</pre>
<p><strong>DiskShadowScript.txt</strong></p>
<pre class="brush: plain; collapse: true; light: false; title: ; toolbar: true; notranslate">#DiskShadow script file

#Make shadows persistent, No writers as data volume

# If backing up C: and any app files (ntds, database, etc) use writers

#SET CONTEXT PERSISTENT NOWRITERS

SET CONTEXT PERSISTENT

#Cab location for process

SET METADATA C:\cygwin\var\tmp\backup.cab

SET VERBOSE ON

BEGIN BACKUP

#Alias volume with alias

ADD VOLUME C: ALIAS SystemData

ADD VOLUME F: ALIAS UserData

#Create Snapshot

CREATE

#Expose the volume and run command file then unexpose

EXPOSE %UserData% B:

EXPOSE %SystemData% T:

EXEC C:\cygwin\BackupPC\Serverbackup.cmd

UNEXPOSE B:

UNEXPOSE T:

END BACKUP

#Delete the shadow copy

DELETE SHADOWS SET %VSS_SHADOW_SET%

#End of script</pre>
<p><strong>Serverbackup.cmd</strong></p>
<pre class="brush: plain; collapse: true; light: false; title: ; toolbar: true; notranslate">REM Start RSync now that Snapshots are created

net start rsyncd

REM Need to wait until backup completed

cscript &quot;C:\cygwin\BackupPC\sleep.vbs&quot;

Logevent.exe -r &quot;BackupPC&quot; -e 20 -s S &quot;Backup Completed&quot;

</pre>
<p><strong>sleep.vbs</strong></p>
<pre class="brush: vb; collapse: true; light: false; title: ; toolbar: true; notranslate">Const Rsync = &quot;C:\cygwin\var\run\rsyncd.pid&quot;
Const Flag = &quot;C:\cygwin\var\run\wake.up&quot;
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

' Just sleep until the file &quot;rsyncd.pid&quot; appears
While DoesFileExist(Rsync)
   wscript.sleep 10000
Wend

' Now sleep until the file &quot;wake.up&quot; appears
While DoesFileExist(Flag)
   wscript.sleep 10000
Wend

fso.DeleteFile(Flag)

' It's time to kill Rsync
'Stop Service
strServiceName = &quot;rsyncd&quot;
Set objWMIService = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2&quot;)
Set colListOfServices = objWMIService.ExecQuery(&quot;Select * from Win32_Service Where Name ='&quot; &amp; strServiceName &amp; &quot;'&quot;)
For Each objService in colListOfServices
    objService.StopService()
	Wscript.Echo &quot;RSyncD Stopped&quot;
Next

' Wait for Rsync to let go
wscript.sleep 5000

' Delete PID file
If DoesFileExist(Rsync)=0 Then
   fso.DeleteFile(Rsync)
End If

' functions
function DoesFileExist(FilePath)
Dim fso
	Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
	if not fso.FileExists(FilePath) then
		DoesFileExist = -1
	else
		DoesFileExist = 0
	end if
	Set fso = Nothing

end function

</pre>
<h2>Cygwin</h2>
<p>Install Cygwin and choose to install packages RSync and OpenSSH</p>
<p>Start an elevated Cygwin (Run as an Administrator )</p>
<h4>Config</h4>
<p>Cygwin 1.7 changes the way to ignore NT Security from the <em>nontsec </em>environment to modifying fstab file.</p>
<p>In your prefered editor modify /etc/fstab and uncomment the bottom line and add <em>noacl </em>as below, this tells it to ignore security :</p>
<pre class="brush: plain; light: true; title: ; notranslate">none /cygdrive cygdrive binary,noacl,posix=0,user 0 0</pre>
<p>Run following to update group and user lists (if on a domain only add the users you want)</p>
<p>[bashlight=1]mkpasswd –l >/etc/passwd<br />
mkgroup –l /etc/group[/bash]</p>
<h3>OpenSSH</h3>
<p>Configure Open SSH using <em>ssh-host-config</em>, create both the accounts it suggests for privilege isolation and running the service (cyg_service &amp; sshd).<br />
This should also automatically add the Firewall Exceptions (SSHD).</p>
<h4>Setting up Keyless</h4>
<p><span style="font-weight: normal;">Login as backuppc user.</span><br />
<span style="font-weight: normal;">Use </span></p>
<pre class="brush: plain; light: true; title: ; notranslate">runas /user:backuppc cmd</pre>
<p>Or</p>
<pre class="brush: plain; light: true; title: ; notranslate">runas /user:domain\backuppc cmd</pre>
<p>Run c:\cygwin\Cygwin.bat to start Cygwin as BackupPC user</p>
<p>You need to add the id_rsa.pub file from the BackupPC user on BackupPC server to C:\cygwin\home\backuppc\.ssh\authorized_keys If you have not already created one follow the instructions below in BackupPC &#8211; SSH section.</p>
<h3>RSync</h3>
<p>To install RSync as a system service use:</p>
<pre class="brush: plain; title: ; notranslate">C:\cygwin\bin\cygrunsrv.exe -I rsyncd -d &quot;RSync Daemon&quot; -O --type manual -p /bin/rsync.exe -f &quot;Used by BackupPC to remotely access files for backup&quot; -a &quot; --config=/etc/rsyncd.conf --daemon --no-detach&quot;</pre>
<p>Modify the /etc/rsyncd.conf file to reflect what drives you want to backup. It is better to edit this file later after you have modified the DiskShadowScript.txt and changed which drive letter it exposes shadows as.</p>
<p>Add a RSync exception to the firewall.</p>
<p>Open <em>Windows Firewall with Advanced Security</em> and choose Inbound Rules, New Rule, Program,  Next</p>
<p>Browse to C:\cygwin\bin\rsync.exe and then choose your options and name the rule</p>
<p>When finished open the rule, click Scope tab and add a Remote IP, that of the BackupPC server. This restricts RSync to only be accessible from BackupPC. You may also wish to similarly modify SSHD to only allow SSH access from BackupPC server.</p>
<h2>DiskShadow</h2>
<p>If you are backing up a windows Server 2008 or 2008 R2 host you already have DiskShadow installed. However, if you are running Windows 7 or Vista you will need to grab a copy from an equivalent server (x86 or x64). It is located in the System32 directory and you will also need the language file from the en-US folder.</p>
<p>I have <a href="http://jrudd.org//download/utilities/DiskShadow.zip">zipped the files needed</a> for x86 and x64 if you do not have immediate access to a Server.Note: There is a file embedded within this post, please visit this post to download the file. (The x86 files are from Server 2008 and x64 are from 2008 R2)</p>
<p>Copy the files from your architecture to the system32 directory and en-US subdirectory.</p>
<h3>LogEvent</h3>
<p>To generate the custom event log entry a tool from the Windows 2000 Resource kit is used, <a href="http://support.microsoft.com/kb/315410">LogEvent</a>, (<a href="http://www.dynawell.com/download/reskit/microsoft/win2000/logevent.zip">Download</a>). This needs to be either placed in the Path (e.g. Windows dir) or scripts need to directly call it.</p>
<h2>Task Scheduler</h2>
<p>The easiest way to configure this is to manually run LogEvent once to generate an event in the log.</p>
<pre class="brush: plain; light: true; title: ; notranslate">Logevent.exe -r &quot;BackupPC&quot; -e 10 -s S &quot;Backup Start&quot;</pre>
<p>Then open Event Viewer, Select the new BackupPC event and choose <em>Attach Task to this Event</em>, and in the wizard click next until it asks for the program, then give it <strong>C:\cygwin\BackupPC\backuppc.cmd</strong></p>
<p>On Final page choose to <em>Open Properties</em> when you click Finish</p>
<p>Click the <em>Change User or Group</em> button and type in <strong>System </strong>as the user  and click OK. Also tick the <em>Run with highest privileges</em> box</p>
<h1>BackupPC Server</h1>
<h2>SSH</h2>
<p>This section is only needed if you do not already have keys generated for the backuppc user.</p>
<p>Login as backuppc user, either with password or simply “su – backuppc” from root</p>
<p>Generate SSH Keys, <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;"><em>ssh-keygen –t rsa</em></span>, do not set a password. Copy id_rsa.pub into C:\cygwin\home\backuppc\.ssh \authorized_keys</p>
<p>Test by running <em>ssh -v backuppc@host</em> to test the connection</p>
<h2>BackupPC Host File</h2>
<p>In the web interface change the following for the host.</p>
<pre class="brush: plain; light: true; title: ; notranslate">DumpPreUserCmd:  $sshPath -q -x -l backuppc $host cscript &quot;C:\cygwin\BackupPC\pre-cmd.vbs&quot;
 DumpPostUserCmd: $sshPath -q -x -l backuppc $host echo &quot;Complete: $xferOK&quot; &gt; /var/run/wake.up</pre>
<h2>Test Run</h2>
<p>If you have existing backups from a previous RSync config, it is a good idea to run a full backup to ensure any in use files are part of the base. In my case I also changed the <em>noacl </em>flag which affected the file attributes RSync sees.</p>
<h1>Tips</h1>
<p>Set your antivirus to exclude the exposed drives. As they are read only it just slows down the reading of files by RSync.</p>
<h3>Downloads</h3>
Note: There is a file embedded within this post, please visit this post to download the file.
<h1>Updates</h1>
<ul>
<li>While writing this up I found a good alternative way of using VShadow with SSH to backup in use files, that uses the AT command instead of task scheduler to get around UAC, <a href="http://geraldbrandt.com/2010/06/08/backuppc-with-sshrsyncvss-on-windows-server/">BackupPC with ssh/rsync/VSS on Windows Server</a>. The only down side to this method is the SSH connection requires an Admin account, but if configured securely this should be fine. It also a lot simpler to configure as it does not require configuring Task Scheduler.</li>
<li>There is a great script for managing VSS by Mark Baggett and Tim &#8220;LaNMaSteR53&#8243; Tomes <a href="http://tools.lanmaster53.com/vssown.vbs">VSSOwn.vbs</a> which was discussed in one of there security blog posts, <a href="http://pauldotcom.com/2011/11/safely-dumping-hashes-from-liv.html">Safely Dumping Hashes from Live Domain Controllers</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jrudd.org/2010/07/using-backuppc-with-diskshadow-to-backup-open-files/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
