@echo off
rem -- Description:
rem --
rem -- This script is designed to easily allow the user to install
rem -- some useful programs which can run in a Dos Console window in
rem -- a Microsoft Window Environment. (The current script has been
rem -- modified to run on Windows XP). There is a similar script called
rem -- get-stuff.bat which is designed to run on Microsoft-Windows 98.
rem --
rem --
rem --
rem -- A distribution of the 'wget' program
rem --   http://xoomer.virgilio.it/hherold/
rem --
rem --
rem -- The binary for wget with ssl support (~300K)
rem --   ftp://ftp.sunsite.dk/projects/wget/windows/wget-1.9.1b.zip
rem -- The ssl libraries for wget (these ARE required) (~450K)
rem --   ftp://ftp.sunsite.dk/projects/wget/windows/ssllibs097c.zip
rem -- The wget sources in zip compression format (~1.5M)
rem --   ftp://ftp.sunsite.dk/projects/wget/windows/wget-1.9s.zip
rem --
rem --
rem --  Notes:
rem --    The is a roughly equivalent of this script designed to run
rem --    on Windows 98 and is called just 'get-stuff.txt' or
rem --    'get-stuff.bat'  The main difference is that in Windows XP
rem --   it is necessary to use the 'set' command with the /p switch
rem --   instead of the 'choice' command on Windows 98
rem --
rem --   Basically this script attempts to mimic, in a very rudimentary
rem --   the Linux package management programs such as the Debian 'apt'
rem --   program or the Redhat 'rpm' program.
rem --
rem --  
rem -- See Also:
rem --   conf-dos.bat   conf-dos.bat is similar to the following
rem --   script but it does not give the user a menu of choices of
rem --   what to install. It just installs everything, such as
rem --     djgpp development environment, wget, a set of unix tools
rem --     the Arachne browser, the lynx browser.
rem -- Author:
rem --   mjb  matth3wbishop@yahoo.com

rem doskey

rem *** set the FIREFTP variable to '-a' when you are behind
rem *** a proxy or firewall which is not allowing the normal ftp
rem *** operations to work, for example
rem  FIREFTP=-a
set FIREFTP=
set DRIVE=c:
set BASEDIR=%DRIVE%\tools

