#!/bin/sh # Demo shell script, to be run under Cygwin on Windows, or (for the brave) under Cygwin on Wine, # showing how to do an unattended install of various Windows apps. # (C) Dan Kegel August 2009 # # Before running, install wget and cabextract in cygwin. # # To run this on wine, do "winetricks dotnet20 msxml6" first # To start Cygwin on wine, use "cd $HOME/.wine/drive_c/cygwin; wineconsole cmd /c cygwin.bat" # Inside the wineconsole, you can then run this script set -e set -x olddir=`pwd` TEMP=${TEMP:-/tmp} PGRAB_TMP="$TEMP/pgrabtmp" PGRAB_CACHE="$TEMP/pgrabcache" mkdir -p "$PGRAB_TMP" mkdir -p "$PGRAB_CACHE" if [ ! -x "`which cabextract`" ] then echo "Cannot find cabextract. Please install it with cygwin setup (in category archivers)." exit 1 fi if [ ! -x "`which wget`" ] then echo "Cannot find wget. Please install it with cygwin setup (in category web)." exit 1 fi # Execute with error checking try() { echo Executing "$@" "$@" status=$? if test $status -ne 0 then echo "Note: command '$@' returned status $status. Aborting." exit 1 fi } # verify an sha1sum verify_sha1sum() { wantsum=$1 file=$2 gotsum=`sha1sum < $file | sed 's/ .*//'` if [ "$gotsum"x != "$wantsum"x ] then die "sha1sum mismatch! Rename $file and try again." fi } # Download a file # Usage: package url [sha1sum [filename]] # Caches downloads in $PGRABCACHE/$package download() { if [ "$4"x != ""x ] then file="$4" else file=`basename "$2"` fi cache="$PGRAB_CACHE/$1" mkdir -p "$cache" if test ! -f "$cache/$file" then cd "$cache" # Use -nd to insulate ourselves from people who set -x in WGETRC # [*] --retry-connrefused works around the broken sf.net mirroring # system when downloading corefonts # [*] --read-timeout is useful on the adobe server that doesn't # close the connection unless you tell it to (control-C or closing # the socket) try wget -O "$file" -nd -c --read-timeout=300 --retry-connrefused --header "Accept-Encoding: gzip,deflate" "$2" cd "$olddir" fi if [ "$3"x != ""x ] then verify_sha1sum $3 "$cache/$file" fi } load_visual_c_2005_express() { # Thanks to http://blogs.msdn.com/astebner/articles/551674.aspx for the recipe # Assumes you already have .net 2 and msxml6 installed # http://go.microsoft.com/fwlink/?LinkId=51410 download vc2005x http://download.microsoft.com/download/8/3/a/83aad8f9-38ba-4503-b3cd-ba28c360c27b/ENU/vcsetup.exe 0292ae1d576edd8ee5350a27113c94c9f9958d5c # "http://go.microsoft.com/fwlink/?LinkId=51417" download vc2005x http://download.microsoft.com/download/0/5/A/05AA45B9-A4BE-4872-8D57-733DF5297284/Ixpvc.exe ce0da62b5649f33c7a150de276d799fb2d68d12a # Have to use cmd; cygwin doesn't trigger UAC, denies access cd "$PGRAB_TMP" rm -rf vc2005x.tmp || true mkdir vc2005x.tmp cd vc2005x.tmp cabextract "$PGRAB_CACHE"/vc2005x/vcsetup.exe cp "$PGRAB_CACHE"/vc2005x/Ixpvc.exe . chmod +x Ixpvc.exe DIR=`pwd` XXX=`cygpath -w $DIR` # Add /qn after ReallySuppress for a really silent install (but then you won't see any errors) # Note: on Wine, the cmd/c fails to wait, see http://bugs.winehq.org/show_bug.cgi?id=19668 #cmd /c Ixpvc /t:$XXX /q:a /c:"msiexec /i vcsetup.msi VSEXTUI=1 ADDLOCAL=ALL REBOOT=ReallySuppress" || true ./Ixpvc /t:$XXX /q:a /c:"msiexec /i vcsetup.msi VSEXTUI=1 ADDLOCAL=ALL REBOOT=ReallySuppress" cd .. rm -rf vc2005x.tmp || true cd "$olddir" } load_psdk_2003() { # Note: aborts on 64 bit windows with dialog saying "don't run on WoW" # http://www.microsoft.com/downloads/details.aspx?familyid=0baf2b35-c656-4969-ace8-e4c0c0716adb download psdk2003 http://download.microsoft.com/download/f/a/d/fad9efde-8627-4e7a-8812-c351ba099151/PSDK-x86.exe 5c7dc2e1eb902b376d7797cc383fefdfc64ff9c9 echo "This takes about an hour, and fails at the end, but enough is installed to be useful, I hope. See http://bugs.winehq.org/show_bug.cgi?id=19673" chmod +x "$PGRAB_CACHE"/psdk2003/PSDK-x86 "$PGRAB_CACHE"/psdk2003/PSDK-x86 } load_psdk_vista() { # http://www.microsoft.com/downloads/details.aspx?familyid=0baf2b35-c656-4969-ace8-e4c0c0716adb download vistasdk download.microsoft.com/download/c/a/1/ca145d10-e254-475c-85f9-1439f4cd2a9e/Setup.exe chmod +x "$PGRAB_CACHE"/vistasdk/Setup.exe cd "$PGRAB_CACHE"/vistasdk cmd /c Setup.exe cd "$olddir" } load_visual_c_2005_express load_psdk_2003 #load_psdk_vista