/* ----------------------------------------------------------------------- */ /* install NAMED under OS/2 eCS */ /* Author: F. Hodel A-Net GmbH, www.anetgmbh.ch */ /* use at your own risk! Please save your data fist! */ /* ----------------------------------------------------------------------- */ /* */ /* activate REXX Utils */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs '@echo off' /* ----------------------------------------------------------------------- */ say '' say 'This script does the following:' say '- tries to find the current hostname of this system' say '- tries to find the current name of its domain' say '- checks if EMX is installed' say '- asks for the installation directory, default is (c:\a\named)' say '- copies the programs into this directory' say '- adds the path to config.sys' say '- creates a basic configuration file \mptn\etc\named.conf' say '- creates directories in \var\lib\named (as in Linux)' say '- can add the zone (xxx.intern) to \mptn\etc\named.conf' say '- can create the master zone file \var\lib\named\master\xxx.intern' say '' say '(press any key to continue...)' pull . /* ----------------------------------------------------------------------- */ /* determine source drive for installation (CD or LAN drive) */ /* source directory should be ..\named (from cmd directory) */ 'cd ..\named' cddrv=directory() /* current directory (= source dir) */ say 'Quell-Laufwerk ist' cddrv /* determine boot drive */ bootdrv = SysBootDrive() say 'Boot drive is ' bootdrv say '' /* extract hostname from environment variable HOSTNAME */ hostname = VALUE('HOSTNAME',,OS2ENVIRONMENT) say 'Hostname currently is: ' hostname /* determine current domain name from \mptn\etc\resolv2 */ oldcfg=bootdrv||'\mptn\etc\resolv2' domain='xxxx.intern' /* read resolv2 line by line */ do while lines(oldcfg) line=linein(oldcfg) /* read line */ if pos('domain ',line) <> 0 then do /* domain found */ parse var line part1 ' ' domain domain=strip(domain) /* remove blanks */ say 'actual domain is:' domain end /* if pos */ end /* do while lines */ /* close files */ call stream oldcfg,'c','close' /* ----------------------------------------------------------------------- */ /* Ask for desired domain name */ /* ----------------------------------------------------------------------- */ do forever say ' ' say ' ' say 'For what zone should this name server be the master?' say '----------------------------------------------------' say '(enter the domain name in lower case letters e.g.. xxxx.intern)' say '(without entering a domain the zone will be:) ' domain say ' ' parse pull answer3 if answer3<>'' then do parse var answer3 part1 '.' part2 if part2='' then do say 'the domain name MUST have at least one . (period) in it' say answer3 'does not hav one . (period)!' end /* then do */ else do domain=answer3 say 'domain name is: ' domain leave end /* else do */ end /* if answer3 */ else leave end /* do forever */ /* ----------------------------------------------------------------------- */ /* ask for the name of this server */ /* ----------------------------------------------------------------------- */ do forever say ' ' say ' ' say 'What ist the name of this server?' say '---------------------------------' say '(enter server name in lower case letters, without any . (period) in it).' say 'e.g. dns1' say '(without entry the name will be:) ' hostname say ' ' parse pull answer4 if answer4<>'' then do parse var answer4 part1 '.' part2 if part2='' then do hostname=answer3 leave end /* then do */ else do say 'the name of the server cannot contain a . (period)! ' answer3 say ' ' end /* else do */ end /* if answer3 */ else leave end /* do forever */ /* ----------------------------------------------------------------------- */ /* IP address of this DNS */ /* ----------------------------------------------------------------------- */ ipaddr='0.0.0.0' infile=bootdrv||'\ipaddr.txt' 'netstat -a > ' infile do while lines(infile) line=linein(infile) if pos('addr ',line) <> 0 then do /* Blank after addr is important */ parse var line adresse ' ' addr 'Interface' rest /* english MPTS V5.1 */ addr = strip(addr) /* remove all blanks */ if addr<>'127.0.0.1' then ipaddr=addr end /*do */ end /* do while lines */ /* close files */ call stream infile,'c','close' 'erase ' bootdrv||'\ipaddr.txt' say ' ' say 'IP address of this server is: ' ipaddr /* ----------------------------------------------------------------------- */ /* eMail address of person responsible for this DNS */ /* ----------------------------------------------------------------------- */ do forever say ' ' say ' ' say 'Enter the e-Mail address of the person responsible for this server?' say '-------------------------------------------------------------------' say '(enter e-Mail address in lower case)' say '(without entry it will be:) info@'||domain say ' ' mailaddr='info.'||domain parse pull answer5 if answer5<>'' then do parse var answer5 part1 '@' part2 '.' part3 if part2='' then do say '@ is missing in e-Mail address, this is required, e.g. yyy@xxx.ccc' end /* then do */ else do if part4='' then do say '. is missing, please enter address in the form of yyy@xxx.ccc' end /* then do */ else do mailaddr=part1||'.'||part2||'.'||part3 leave end /* else do */ end /* else do */ end /* if answer3 */ else leave end /* do forever */ say 'eMail address is: ' mailaddr say ' ' /* ----------------------------------------------------------------------- */ /* create \mptn\etc\named.conf */ /* ----------------------------------------------------------------------- */ say ' ' say 'creating config file \mptn\etc\named.conf :' /* forward lookup zone file for this domain */ 'xcopy 'cddrv||'\a-net\named.conf' bootdrv||'\mptn\etc\' 'echo zone "'||domain||'" IN { >>' bootdrv||'\mptn\etc\named.conf' 'echo type master; >>' bootdrv||'\mptn\etc\named.conf' 'echo file "master/'||domain||'"; >>' bootdrv||'\mptn\etc\named.conf' 'echo }; >>' bootdrv||'\mptn\etc\named.conf' /* reverse lookup zone file for this subnet */ parse var ipaddr ip1 '.' ip2 '.' ip3 '.' ip4 reversefile=ip3||'.'||ip2||'.'||ip1||'.in-addr.arpa' 'echo zone "'||reversefile||'" IN { >>' bootdrv||'\mptn\etc\named.conf' 'echo type master; >>' bootdrv||'\mptn\etc\named.conf' 'echo file "master/'||reversefile||'"; >>' bootdrv||'\mptn\etc\named.conf' 'echo }; >>' bootdrv||'\mptn\etc\named.conf' /* ----------------------------------------------------------------------- */ /* zone files are created */ /* ----------------------------------------------------------------------- */ say ' ' say 'creating master zone file for domain: ' domain say 'host www.'||domain||' is added as an alias (CNAME)' say ' ' 'md ' bootdrv||'\var' 'md ' bootdrv||'\var\lib' 'md ' bootdrv||'\var\tmp' /* for log files */ 'md ' bootdrv||'\var\lib\named' 'md ' bootdrv||'\var\lib\named\master' 'md ' bootdrv||'\var\lib\named\slave' 'copy ' cddrv||'\a-net\0.0.127.zone ' bootdrv||'\var\lib\named\' 'copy ' cddrv||'\a-net\localhost.zone ' bootdrv||'\var\lib\named\' 'copy ' cddrv||'\a-net\root.hint ' bootdrv||'\var\lib\named\' /* Master zone file for domain */ 'echo $TTL 1D > ' bootdrv||'\var\lib\named\master\'||domain 'echo @ IN SOA ' hostname||'.'||domain||'.' mailaddr||'. ( >> ' bootdrv||'\var\lib\named\master\'||domain 'echo 2005013000 ; Seriennummer YYYYMMDDxx >> ' bootdrv||'\var\lib\named\master\'||domain 'echo 3H ; refresh >> ' bootdrv||'\var\lib\named\master\'||domain 'echo 1H ; retry >> ' bootdrv||'\var\lib\named\master\'||domain 'echo 1W ; expiry >> ' bootdrv||'\var\lib\named\master\'||domain 'echo 1D ) ; minimum >> ' bootdrv||'\var\lib\named\master\'||domain 'echo IN NS ' ||hostname||' >> ' bootdrv||'\var\lib\named\master\'||domain 'echo '||hostname||' IN A ' ||ipaddr||' >> ' bootdrv||'\var\lib\named\master\'||domain 'echo www IN CNAME ' ||hostname||' >> ' bootdrv||'\var\lib\named\master\'||domain /* Master reverslookup zone file for subnet */ 'echo $TTL 1D > ' bootdrv||'\var\lib\named\master\'||reversefile 'echo @ IN SOA ' hostname||'.'||domain||'.' mailaddr||'. ( >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo 2005013000 ; Seriennummer YYYYMMDDxx >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo 3H ; refresh >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo 1H ; retry >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo 1W ; expiry >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo 1D ) ; minimum >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo IN NS ' ||hostname||'.'||domain||'. >> ' bootdrv||'\var\lib\named\master\'||reversefile 'echo '||ip4||' IN PTR ' ||hostname||'.'||domain||'. >> ' bootdrv||'\var\lib\named\master\'||reversefile /* ----------------------------------------------------------------------- */ /* check, if emx is already installed on system */ /* ----------------------------------------------------------------------- */ say 'looking for EMX ...' rc=SysFileTree(bootdrv||'\emxlibcm.dll','emxloc.','FS') /* search for emxlibcm.dll */ if rc==0 then do say 'EMX seems to be installed at: ' say emxloc.1 end /* if rc==0 */ else do say 'EMX must be installed' signal ende end /* else */ /* copy files */ drive=bootdrv nameddir='\a\named' /* named directory OS/2 style */ say ' ' say '+--------------------------------------------+' say 'I select installation drive letter I' say '+--------------------------------------------+' say 'named will be installed in ' drive||nameddir say '[Enter] if o.k.,' say 'otherwise enter drive letter:' pull answer if answer=='' then answer='C' if answer<>'' then do if substr(answer,length(answer),1) == ':' /* : at line end */ then dd = '' else dd = ':' drive=answer||dd end /* if answer */ say 'Choose a different installation directory, otherwise [Enter]' parse pull answer2 if answer2<>'' then do if substr(answer2,length(answer2),1) == '\' /* remove \ at the end */ then answer2=substr(answer2,1,length(answer2)-1) if substr(answer2,1,1) == '\' /* \ at the beginning */ then answer2=substr(answer2,2,length(answer2)) nameddir='\'||answer2 end /* if answer2 */ nameddir = strip(nameddir) /* remove all Blanks */ say 'named is now copied to ' drive||nameddir||'\' call SysSleep(4) say ' ' 'xcopy ' cddrv||'\. ' drive||nameddir||'\ /s' /* copy program files */ /* ----------------------------------------------------------------------- */ /* add program directory to path in config.sys */ /* ----------------------------------------------------------------------- */ oldcfg=bootdrv||'\config.sys' newcfg=bootdrv||'\config.new' 'if exist ' newcfg ' erase ' newcfg /* read CONFIG.SYS line by line */ do while lines(oldcfg) line=linein(oldcfg) /* read line */ linenew=translate(line) /* convert to upper case */ if pos('SET PATH=',linenew) <> 0 then do /* PATH found */ /* search existing named Path in PATH */ namedfound='0' parse upper var line anfang '=' rest anfang = space(anfang) /* remove possible double blanks */ do while rest \= '' parse upper var rest next ';' rest if next==nameddir then namedfound='1' end /* do while */ if namedound='1' then do say 'PATH found with: ' nameddir ' no changes made' end /* then do */ else do say 'the following PATH is added ' nameddir if substr(line,length(line),1) == ';' /* ; at line end */ then sc = '' else sc = ';' line=line||sc||drive||nameddir||';' end /* else do */ end /* if pos */ call lineout newcfg,line /* write changed lines */ end /* do while lines */ /* close files */ call stream oldcfg,'c','close' call stream newcfg,'c','close' /* ----------------------------------------------------------------------- */ /* create Menu */ /* ----------------------------------------------------------------------- */ bootdrv 'cd ' nameddir 'start ' bootdrv||nameddir||'\makefolder.cmd' /* ----------------------------------------------------------------------- */ /* display message for required reboot */ /* ----------------------------------------------------------------------- */ say ' ' if namedfound='0' then do 'copy ' oldcfg bootdrv||'\config.named' /* save old CONFIG.SYS */ 'copy ' newcfg oldcfg say 'old CONFIG.SYS saved as CONFIG.NAMED' say 'CONFIG.SYS has been changed, please reboot now' say ' -----------------' end /* if namefound */ ende: parse var cddrv ndrive ':' rest ndrive||':' 'cd \'