This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cygwin installation batch file?

First, a few apologies...
- I just joined this mailing list, so this reply is cobbled 
together using the original message from the archives.
- Though I've used cygwin for several years as an administrative 
user, I'm brand new to using cygwin in any complex ways
- I'm not at all skilled at Windows batch files (this is my first one...)

With that said, I have a similar need to what (the other) Mike needed
to do -- namely the ability to install cygwin in a "batch" mode, preferably
an autostart CD. My goal is to have ssh running at the completion.

In particular, the problem I tried to address was how to install something
other than the set of packages that setup.exe chooses by default.

After searching the archives, I found two suggested approaches:

- Igor suggested that one could have one dummy package in the "Base" 
category and make it depend on everything you want.

- Fergus' approach was to create a "template" installed.db listing 
only those packages you want, with the version numbers of each set to zero. 
For example
rxvt rxvt-0.tar.bz2 0
tar tar-0.tar.bz2 0
Setup.exe will find this file and update each listed package to the 
current (non-zero) version.

Since making the dummy package in setup.ini would require some magic 
to edit setup.ini (downloaded fresh with each execution of setup.exe??) 
on the fly that I couldn't quite figure out how to do, I chose the latter 

With the goal of getting sshd completely up and running, I used the 
procedure described at 
and attempted to turn it in to a batch file.

One tool that I could not find in cygwin was a way to set the Windows 
System Environment variables. For ssh it looks like both PATH and CYGWIN 
need to be updated/created. To get this done, I used setenv.exe 
from which looks quite old, is only 
available as an executable (ouch!), but solved the immediate problem. 
Suggestions welcome on how to do this better.

The following batch file is intended (haven't actually done the CD part yet)
to be put on a CD containing the following files:
- cygwin_inst.bat -- the following file
- setup.exe -- the cygwin set up program
- setenv.exe -- the program described previously to set environment
- to_be_installed.db -- the list of packages desired, with the versions set
to zero

=========== begin batch file =============
rem -- Batch install file for cygwin
rem -- MDV 9/16/06
rem -- To set system environment variables (PATH, CYGWIN), this script
depends on 
rem -- setenv.exe from
rem -- which is used instead of Microsoft setx (which is in a Windows
resource pack)
rem -- because of possible MS licensing restrictions on copying to an
install CD.
rem -- There may be a better way to do this!

rem -- CYG_MIRROR is the URL of a public or private server from where cygwin
can be downloaded.
rem -- This particular site works, but necessarily the best one... to do...
rem -- the http:// is important

set CYG_MIRROR="";

mkdir c:\cygwin

rem -- Assume that setup.exe and setenv.exe are in the working directory on
the CD when started
rem -- Copy executables from CD to disk

copy setup.exe c:\cygwin
copy setenv.exe c:\cygwin

rem -- Now put a hand-crafted installed.db in cygwin's /etc/setup
rem -- This installed.db has the list of packages desired with the revision
level set to zero
rem --   as suggested by Fergus in
rem -- For example
rem --   openssh openssh-0.tar.bz2 0

if exist c:\cygwin\etc\setup\installed.db (
	echo "cygwin already installed"
	goto end
) else (
	mkdir c:\cygwin\etc
	mkdir c:\cygwin\etc\setup
	copy to_be_installed.db c:\cygwin\etc\setup\installed.db

rem -- Instead of "goto end", above, do something more appropriate
rem -- Future work: compare the list of packages in our target
to_be_installed.db to the list of 
rem --   packages already in /etc/setup/installed.db to make sure that all
the packages that we want
rem --   are included. If not, merge them in with the rev level set to zero.

rem --   #UNTESTED bash code 
rem --   CURRENT_INSTALLED=/etc/setup/installed.db
rem --   TO_BE_INSTALLED=to_be_installed.db
rem --   cat $TO_BE_INSTALLED | while read
rem --   do
rem --   if grep $1 $CURRENT_INSTALLED
rem --   then
rem --      echo "Package " $1 " already included"
rem --   else
rem --       echo $0 >> $CURRENT_INSTALLED
rem --       echo "Added: " $0
rem --    fi
cd \cygwin

rem -- Now we can finally run setup. Though this will show a status window,
no user interaction
rem -- is required.

setup --quiet-mode --site %CYG_MIRROR% --no-shortcuts --no-desktop

rem -- Now set the Windows System environment variable PATH and CYGWIN as
noted in
rem --

setenv -m PATH "%PATH%;\cygwin\bin"
setenv -m CYGWIN "ntsec tty"

rem -- Add our new cygwin tools to the path for the remainder of this shell
set PATH=%PATH%;\cygwin\bin;\cygwin\usr\bin

rem -- In the following lines, use double quotes to insure that Windows will
not parse the 
rem --   file redirection > symbols (Windows found the > inside single

bash.exe -c "/usr/bin/mkpasswd --local > /etc/passwd"
bash.exe -c "/usr/bin/mkgroup --local > /etc/group"

rem -- Suggestion to include "tty" in CYGWIN environment variable at
rem --
rem -- How does the --cygwin option interact with the setenv CYGWIN above?

bash.exe -c "/usr/bin/ssh-host-config --yes --cygwin NTSEC"

net start sshd

rem -- cleanup
rm /setenv.exe
==============  end of batch file =================

Well that's my attempt. It seems to work (I'm not sure I could have ever
tested this without Vmware...). Comments welcome.


.	From: Mike <mikee at mikee dot ath dot cx>
.	To: cygwin at cygwin dot com
.	Date: Tue, 12 Sep 2006 00:55:55 +0000 (UTC)
.	Subject: cygwin installation batch file?
<hr size=2 width="100%" align=center> 
I have used cygwin for many years and now am in a situation
where I need/want to install it on 30 or so windows xp boxes.
Does someone have a batch file I can adapt to my situation?
I've started on one at work (no access to it at the moment)
that attempts to copy setup.exe from a local mirror I've
created, c:, mkdir \cygwin, cd \cygwin, copy \\host\cygwin\setup.exe,
and then I get into a problem trying to get setup.exe to run.

The command (at work, so I'm going from memory) I'm trying to use
is 'setup.exe --download --site http://host/cygwin --no-shortcuts
--no-desktop perl rsync cvs ssh cygserv'. I am following up the
installation with cd bin, bash.exe --login -i -c '/usr/bin/mkpasswd
--local > /etc/passwd', bash --login -i -c '/usr/bin/mkgroup
--local > /etc/group', bash ... wait, this is confusing...

mkdir \cygwin
cd \cygwin
copy \\host\cygwin\setup.exe
setup --download --site http://host/cygwin --no-shortcuts \
               --no-desktop perl rsync cvs ssh cygserv
bash.exe --login -i -c '/usr/bin/mkpasswd --local > /etc/passwd
bash.exe --login -i -c '/usr/bin/mkgroup --local > /etc/group
bash.exe --login -i -c '/usr/bin/ssh-keygen'
bash.exe --login -i -c '/usr/bin/ssh-host-config --yes'
net start sshd

That's what I've tried so far (from memory). Does someone have
a script that does the above and works? :)


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]