/* DelShare script for Samba Server for eCS (OS/2) Copyright (C) netlabs.org 2007-2009 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Purpose: Let a remote user delete a share from a Samba Server Required smb.conf changes: [global] delete share command = x:\Samba\addshare.cmd */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs /* parse arguments into appropriate variables */ parse arg '"'smbconf'" "'sharename'"' /* determine where to put the logfile */ parse source . . scriptcmd smbpath = strip(filespec('D',scriptcmd)||filespec('P',scriptcmd),,'\') UnixRoot = strip(value('UNIXROOT',,'OS2ENVIRONMENT'),,'\') LogPath = strip(value('LOGFILES',,'OS2ENVIRONMENT'),,'\') if LogPath = "" then LogPath = strip(value('ETC',,'OS2ENVIRONMENT'),,'\')||'\samba\logs' LogFile = LogPath'\'left(filespec('N',scriptcmd),length(filespec('N',scriptcmd))-3)'log' /* translate remaining '/' into '\' */ smbconf = translate(smbconf,'\','/') newsmbconf = filespec('D',smbconf)||filespec('P',smbconf)'smb.new' ok = SysFileDelete(newsmbconf) /* indent statements by a tabulator (as testparm -v does) */ Indent = '09'x /* write logfile */ call lineout LogFile, '['date('S')' 'time()'] 'filespec('N',scriptcmd)' started.' call lineout LogFile, '['date('S')' 'time()'] smb.conf="'smbconf'"' call lineout LogFile, '['date('S')' 'time()'] new smb.conf="'newsmbconf'"' call lineout LogFile, '['date('S')' 'time()'] sharename="'sharename'"' ok = stream(smbconf, 'c','open read') /* 'msgbox 'filespec('N',scriptcmd)' 'OK */ do until lines(smbconf) = 0 smbconfline = strip(linein(smbconf)) if translate(smbconfline) = translate('['sharename']') then do /* section to delete */ smbconfline = "" do until left(smbconfline,1) = '[' | lines(smbconf) = 0 smbconfline = strip(linein(smbconf)) end end if pos(left(smbconfline,1),'[;') <> 0 then call lineout newsmbconf, smbconfline else call lineout newsmbconf, Indent||smbconfline end ok = stream(smbconf,'c','close') ok = stream(newsmbconf,'c','close') ok = SysFileDelete(smbconf) 'ren 'newsmbconf' 'filespec('N',smbconf) /* call beep 1880, 10 call beep 2440, 10 */ call lineout LogFile, '['date('S')' 'time()'] 'filespec('N',scriptcmd)' done.'