.key IP,HN/K,DEST/K,MASK/K,GW/K,USER/K,SRV/S,BOOTP/S,UMASK/K,S2CF/K,S2OPT/K,IFACE/K,DEBUG/S
.bra {
.ket }
;
; AmiTCP/IP startnet script
;
; Copyright © 1994 AmiTCP/IP Group,
;                  NSDi - Network Solutions Development Inc., Finland
;                  All rights reserved.
;
; *NOTE*  NORMALLY YOU SHOULD USE THE PROVIDED CONFIGURATION UTILITY
; *NOTE*  TO CHANGE THE CONFIGURATION.  IF YOU NEED TO CHANGE THE 
; *NOTE*  CONFIGURATION MANUALLY, RESTRICT ANY MODIFICATIONS TO THIS 
; *NOTE*  "DEF" SECTION.
;
; IP address if known, _nothing_ otherwise
.def IP    
; Our full host name and aliases if known, _nothing_ otherwise
; (if this is set, the IP _must_ be set, too)
.def HN    
; The destination address, needed only if GW is not good destination
.def DEST 
; netmask if known, _nothing_ otherwise
.def MASK  
; IP address of the default gateway if known, _nothing_ otherwise
.def GW    
; Default login name
.def USER Demonoid
; User's file creation mask
.def UMASK 022
; "SRV" if servers are used, _nothing_ otherwise
.def SRV   
; "BOOTP" if bootstrap protocol is used, _nothing_ otherwise
.def BOOTP 
; Interface name
.def IFACE ppp0
; Sana-II device configuration file, _nothing_ otherwise
.def S2CF  ppp0.config
; Sana-II device configuration to be stored into the configuration file
.def S2OPT "serial.device 0 38400 0.0.0.0 MTU=1900 DIALSCRIPT=AmiTCP:bin/dialup CD 7WIRE PAP=amitcp:bin/pap,seikesda "
;
; *NOTE*  YOU SHOULD NOT NEED TO EDIT ANYTHING BELOW. IF YOU NEED TO ADD
; *NOTE*  CONFIGURATIONS OF ADDITIONAL INTERFACES OR TO START UTILITIES,
; *NOTE*  DO IT IN THE AmiTCP:db/User-Startnet.
;
; Set the failat level so that the errors can be handled by the script
FailAt 21
; Log in
echo
echo login: {USER}
AmiTCP:bin/login -f {USER}
echo Pass_01/10
AmiTCP:bin/umask {UMASK}
echo Pass_02/10
run AmiTCP:AmiTCP {DEBUG}
echo Pass_03/10
WaitForPort AMITCP
If NOT Warn
echo Pass_04/10
  ; Create Sana2 configuration file if used
  If NOT X EQ "X{S2CF}"
echo Pass_05/10
    ; Assure that ENV:Sana2 exists
    If NOT Exists ENV:Sana2
echo Pass_06/10
      MakeDir ENV:Sana2
    EndIf
    ; Create configuration file
    Echo "{S2OPT}" >ENV:Sana2/{S2CF}
  EndIf
  ; Do we need loopback?
  If X EQ "X{SRV}"
echo Pass_07/10
    Set LOOPBACK=""
  Else
echo Pass_08/10
    Set LOOPBACK="LOOPBACK"
  EndIf
  ; Configure interface
echo Pass_09/10
  AmiTCP:bin/bootpconfig {IFACE} IP {IP$*} DEST {DEST$*} MASK {MASK$*} GW {GW$*} $LOOPBACK {BOOTP} {DEBUG}
echo XXXa
  If NOT Warn
echo Pass_10/10
amitcp:caretime EVERY 30 POSY 540 MESSAGE "You have been connected for:"
echo AmiTCP now running. Start surf'n dude! :)
    If NOT X EQ "X{HN}"
      rx "address AMITCP; 'ADD HOST {IP} {HN}'"
    Else
      If NOT X EQ "X{DEBUG}"
        echo "Quering Name Server for the host name..."
      EndIf
    EndIf
    setenv HOSTNAME `AmiTCP:bin/hostname`
    Assign TCP: Exists >NIL:
    IF Warn
      Mount TCP: from AmiTCP:devs/Inet-Mountlist
    EndIf
    ; Start the internet `super server' if wanted
    If NOT X EQ "X{SRV}"
      If X EQ "X{DEBUG}"
        Run <NIL: >NIL: AmiTCP:bin/inetd
      Else
        Run AmiTCP:bin/inetd {DEBUG}
      EndIf
    EndIf
    ;
    ; Configure any additional interfaces & start utilities in 
    ; AmiTCP:db/User-Startnet
    ;
    If Exists AmiTCP:db/User-Startnet
      Execute AmiTCP:db/User-Startnet
    EndIf
  Else
    Echo Interface {IFACE} configuration failed!
    Echo Stopping AmiTCP
    AmiTCP:bin/stopnet FLUSH
  EndIf
Else
  Echo AmiTCP couldn't be started!
EndIf

; EOF
