| 1 | /* Perform basic Samba Client init stuff */
|
|---|
| 2 |
|
|---|
| 3 | /*:VRX */
|
|---|
| 4 | _CltInit:
|
|---|
| 5 | IF options.!debug == 1 THEN say '_CltInit() started'
|
|---|
| 6 | IF options.!debug == 1 THEN say " Checking Samba setup..."
|
|---|
| 7 |
|
|---|
| 8 | /* debuglevel when executing Samba binaries */
|
|---|
| 9 | debuglevel = ' --debuglevel=0'
|
|---|
| 10 |
|
|---|
| 11 | /* Error status and file variables */
|
|---|
| 12 | ErrorState = 0 /* _ErrorBinaryNotFound() changes this variable */
|
|---|
| 13 | DataErrorState = 0 /* _ErrorDataFileNotFound() changes this variable */
|
|---|
| 14 |
|
|---|
| 15 | /* Evaluate environment */
|
|---|
| 16 | ETC = value('ETC',,'OS2ENVIRONMENT')
|
|---|
| 17 | IF options.!debug == 1 THEN say ' ETC = "'ETC'"'
|
|---|
| 18 |
|
|---|
| 19 | UnixRoot = value("UNIXROOT",,'OS2ENVIRONMENT')
|
|---|
| 20 | if UnixRoot = "" then do
|
|---|
| 21 | UnixRoot = left(ETC,length(ETC)-4)
|
|---|
| 22 | say ' WARNING! Setting missing UNIXROOT variable to "'UnixRoot'".'
|
|---|
| 23 | ok = value("UNIXROOT",UnixRoot,'OS2ENVIRONMENT')
|
|---|
| 24 | end
|
|---|
| 25 |
|
|---|
| 26 | IF options.!debug == 1 THEN say ' UnixRoot = "'UnixRoot'"'
|
|---|
| 27 |
|
|---|
| 28 | unixetc = UnixRoot'\etc'
|
|---|
| 29 | IF options.!debug == 1 THEN say ' Unixetc = "'unixetc'"'
|
|---|
| 30 |
|
|---|
| 31 | /* Find all executables */
|
|---|
| 32 |
|
|---|
| 33 | /* Get the path to this file */
|
|---|
| 34 | samba.!tools = VRParseFilename(VRGet("Application", "Program"),'DP')
|
|---|
| 35 | if samba.!tools = '' then do
|
|---|
| 36 | parse source . . script
|
|---|
| 37 | samba.!tools = VRParseFilename(script,'DP')
|
|---|
| 38 | end
|
|---|
| 39 | IF options.!debug == 1 THEN say ' Samba tools = "'samba.!tools'"'
|
|---|
| 40 | say ' Changing into "'directory(samba.!tools)'"'
|
|---|
| 41 |
|
|---|
| 42 | /* smbclient.exe */
|
|---|
| 43 | samba.!smbclientexe = ""
|
|---|
| 44 | if samba.!smbclientexe = "" then do /* in current directory? */
|
|---|
| 45 | call charout , " Are binaries in current directory? "
|
|---|
| 46 | ok = SysFileTree('.\smbclient.exe', exist.,'FO')
|
|---|
| 47 | say exist.0' (1 = Yes, 0 = No)'
|
|---|
| 48 | if exist.0 = 1 then samba.!smbclientexe = exist.1
|
|---|
| 49 | end
|
|---|
| 50 | if samba.!smbclientexe = "" then do /* in parent directory? */
|
|---|
| 51 | call charout , " Are binaries in parent directory? "
|
|---|
| 52 | ok = SysFileTree('..\smbclient.exe', exist.,'FO')
|
|---|
| 53 | say exist.0' (1 = Yes, 0 = No)'
|
|---|
| 54 | if exist.0 = 1 then samba.!smbclientexe = exist.1
|
|---|
| 55 | end
|
|---|
| 56 | if samba.!smbclientexe = "" then do /* in ..\BIN directory? */
|
|---|
| 57 | call charout , " Are binaries in ..\BIN directory? "
|
|---|
| 58 | ok = SysFileTree('..\bin\smbclient.exe', exist.,'FO')
|
|---|
| 59 | say exist.0' (1 = Yes, 0 = No)'
|
|---|
| 60 | if exist.0 = 1 then samba.!smbclientexe = exist.1
|
|---|
| 61 | end
|
|---|
| 62 | if samba.!smbclientexe = "" then do /* in SMB_EXE ? */
|
|---|
| 63 | call charout , " Are binaries in SMB_EXE path? "
|
|---|
| 64 | samba.!smbclientexe = SysSearchPath("SMB_EXE","smbclient.EXE")
|
|---|
| 65 | if samba.!smbclientexe = "" then say "No."; else say "Yes."
|
|---|
| 66 | end
|
|---|
| 67 | if samba.!smbclientexe = "" then do /* in PATH ? */
|
|---|
| 68 | call charout , " Are binaries in PATH? "
|
|---|
| 69 | samba.!smbclientexe = SysSearchPath("PATH","smbclient.EXE")
|
|---|
| 70 | if samba.!smbclientexe = "" then say "No."; else say "Yes."
|
|---|
| 71 | end
|
|---|
| 72 |
|
|---|
| 73 | if samba.!smbclientexe = "" then call _ErrorBinaryNotFound " could not find smbclient.exe!"
|
|---|
| 74 |
|
|---|
| 75 | samba.!bin = VRParseFileName(samba.!smbclientexe,'DP')
|
|---|
| 76 | IF options.!debug == 1 THEN say ' Samba binaries = "'samba.!bin'"'
|
|---|
| 77 |
|
|---|
| 78 | /* net.exe */
|
|---|
| 79 | samba.!netexe = samba.!bin'\net.exe'
|
|---|
| 80 | if \VRFileExists(samba.!netexe) then call _ErrorBinaryNotFound " could not find net.exe!"
|
|---|
| 81 | IF options.!debug == 1 THEN say ' net.exe = "'samba.!netexe'"'
|
|---|
| 82 |
|
|---|
| 83 | /* testparm.exe */
|
|---|
| 84 | samba.!testparmexe = samba.!bin'\testparm.exe'
|
|---|
| 85 | if \VRFileExists(samba.!testparmexe) then call _ErrorBinaryNotFound " could not find testparm.exe!"
|
|---|
| 86 | IF options.!debug == 1 THEN say ' testparm.exe = "'samba.!testparmexe'"'
|
|---|
| 87 |
|
|---|
| 88 | /* smbtree.exe */
|
|---|
| 89 | samba.!smbtreeexe = samba.!bin'\smbtree.exe'
|
|---|
| 90 | if \VRFileExists(samba.!smbtreeexe) then call _ErrorBinaryNotFound " could not find smbtree.exe!"
|
|---|
| 91 | IF options.!debug == 1 THEN say ' smbtree.exe = "'samba.!smbtreeexe'"'
|
|---|
| 92 |
|
|---|
| 93 | /* nmblookup.exe */
|
|---|
| 94 | samba.!nmblookupexe = samba.!bin'\nmblookup.exe'
|
|---|
| 95 | if \VRFileExists(samba.!nmblookupexe) then call _ErrorBinaryNotFound " could not find nmblookup.exe!"
|
|---|
| 96 | IF options.!debug == 1 THEN say ' nmblookup.exe = "'samba.!nmblookupexe'"'
|
|---|
| 97 |
|
|---|
| 98 | /* smbspool.exe */
|
|---|
| 99 | samba.!smbspoolexe = samba.!bin'\smbspool.exe'
|
|---|
| 100 | if \VRFileExists(samba.!smbspoolexe) then call _ErrorBinaryNotFound " could not find smbspool.exe!"
|
|---|
| 101 | IF options.!debug == 1 THEN say ' smbspool.exe = "'samba.!smbspoolexe'"'
|
|---|
| 102 |
|
|---|
| 103 | /* smb.conf */
|
|---|
| 104 | samba.!smbconf = ETC'\samba\smb.conf'
|
|---|
| 105 | if \VRFileExists(samba.!smbconf) then call _ErrorDataFileNotFound samba.!smbconf' is not present.'
|
|---|
| 106 | IF options.!debug == 1 THEN say ' Samba smb.conf = "'samba.!smbconf'"'
|
|---|
| 107 |
|
|---|
| 108 | /* Create these directories to make sure they do exist */
|
|---|
| 109 | ok = SysMkDir(unixetc)
|
|---|
| 110 | ok = SysMkDir(etc'\samba')
|
|---|
| 111 |
|
|---|
| 112 | /* Messages from Samba will go here */
|
|---|
| 113 | samba.!error = SysTempFileName(TempDir'smb_err.???')
|
|---|
| 114 | samba.!msg = SysTempFileName(TempDir'smb_msg.???')
|
|---|
| 115 | /* Use of this file is deprecated */
|
|---|
| 116 | ErrorFile = Tempdir'smbutil.error'
|
|---|
| 117 |
|
|---|
| 118 | IF options.!debug == 1 then do
|
|---|
| 119 | if ErrorState then say " One or more basic Samba Client setup errors detected!"
|
|---|
| 120 | else say " No basic Samba Client setup errors detected!"
|
|---|
| 121 | end
|
|---|
| 122 | IF options.!debug == 1 THEN say '_CltInit() done, Errorstate = 'Errorstate
|
|---|
| 123 | return
|
|---|
| 124 |
|
|---|
| 125 | /*:VRX */
|
|---|
| 126 | _SambaFinish:
|
|---|
| 127 | /* Do some very basic housekeeping when leaving */
|
|---|
| 128 | ok = stream(samba.!msg,'c','close')
|
|---|
| 129 | ok = stream(samba.!error,'c','close')
|
|---|
| 130 | ok = SysFileDelete(samba.!msg)
|
|---|
| 131 | ok = SysFileDelete(samba.!error)
|
|---|
| 132 | return
|
|---|
| 133 |
|
|---|
| 134 | /*:VRX */
|
|---|
| 135 | _ErrorBinaryNotFound:
|
|---|
| 136 | /* Set error status variable and show a short message - incomplete! */
|
|---|
| 137 | msg = arg(1)
|
|---|
| 138 | say "ERROR: "msg
|
|---|
| 139 | id = VRMessage( VRWindow(), msg, "Samba Installation", "E" )
|
|---|
| 140 | ErrorState = (1|ErrorState)
|
|---|
| 141 | return
|
|---|
| 142 |
|
|---|
| 143 | /*:VRX */
|
|---|
| 144 | _ErrorDataFileNotFound:
|
|---|
| 145 | /* Set error status variable and show a short message - incomplete! */
|
|---|
| 146 | msg = arg(1)
|
|---|
| 147 | say "ERROR: "msg
|
|---|
| 148 | DataErrorState = (1|DataErrorState)
|
|---|
| 149 | return
|
|---|
| 150 |
|
|---|
| 151 | /*:VRX */
|
|---|
| 152 | _SambaExtendSearchPath:
|
|---|
| 153 | IF options.!debug == 1 THEN say '_SambaExtendSearchPath() started'
|
|---|
| 154 | /* Add binary and tools path to the PATH variable */
|
|---|
| 155 | old_path = value('PATH',, 'OS2ENVIRONMENT')
|
|---|
| 156 | if pos(translate(samba.!bin';'),translate(old_path)) = 0 then do
|
|---|
| 157 | if samba.!bin = samba.!tools then new_path = samba.!bin';'
|
|---|
| 158 | else new_path = samba.!bin';'samba.!tools';'
|
|---|
| 159 | ok = value('PATH', new_path || old_path, 'OS2ENVIRONMENT')
|
|---|
| 160 | drop new_path
|
|---|
| 161 | end
|
|---|
| 162 | drop old_path
|
|---|
| 163 |
|
|---|
| 164 | /* Add binary and tools path to the BEGINLIBPATH variable */
|
|---|
| 165 | old_beginlibpath = SysQueryExtLibPath("B")
|
|---|
| 166 | if pos(translate(samba.!bin';'),translate(old_beginlibpath)) = 0 then do
|
|---|
| 167 | if samba.!bin = samba.!tools then new_beginlibpath = samba.!bin';'old_beginlibpath
|
|---|
| 168 | else new_beginlibpath = samba.!bin';'samba.!tools';'old_beginlibpath
|
|---|
| 169 | ok = SysSetExtLibPath( new_beginlibpath, "B")
|
|---|
| 170 | drop new_beginlibpath
|
|---|
| 171 | end
|
|---|
| 172 | drop old_beginlibpath
|
|---|
| 173 |
|
|---|
| 174 | /* Set LIBPATHSTRICT (this is an option - disabled by default) */
|
|---|
| 175 | /* ok = value('LIBPATHSTRICT','T', 'OS2ENVIRONMENT') */
|
|---|
| 176 |
|
|---|
| 177 | IF options.!debug == 1 THEN say '_SambaExtendSearchPath() done'
|
|---|
| 178 | return
|
|---|