@echo 'get-stuff.bat' can install some useful programs on your
@echo Microsoft Windows computer. You need an Internet connection
@echo for this program to work [This version is for Windows XP]
@echo see: http://www.geocities.com/matth3wbishop/
@echo =====================================================
@echo
@echo x: quit without installing anything
@echo a: wget - URL getter   [http://www.gnu.org/wget/]   
@echo b: infozip - zip compression / decompression [http://www.info-zip.org/] 
@echo c: fileC - filename completion [http://www.morearty.com/filec/]
@echo     NOTE: windows xp already has filename completion
@echo d: unix tools - Unix utility programs [http://unxutils.sourceforge.net]
@echo e: lynx - Text only browser with SSL [http://www.lynx.org ?]
@echo f: arachne - Graphical dos/winx browser [http://www.arachne.com ?]
@echo g: djgpp - dos/win c developement system [http://www.delorie.com]
@echo h: vim - a text editor [http://www.vim.org] - 3MB
@echo i: mjb - mirror matth3wbishop [http://www.geocities.com/matth3wbishop]
@echo j: geoftp - system to upload to geocities free account 
@echo k: curl - ssh url getter [http://curl.haxx.se/]
@echo l: retrovox - the code for the retrovox system 
set /p choice="Which program would you like to install "

set PROG=
if "%choice%"=="x" set PROG=x
if "%choice%"=="a" set PROG=wget
if "%choice%"=="b" set PROG=infozip
if "%choice%"=="c" set PROG=filec
if "%choice%"=="d" set PROG=unixutil
if "%choice%"=="e" set PROG=lynx
if "%choice%"=="f" set PROG=arachne
if "%choice%"=="g" set PROG=djgpp
if "%choice%"=="h" set PROG=vim
if "%choice%"=="i" set PROG=mjb
if "%choice%"=="j" set PROG=geoftp
if "%choice%"=="k" set PROG=curl
if "%choice%"=="l" set PROG=retrovox

echo Program Selected=%PROG% 

if %PROG%==x goto end
if %PROG%== goto end

if NOT %PROG%==wget goto endifWG
  @rem ***
  @rem *** The following code creates an ftp script file which can be used
  @rem *** with the standard Microsoft Windows command line ftp program
  @rem *** The purpose of this section is to retrieve the wget program from
  @rem *** the 'sunsite' ftp server. In the past I have noticed that
  @rem *** under some versions of MS Windows, when the script file has finished
  @rem *** the ftp program does not exit (it waits for more commands from the
  @rem *** command line). This will cause the present script to stop executing.
  @rem *** One solution to this situation is just to type 'quit' at the
  @rem *** prompt which looks like this "ftp>"
  @rem ***
  @rem *** create the ftp script file
  @rem ***


  set WGETSITE=ftp.sunsite.dk
  set WGETDIR=projects/wget/windows

  mkdir %BASEDIR%\wget
  path=%BASEDIR%\wget;%path%

  cd %BASEDIR%\wget
  @rem -- Note that I believe that I have noticed that on some versions
  @rem -- of the MS Windows console it is not possible to change directories
  @rem -- using the syntax
  @rem --    cd c:\some\dir
  @rem -- That is, the drive letter is not allowed in the path. If this is
  @rem -- true then the line immediately above the current comment block
  @rem -- will fail. However on Windows 98SE this appears to be working

  echo user anonymous matthew@macwcwagga.homedns.org > junk.txt
  echo hash >> junk.txt
  echo bin >> junk.txt
  echo cd %WGETDIR% >> junk.txt

  @rem -- I wonder how portable this construct is to various
  @rem -- dos and windows batch languages. It works on Windows 98 and 
  @rem -- Windows XP

  IF EXIST %BASEDIR%\wget\wget-1.9.1b.zip GOTO endif1
    echo get wget-1.9.1b.zip >> junk.txt
  :endif1

  IF EXIST %BASEDIR%\wget\ssllibs097c.zip GOTO endif2
    echo get ssllibs097c.zip >> junk.txt
  :endif2

  rem -- echo get wget-1.9s.zip >> junk.txt
  echo quit >> junk.txt


  @rem ***
  @rem *** Logon & transfer the file                                       
  @rem ***
  ftp %FIREFTP% -n -s:junk.txt %WGETSITE%
  @rem *** When behind a firewall use the following line
  @rem ***  ftp -n -s:junk.txt -a %WGETSITE% but please NOTE that the
  @rem *** line above this comment block actually should take care of
  @rem *** this situation by using the FIREFTP variable.
  rem del junk.txt

  unzip -o *.zip
  move wget.HLP wget-ms.HLP

  @echo The wget recursive URL retriever was probably installed
  @echo successfully in the directory %BASEDIR%\wget\. Type
  @echo   wget -h | more
  @echo to see how it works or look at the file %BASEDIR%\wget\wget-ms.hlp
  @echo The correct installation of 'wget' is dependent on the 'infozip'
  @echo programs being installed first. 
:endifWG
@rem -- end of WGET block

if NOT %PROG%==infozip goto endifIZ
  set ZIPSITE=ftp.info-zip.org
  set ZIPDIR=pub/infozip/WIN32
  set ZIPDIR2=pub/infozip/MSDOS

  mkdir %BASEDIR%\infozip

  mkdir %BASEDIR%\infozip\unzip
  path=%BASEDIR%\infozip\unzip;%path%

  mkdir %BASEDIR%\infozip\unzip\dos
  rem ---  path=%BASEDIR%\infozip\unzip\dos;%path%

  mkdir %BASEDIR%\infozip\zip
  path=%BASEDIR%\infozip\zip;%path%

  mkdir %BASEDIR%\infozip\zip\dos
  rem ---  path=%BASEDIR%\infozip\zip\dos;%path%

  mkdir %BASEDIR%\infozip\gui
  path=%BASEDIR%\infozip\gui;%path%

  cd %BASEDIR%\infozip\unzip

  echo user anonymous matth2wbishop@yahoo.com > junk.txt
  echo hash >> junk.txt
  echo bin >> junk.txt
  echo cd %ZIPDIR% >> junk.txt
  echo lcd %BASEDIR%\infozip\unzip >> junk.txt
  IF EXIST %BASEDIR%\infozip\unzip\unz552xN.exe GOTO endif3
    echo get unz552xN.exe >> junk.txt
  :endif3

  echo lcd %BASEDIR%\infozip\zip >> junk.txt
  IF EXIST %BASEDIR%\infozip\zip\zip231xN.zip GOTO endif4
    echo get zip231xN.zip >> junk.txt
  :endif4

  echo lcd %BASEDIR%\infozip\gui >> junk.txt
  IF EXIST %BASEDIR%\infozip\gui\wiz503xN.exe GOTO endif5
    echo get wiz503xN.exe >> junk.txt
  :endif5

  rem -- echo get wget-1.9s.zip >> junk.txt
  echo quit >> junk.txt
  @rem ***
  @rem *** Logon & transfer the file                                       
  @rem ***
  ftp %FIREFTP% -n -s:junk.txt %ZIPSITE%
  rem del junk.txt

  cd %BASEDIR%\infozip\unzip
  unz552xN.exe
  cd %BASEDIR%\infozip\zip
  unzip -o zip231xN.zip

  @rem --- The extraction below triggers a gui process which will
  @rem --- interrupt the current script
  @rem ---
  @rem --- cd %BASEDIR%\infozip\gui
  @rem --- wiz502xN.exe



  @echo The infozip compression tools were probably installed
  @echo successfully in the directory %BASEDIR%\infozip\ . Type
  @echo   unzip filename.zip  to decompress,
  @echo   zip filename.ext    to compress and
  @echo   wiz                 to use a graphical compression tool
  @echo type unzip -h  ... etc for more help
  @echo  
:endifIZ
@rem -- end of INFOZIP block

if NOT %PROG%==filec goto endifFC
  mkdir %BASEDIR%\filec
  path=%BASEDIR%\filec;%path%
  cd %BASEDIR%\filec

  IF EXIST %BASEDIR%\filec\filec.zip GOTO endif6
    wget http://www.morearty.com/filec/filec.zip
  :endif6

  
  unzip -o filec.zip
  if ERRORLEVEL 0 goto endifEL0
    @echo the 'unzip' program is not available
  :endifEL0
  filec -Q -\ -B
:endifFC

if NOT %PROG%==unixutil goto endifUU
  mkdir %BASEDIR%\unixutil
  path=%path%;%BASEDIR%\unixutil\usr\local\wbin
  path=%path%;%BASEDIR%\unixutil\bin
  cd %BASEDIR%\unixutil

  IF EXIST %BASEDIR%\unixutil\UnxUtils.zip GOTO endif7
    wget http://unxutils.sourceforge.net/UnxUtils.zip
  :endif7

  unzip -o UnxUtils.zip
  cd %BASEDIR%\unixutil\usr\local\wbin
  move find.exe ufind.exe
  move expand.exe uexpand.exe
  @echo  The ports of the unix utilities were (probably) successfully
  @echo  installed in the directory %BASEDIR%\unixutil\ .
  @echo  Type 'sh' to start a unix style shell, or type
  @echo  the name of a unix utility to use it from within the Microsoft
  @echo  Windows Console Box.
  @echo  NOTE: the Unix 'find' program is called 'ufind' to prevent
  @echo        it from interfering with the Microsoft program of the same
  @echo        name and similarly with the expand program
  @echo  .
  @echo  The installation of the unix utilities required the prior
  @echo  installation of the 'infozip' and 'wget' tools. If you
  @echo  have a problem using the unix tools, run these other
  @echo  installation programs first, and then rerun the unix tools
  @echo  installation program.
  @echo  See http://unxutils.sourceforge.net/ for more information

:endifUU

if NOT %PROG%==lynx goto endifLB
  mkdir %BASEDIR%\lynx
  path=%path%;%BASEDIR%\lynx
  cd %BASEDIR%\lynx

  IF EXIST %BASEDIR%\lynx\lynx.zip GOTO endif8
    wget http://www.fredlwm.hpg.ig.com.br/cygwin/lynx/download/lynx.piz
    move lynx.piz lynx.zip
  :endif8

  IF EXIST %BASEDIR%\lynx\lynx.cfg GOTO endif9
    wget http://lynx.isc.org/current/lynx2-8-5/lynx.cfg
  :endif9

  unzip -o lynx.zip
  set LYNX_CFG=%BASEDIR%\lynx\lynx.cfg
  echo set LYNX_CFG=%BASEDIR%\lynx\lynx.cfg >> \autoexec.bat
  @echo =================
  @echo The text mode web-browser Lynx was probably installed
  @echo successfully. You should be able to see how it work by typing
  @echo   lynx
  @echo now on the command line. However, the environment variable which
  @echo lynx requires in order to find its configuration file has only
  @echo been set for the current Console Window or Dos Box. You need to
  @echo set the variable as below. 
  @echo   LYNX_CFG=c:\tools\lynx\lynx.cfg
  @echo You can do this through the control panel but the exact method
  @echo differs in different versions of Microsoft Windows.
  @echo This comment may only apply to those Windows versions which dont
  @echo use an autoexec.bat file
  @echo =================
:endifLB

if NOT %PROG%==arachne goto endifAB
  @rem --- get the dos and windows dos-box browser 'Arachne'
  @rem ---
  mkdir %BASEDIR%\arachne
  path=%path%;%BASEDIR%\arachne
  cd %BASEDIR%\arachne

  IF EXIST %BASEDIR%\arachne\a173gplf.zip GOTO endif10
    wget http://home.hetnet.nl/~ba8tian/arachne/a173gplf.zip
  :endif10

  unzip -o a173gplf.zip
  @rem -- arachne needs to be setup and configured by running the
  @rem -- setup program. I am not sure how this can be automated
  @rem -- currently. Arachne appears to be distributed under the GPL
  @rem -- although some of the documentation indicates that the core.exe
  @rem -- code is not open-source ?

:endifAB

if NOT %PROG%==djgpp goto endifDJ
  set DJSITE=ftp.delorie.com
  set DJDIR=pub/djgpp/current
  @rem -- below is a list of files which are necessary to build
  @rem -- and run c, assembler, yacc and bison programs on a DOS
  @rem -- operating system, or on a compatible system such as a
  @rem -- 'dos console' running on Microsoft Windows

  @rem ** unzip32.exe          to unzip the zip files         95 kb

  @rem ** v2/copying.dj        DJGPP Copyright info            3 kb
  @rem ** v2/djdev203.zip      DJGPP Basic Development Kit   1.5 mb
  @rem ** v2/faq230b.zip       Frequently Asked Questions    664 kb
  @rem ** v2/readme.1st        Installation instructions      22 kb
  @rem ** 
  @rem ** v2apps/rhid149b.zip  RHIDE                         2.4 mb
  @rem ** 
  @rem ** v2gnu/bnu214b.zip    Basic assembler, linker       3.1 mb
  @rem ** v2gnu/bsn135b.zip    Bison                         185 kb
  @rem ** v2gnu/flx254b.zip    Flex                          189 kb
  @rem ** v2gnu/gcc332b.zip    Basic GCC compiler            2.8 mb
  @rem ** v2gnu/gdb53b.zip     GNU debugger                  1.5 mb
  @rem ** v2gnu/mak3791b.zip   Make (processes makefiles)    267 kb
  @rem ** v2gnu/txi46b.zip     Info file viewer              761 kb
  @rem ** 
  @rem ** Extra Documentation Formats
  @rem ** v2gnu/bnu214d.zip    Basic assembler, linker       4.2 mb
  @rem ** v2gnu/bsn128d.zip    Bison                         438 kb
  @rem ** v2gnu/flx254d.zip    Flex                          259 kb
  @rem ** v2gnu/gcc332d.zip    Basic GCC compiler            4.8 mb
  @rem ** v2gnu/gdb53d.zip     GNU debugger                  3.5 mb
  @rem ** v2gnu/mak3791d.zip   Make (processes makefiles)    610 kb
  @rem ** v2gnu/txi46d.zip     Info file viewer              1.3 mb
  @rem ** 
  @rem ** Total bytes to download  approx 30M

  @rem --- get the dos c compiler 'djgpp'
  @rem ---
  mkdir %BASEDIR%\djgpp
  path=%path%;%BASEDIR%\djgpp\bin
  set DJGPP=%BASEDIR%\DJGPP\DJGPP.ENV
  echo set DJGPP=%BASEDIR%\DJGPP\DJGPP.ENV >> \autoexec.bat
  cd %BASEDIR%\djgpp

  echo user anonymous matthew@macwcwagga.homedns.org > junk.txt
  echo hash >> junk.txt
  echo bin >> junk.txt
  echo cd %DJDIR% >> junk.txt
  echo lcd %BASEDIR%\djgpp >> junk.txt
  IF EXIST %BASEDIR%\djgpp\unzip32.exe GOTO endif11
    echo get unzip32.exe >> junk.txt
  :endif11

  echo cd v2 >> junk.txt
  IF EXIST %BASEDIR%\djgpp\djdev203.zip GOTO endif12
    echo get djdev203.zip >> junk.txt
  :endif12

  IF EXIST %BASEDIR%\djgpp\faq230b.zip GOTO endif13
    echo get faq230b.zip >> junk.txt
  :endif13

  IF EXIST %BASEDIR%\djgpp\readme.1st GOTO endif14
    echo get readme.1st >> junk.txt
  :endif14

  echo cd ../v2apps >> junk.txt
  IF EXIST %BASEDIR%\djgpp\rhid149b.zip GOTO endif15
    echo get rhid149b.zip >> junk.txt
  :endif15

  echo cd ../v2gnu >> junk.txt
  IF EXIST %BASEDIR%\djgpp\bnu214b.zip GOTO endif16
    echo get bnu214b.zip >> junk.txt
  :endif16

  IF EXIST %BASEDIR%\djgpp\bsn135b.zip GOTO endif17
    echo get bsn135b.zip >> junk.txt
  :endif17

  IF EXIST %BASEDIR%\djgpp\flx254b.zip GOTO endif18
    echo get flx254b.zip >> junk.txt
  :endif18


  IF EXIST %BASEDIR%\djgpp\gcc332b.zip GOTO endif19
    echo get gcc332b.zip >> junk.txt
  :endif19

  IF EXIST %BASEDIR%\djgpp\gdb53b.zip GOTO endif20
    echo get gdb53b.zip >> junk.txt
  :endif20

  IF EXIST %BASEDIR%\djgpp\mak3791b.zip GOTO endif21
    echo get mak3791b.zip >> junk.txt
  :endif21

  IF EXIST %BASEDIR%\djgpp\txi46b.zip GOTO endif22
    echo get txi46b.zip >> junk.txt
  :endif22

  IF EXIST %BASEDIR%\djgpp\bnu214d.zip GOTO endif23
    echo get bnu214d.zip >> junk.txt
  :endif23

  IF EXIST %BASEDIR%\djgpp\bsn128d.zip GOTO endif24
    echo get bsn128d.zip >> junk.txt
  :endif24

  IF EXIST %BASEDIR%\djgpp\flx254d.zip GOTO endif25
    echo get flx254d.zip >> junk.txt
  :endif25

  IF EXIST %BASEDIR%\djgpp\gcc332d.zip GOTO endif26
    echo get gcc332d.zip >> junk.txt
  :endif26

  IF EXIST %BASEDIR%\djgpp\gdb53d.zip GOTO endif27
    echo get gdb53d.zip >> junk.txt
  :endif27

  IF EXIST %BASEDIR%\djgpp\mak3791d.zip GOTO endif28
    echo get mak3791d.zip >> junk.txt
  :endif28

  IF EXIST %BASEDIR%\djgpp\txi46d.zip GOTO endif29
    echo get txi46d.zip >> junk.txt
  :endif29

  echo quit >> junk.txt
  @rem ***
  @rem *** Logon & transfer the file                                       
  @rem ***
  ftp %FIREFTP% -n -s:junk.txt %DJSITE%
  rem del junk.txt

  cd %BASEDIR%\djgpp
  unzip -o *.zip

:endifDJ

if NOT %PROG%==mjb goto endifMM
  mkdir %BASEDIR%\mjb
  @rem path=%path%;%BASEDIR%\mjb
  cd %BASEDIR%\mjb
  wget -nH -m -Ac,txt,htm,html,js,java,class,css -Imatth3wbishop http://www.geocities.com/matth3wbishop

  @echo The web-site at http://www.geocities.com/matth3wbishop/ has been
  @echo mirrored locally at %BASEDIR%\mjb
  @echo However only the following file extensions were retrieved
  @echo c,txt,htm,html,js,java,class,css

:endifMM

if NOT %PROG%==vim goto endifVI
  mkdir %BASEDIR%\vim
  @rem -- The line below is very XP/NT specific since it uses
  @rem -- substitutions in the variable.
  @rem path=%path:%BASEDIR%\vim\vim\vim62=%
  path=%path%;%BASEDIR%\vim\vim\vim62
  cd %BASEDIR%\vim
  wget -N ftp://ftp.vim.org/pub/vim/pc/vim62w32.zip
  wget -N ftp://ftp.vim.org/pub/vim/pc/vim62rt.zip
  unzip -o *.zip

  cd %BASEDIR%\vim\vim\vim62
  rem install -create-vimrc -install-popup -add-start-menu -install-icons -create-directories
  install

  @echo The text editor vim has (probably) been installed successfully
  @echo in the directory %BASEDIR%\vim\vim\vim62
  @echo Type vim to start it and then type :help to see how it works.
  @echo Dependencies: wget, unzip
  @echo In some versions of windows you will have to set your Path
  @echo variable to the directory above.
:endifVI




if NOT %PROG%==curl goto endifCU
  mkdir %BASEDIR%\curl
  path=%path%;%BASEDIR%\curl
  cd %BASEDIR%\curl
  wget http://curl.haxx.se/download/openssl-0.9.7e-win32-bin.zip
  wget http://curl.haxx.se/download/curl-7.15.0-win32-ssl.zip

  unzip -o *.zip

  @echo Dependencies: wget, unzip
  @echo Type curl to see what the curl program
  @echo can do. 

:endifCU

if NOT %PROG%==geoftp goto endifGF
  mkdir %BASEDIR%\geoftp
  path=%path%;%BASEDIR%\geoftp
  cd %BASEDIR%\geoftp
  wget -O upload-geocities.bat -N http://www.geocities.com/matth3wbishop/eg/batch/upload-geocities.txt
  wget -O lg.txt -N http://www.geocities.com/matth3wbishop/eg/batch/lg.txt


  wget -O upload-geocities.sh -N http://www.geocities.com/matth3wbishop/eg/unix-shell/upload-geocities.txt

  wget -O login-geocities-uu.sh -N http://www.geocities.com/matth3wbishop/eg/unix-shell/login-geocities-uu.txt


  @echo ==========================================
  @echo The command line interface to uploading to a geocities free
  @echo account has (probably) been installed successfully in the
  @echo directory %BASEDIR%\geoftp
  @echo Dependencies: wget, curl, unixtools
  @echo Type 
  @echo   login-geocities [matthews-password]
  @echo or maybe
  @echo   lg [matthews-password]   and then type
  @echo   upload-geocities [file-to-upload] [target-directory]
  @echo This will upload a file to the site
  @echo   http://www.geocities.com/matth3wbishop/ which is a free geocities
  @echo web account. This script can upload to any account given the 
  @echo password, but I have not really configured this properly yet.
  @echo ==========================================


:endifGF


if NOT %PROG%==retrovox goto endifRV
  mkdir %BASEDIR%\retrovox
  cd %BASEDIR%\retrovox
  set RETROCODE=retrovox-manage-dir
  set RETRODATA=retrovox-product-data-dir
  set RETROSITE=http://www.retrovox.com.au/manage/
  wget -N http://www.retrovox.com.au/manage/%RETROCODE%.tar.gz
  wget -N http://www.retrovox.com.au/manage/%RETRODATA%.tar.gz
 
  gunzip *.gz 
  tar -xvf %RETROCODE%.tar
  tar -xvf %RETRODATA%.tar

  @echo ==========================================
  @echo The code for the retrovox system has been unpacked 
  @echo in the directory %BASEDIR%\retrovox
  @echo In order to unpack this code a tar and gunzip program is
  @echo is needed which is why the unixtools package is required
  @echo Dependencies: wget, unixtools, 
  @echo ==========================================
:endifRV

goto end

:error1
  @echo Error 1 occurred
goto end

:error2
  @echo Error 2 occurred
goto end

:end

echo doskey >> \autoexec.bat
echo path=%path% >> \autoexec.bat

cd %BASEDIR%