├── .gitignore ├── Dist └── README.md ├── LICENSE ├── MicroSIP.ini ├── README.md ├── Users └── __tpl.ini ├── microsip_autoconf.js ├── updater.ini.sample └── updater.log /.gitignore: -------------------------------------------------------------------------------- 1 | /Dist/* 2 | !/Dist/README.md 3 | /Users/* 4 | !/Users/__tpl.ini -------------------------------------------------------------------------------- /Dist/README.md: -------------------------------------------------------------------------------- 1 | Download latest portable distributive from MicroSIP official site (https://www.microsip.org/downloads) and unpack files to these folder. 2 | 3 | For example, files like below: 4 | - avcodec-57.dll 5 | - avformat-57.dll 6 | - avutil-55.dll 7 | - hangup.wav 8 | - langpack_XXXXXXXX.txt 9 | - License.txt 10 | - MicroSIP Website.url 11 | - microsip.exe 12 | - msgin.wav 13 | - msgout.wav 14 | - ringing2.wav 15 | - ringing.wav 16 | - ringtone.wav 17 | - SDL2.dll 18 | - swscale-4.dll -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Denis Pantsyrev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MicroSIP.ini: -------------------------------------------------------------------------------- 1 | [Settings] 2 | disableLocalAccount=1 3 | EnableLog=0 4 | updatesInterval=never 5 | CheckUpdatesTime=1466489328 6 | denyIncoming= 7 | usersDirectory=http://phonebook.example.local 8 | SingleMode=1 9 | LocalDTMF=1 10 | autoanswer=button 11 | denyIncoming=button 12 | micAmplification=1 13 | swLevelAdjustment=1 14 | audioCodecs=PCMA/8000/1 PCMU/8000/1 15 | accountId=1 16 | [Account1] 17 | Server=voip.example.local 18 | Domain=voip.example.local 19 | Proxy= 20 | PublicAddr= 21 | ListenPort= 22 | SRTP= 23 | Transport=udp 24 | Publish=0 25 | STUN= 26 | ICE=0 27 | allowRewrite=1 28 | voicemailNumber= 29 | disableSessionTimer=0 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # microsip_autoconf 2 | MicroSIP softphone auto configuration script for using in Enterprise 3 | 4 | Allow to simplify distribution, configuring and management of softphone software in Enterprise 5 | by using simple JScript script and Group Policy 6 | 7 | ## Files and folders definitions: 8 | 9 | **Dist** - Folder with a portable version of MicroSIP. Distributed to workstations 10 | 11 | **Users** - User configuration files. '__tpl.ini' is a template file with sample of some options. 12 | Settings in this file are override all other settings (user settings on local computer and from the main MicroSIP.ini file on the server side) 13 | 14 | **MicroSIP.ini** - The main configuration file (general settings). Overlapped by settings from the user settings file (in Users dir) 15 | 16 | **microsip_autoconf.js** - Group Policy distribution file that must be run at user logon time on workstation. 17 | 18 | **updater.ini** - Some autoconf settings 19 | 20 | **updater.log** - Some log data of script execution (errors, etc) 21 | 22 | ## How it work 23 | 24 | - clone this repo in shared folder. 25 | - allow all domain users *read* permittions on all files and folders. For Users dir turn off inheritance (each user must have read access only to his config file) 26 | - allow all domain users *write* permittions on **updater.log** 27 | - rename **updater.ini.sample** to **updater.ini** and change settings (if needed) 28 | - change Group Policy to run **microsip_autoconf.js** file at user logon 29 | - change settings in **MicroSIP.ini** file (if needed) 30 | - allowedPC: Reulal expression of allowed computers. If set updater will work only on this computers (Default: .*) 31 | - desktopLink: if set true, it create link to MicroSIP.exe on desktop (Default: true) 32 | - saveUserContacts: if set false, it replaces user's **Contacts.xml** file by file **Contacts.xml** from Dist folder (Default: false) 33 | 34 | To add new user's config do these: 35 | - make a copy of **__tpl.ini** file in Users dir 36 | - rename it to **.ini** 37 | - give the user rights to read 38 | - change options in this new config file. 39 | 40 | Now, if user has his own config file in Users directory, the script will install MicroSIP distro at user's local PC and apply config settings. 41 | -------------------------------------------------------------------------------- /Users/__tpl.ini: -------------------------------------------------------------------------------- 1 | ; This is a template of user's config file 2 | 3 | [Account1] 4 | label=40000 5 | AuthID=40000 6 | Username=40000 7 | DisplayName=UserName 8 | Password=0000000000000000000000000000 -------------------------------------------------------------------------------- /microsip_autoconf.js: -------------------------------------------------------------------------------- 1 | /* ============================================================================ 2 | * MicroSIP updater script for using in Enterprise 3 | * Powered by: Denis Pantsyrev 4 | * ============================================================================ 5 | */ 6 | 7 | // Script internal variables. DO NOT CHANGE! 8 | var WSN = WScript.CreateObject('WScript.Network'); 9 | var FSO = WScript.CreateObject('Scripting.FileSystemObject'); 10 | var WSS = WScript.CreateObject('WScript.Shell'); 11 | var srvScriptDir = WScript.ScriptFullName.substring(0, WScript.ScriptFullName.lastIndexOf(WScript.ScriptName) - 1) 12 | 13 | try { 14 | // Get updater config 15 | var updaterINI = {}; 16 | ReadINIFile(updaterINI, srvScriptDir + '\\updater.ini'); 17 | var allowedPC = new RegExp(updaterINI.settings.allowedpc, "i"); 18 | var desktopLink = updaterINI.settings.desktoplink; 19 | var saveUserContacts = updaterINI.settings.saveusercontacts; 20 | 21 | // Prepare names 22 | var srvDistFolderName = 'Dist'; 23 | var srvUsersFolderName = 'Users'; 24 | var distFolderName = 'MicroSIP'; 25 | var confFileName = 'MicroSIP.ini'; 26 | var contactsFileName = 'Contacts.xml'; 27 | var execFileName = 'microsip.exe'; 28 | var lnkFileName = 'MicroSIP.lnk'; 29 | var tmpDistFolderName = 'tmp_MicroSIP'; 30 | 31 | var srvDistPath = srvScriptDir + '\\' + srvDistFolderName; 32 | var usrDistPath = WSS.ExpandEnvironmentStrings('%APPDATA%') + '\\' + distFolderName; 33 | var tmpDistPath = WSS.ExpandEnvironmentStrings('%APPDATA%') + '\\' + tmpDistFolderName; 34 | 35 | var tmpConfFile = tmpDistPath + '\\' + confFileName 36 | var tmpContactsFile = tmpDistPath + '\\' + contactsFileName; 37 | var srvMainConfFile = srvScriptDir + '\\' + confFileName; 38 | var srvUserConfFile = srvScriptDir + '\\' + srvUsersFolderName + '\\' + WSN.UserName + '.ini'; 39 | var usrConfFile = usrDistPath + '\\' + confFileName; 40 | var usrContactsFile = usrDistPath + '\\' + contactsFileName; 41 | var usrExecFile = usrDistPath + '\\' + execFileName; 42 | 43 | var mainSrvINI = {}; 44 | var usrSrvINI = {}; 45 | var usrLocINI = {}; 46 | 47 | var needRestart = 0; 48 | var cmdLine = 'taskkill.exe /FI "USERNAME eq ' + WSN.UserName + '" /IM ' + execFileName; 49 | 50 | if (!(allowedPC.test(WSN.ComputerName)) 51 | || !(FSO.FileExists(srvUserConfFile) && FSO.GetFile(srvUserConfFile).Size > 0) 52 | ) { 53 | WScript.Quit(); 54 | } 55 | 56 | // Update MicroSIP files 57 | 58 | if (FSO.FolderExists(srvDistPath)) { 59 | FSO.CopyFolder(srvDistPath, tmpDistPath); 60 | if (FSO.FileExists(usrConfFile)) { 61 | FSO.CopyFile(usrConfFile, tmpConfFile); 62 | } 63 | if ((FSO.FileExists(usrContactsFile)) && (saveUserContacts == "true")) { 64 | FSO.CopyFile(usrContactsFile, tmpContactsFile); 65 | } 66 | if (desktopLink == "true") { 67 | strDesktop = WSS.SpecialFolders('Desktop'); 68 | oMyShortcut = WSS.CreateShortcut(strDesktop + '\\' + lnkFileName); 69 | oMyShortcut.WindowStyle = 4; 70 | oMyShortcut.IconLocation = usrExecFile + ', 0'; 71 | oMyShortcut.TargetPath = usrExecFile; 72 | oMyShortcut.WorkingDirectory = usrDistPath; 73 | oMyShortcut.Save(); 74 | } 75 | } 76 | 77 | 78 | ReadINIFile(mainSrvINI, srvMainConfFile); 79 | ReadINIFile(usrSrvINI, srvUserConfFile); 80 | ReadINIFile(usrLocINI, tmpConfFile, -1); 81 | 82 | MergeINIObj(usrLocINI, mainSrvINI); 83 | MergeINIObj(usrLocINI, usrSrvINI); 84 | 85 | SaveINIFile(usrLocINI, tmpDistPath, tmpConfFile); 86 | 87 | // Update Registry to associate MicroSIP application with sip:// uri 88 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\sip\\', 'Internet Call Protocol', 'REG_SZ'); 89 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\sip\\URL Protocol', '', 'REG_SZ'); 90 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\sip\\Owner Name', 'MicroSIP', 'REG_SZ'); 91 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\sip\\DefaultIcon', usrExecFile + ',0', 'REG_SZ'); 92 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\sip\\shell\\open\\command\\', '\"' + usrExecFile + '\" %1', 'REG_SZ'); 93 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\RegisteredApplications\\MicroSIP', 'SOFTWARE\\MicroSIP\\Capabilities', 'REG_SZ'); 94 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\MicroSIP\\', usrDistPath, 'REG_SZ'); 95 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\MicroSIP\\Start Menu Folder', 'MicroSIP', 'REG_SZ'); 96 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\MicroSIP\\Capabilities\\ApplicationDescription', 'MicroSIP Softphone', 'REG_SZ'); 97 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\MicroSIP\\Capabilities\\ApplicationName', 'MicroSIP', 'REG_SZ'); 98 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\MicroSIP\\Capabilities\\UrlAssociations\\sip', 'MicroSIP', 'REG_SZ'); 99 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\MicroSIP\\', 'Internet Call Protocol', 'REG_SZ'); 100 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\MicroSIP\\DefaultIcon\\', usrExecFile + ',0', 'REG_SZ'); 101 | WSS.RegWrite('HKEY_CURRENT_USER\\SOFTWARE\\Classes\\MicroSIP\\shell\\open\\command\\', '\"' + usrExecFile + '\" %1', 'REG_SZ'); 102 | 103 | // Close microsip.exe for update if it running 104 | if (/ [0-9]+/.test(WSS.Exec(cmdLine).StdOut.ReadAll())) { 105 | needRestart = 1; 106 | WScript.Sleep(3000); 107 | } 108 | 109 | if (FSO.FolderExists(usrDistPath)) { 110 | FSO.DeleteFolder(usrDistPath, 1); 111 | } 112 | 113 | FSO.MoveFolder(tmpDistPath, usrDistPath); 114 | 115 | if (needRestart) { 116 | WSS.run(usrDistPath + '\\' + execFileName, 1, false); 117 | } 118 | 119 | } catch (e) { 120 | var curDate = new Date(); 121 | var logFile = FSO.OpenTextFile(srvScriptDir + '\\updater.log', 8, true); 122 | logFile.WriteLine('[' + curDate + '] ' + WSN.ComputerName + ' :: ' + e.name + ': ' + e.message); 123 | logFile.Close(); 124 | } 125 | 126 | 127 | 128 | // Read .ini file to object 129 | function ReadINIFile(INIObj, filename, format) { 130 | if ((FSO.FileExists(filename)) && (FSO.GetFile(filename).Size > 0)) { 131 | var fileh = FSO.OpenTextFile(filename, 1, false, format); 132 | while (!fileh.AtEndOfStream) { 133 | var line = fileh.ReadLine(); 134 | if (/^\[(\w+)\]/.test(line)) { 135 | var section = RegExp.$1.toLowerCase(); 136 | INIObj[section] = {}; 137 | } 138 | if (/^([^;#][^=]*?)\s*=\s*([^\r\n]*?)\s*$/.test(line)) { 139 | var param = RegExp.$1.toLowerCase(); 140 | var value = RegExp.$2; 141 | INIObj[section][param] = value; 142 | } 143 | } 144 | fileh.Close(); 145 | } 146 | } 147 | 148 | // Read object to .ini file 149 | function SaveINIFile(INIObj, confPath, filename) { 150 | function WriteArray(arr) { 151 | for (var i in arr) { 152 | var value = arr[i]; 153 | if (typeof (value) === 'object') { 154 | if (value) { 155 | file.Write('[' + i + ']\r\n'); 156 | WriteArray(value); 157 | } 158 | } else { 159 | if (value) { 160 | file.Write(i + '=' + value + '\r\n'); 161 | } 162 | } 163 | } 164 | } 165 | 166 | if (!FSO.FolderExists(confPath)) { 167 | FSO.CreateFolder(confPath); 168 | } 169 | var file = FSO.OpenTextFile(filename, 2, true); 170 | WriteArray(INIObj); 171 | file.Close(); 172 | } 173 | 174 | // Merge objects 175 | function MergeINIObj(firstINIObj, secondINIObj) { 176 | for (var section in secondINIObj) { 177 | if (!firstINIObj[section]) { 178 | firstINIObj[section] = {}; 179 | } 180 | for (var param in secondINIObj[section]) { 181 | if (!firstINIObj[section][param] || firstINIObj[section][param] !== secondINIObj[section][param]) { 182 | firstINIObj[section][param] = secondINIObj[section][param]; 183 | } 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /updater.ini.sample: -------------------------------------------------------------------------------- 1 | [Settings] 2 | allowedPC = .* 3 | desktopLink = true 4 | saveUserContacts = false -------------------------------------------------------------------------------- /updater.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StuxForce/microsip_autoconf/89d05d5533fa6292aaa4c38b63c80723c65e224a/updater.log --------------------------------------------------------------------------------