1 --- a/hardware/OpenZWave.cpp
2 +++ b/hardware/OpenZWave.cpp
3 @@ -948,7 +948,7 @@ bool COpenZWave::OpenSerialConnector()
7 - std::string ConfigPath = szStartupFolder + "Config/";
8 + std::string ConfigPath = "/usr/share/domoticz/openzwave/";
9 std::string UserPath = ConfigPath;
10 if (szStartupFolder != szUserDataFolder)
12 --- a/main/EventSystem.cpp
13 +++ b/main/EventSystem.cpp
14 @@ -33,7 +33,7 @@ extern "C" {
18 -extern std::string szUserDataFolder;
19 +extern std::string szScriptsFolder;
20 extern http::server::CWebServerHelper m_webservers;
22 static std::string m_printprefix;
23 @@ -149,7 +149,7 @@ void CEventSystem::StartEventSystem()
24 GetCurrentScenesGroups();
25 GetCurrentUserVariables();
27 - Plugins::PythonEventsInitialize(szUserDataFolder);
28 + Plugins::PythonEventsInitialize(szScriptsFolder);
31 m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CEventSystem::Do_Work, this)));
32 @@ -181,9 +181,9 @@ void CEventSystem::LoadEvents()
34 std::string dzv_Dir,s;
36 - dzv_Dir = szUserDataFolder + "scripts\\dzVents\\generated_scripts\\";
37 + dzv_Dir = szScriptsFolder + "dzVents\\generated_scripts\\";
39 - dzv_Dir = szUserDataFolder + "scripts/dzVents/generated_scripts/";
40 + dzv_Dir = szScriptsFolder + "dzVents/generated_scripts/";
42 boost::unique_lock<boost::shared_mutex> eventsMutexLock(m_eventsMutex);
43 _log.Log(LOG_STATUS, "EventSystem: reset all events...");
44 @@ -274,18 +274,18 @@ void CEventSystem::LoadEvents()
45 void CEventSystem::Do_Work()
48 - m_lua_Dir = szUserDataFolder + "scripts\\lua\\";
49 - m_dzv_Dir = szUserDataFolder + "scripts\\dzVents\\runtime\\";
50 + m_lua_Dir = szScriptsFolder + "lua\\";
51 + m_dzv_Dir = szScriptsFolder + "dzVents\\runtime\\";
53 - m_lua_Dir = szUserDataFolder + "scripts/lua/";
54 - m_dzv_Dir = szUserDataFolder + "scripts/dzVents/runtime/";
55 + m_lua_Dir = szScriptsFolder + "lua/";
56 + m_dzv_Dir = szScriptsFolder + "dzVents/runtime/";
61 - m_python_Dir = szUserDataFolder + "scripts\\python\\";
62 + m_python_Dir = szScriptsFolder + "python\\";
64 - m_python_Dir = szUserDataFolder + "scripts/python/";
65 + m_python_Dir = szScriptsFolder + "python/";
68 m_stoprequested = false;
69 @@ -1426,9 +1426,9 @@ void CEventSystem::EvaluateEvent(const s
71 std::string dzv_scripts;
73 - dzv_scripts = szUserDataFolder + "scripts\\dzVents\\scripts\\";
74 + dzv_scripts = szScriptsFolder + "dzVents\\scripts\\";
76 - dzv_scripts = szUserDataFolder + "scripts/dzVents/scripts/";
77 + dzv_scripts = szScriptsFolder + "dzVents/scripts/";
79 DirectoryListing(FileEntries, dzv_scripts, false, true);
80 for (itt = FileEntries.begin(); itt != FileEntries.end(); ++itt)
81 @@ -2404,7 +2404,7 @@ bool CEventSystem::parseBlocklyActions(c
84 if (sPath.find("/") != 0)
85 - sPath = szUserDataFolder + "scripts/" + sPath;
86 + sPath = szScriptsFolder + sPath;
89 m_sql.AddTaskItem(_tTaskItem::ExecuteScript(0.2f, sPath, sParam));
90 @@ -3508,11 +3508,11 @@ void CEventSystem::EvaluateLua(const std
92 std::stringstream lua_DirT;
94 - lua_DirT << szUserDataFolder <<
95 + lua_DirT << szScriptsFolder <<
97 - "scripts\\dzVents\\";
100 - "scripts/dzVents/";
104 lua_pushstring(lua_state, "script_path");
105 @@ -4695,9 +4695,9 @@ namespace http {
107 std::stringstream template_file;
109 - template_file << szUserDataFolder << "scripts\\templates\\" << eventType << "." << interpreter;
110 + template_file << szScriptsFolder << "templates\\" << eventType << "." << interpreter;
112 - template_file << szUserDataFolder << "scripts/templates/" << eventType << "." << interpreter;
113 + template_file << szScriptsFolder << "templates/" << eventType << "." << interpreter;
116 std::stringstream template_content;
117 --- a/main/LuaHandler.cpp
118 +++ b/main/LuaHandler.cpp
119 @@ -22,7 +22,7 @@ extern "C" {
120 #include "mainworker.h"
121 #include "../hardware/hardwaretypes.h"
123 -extern std::string szUserDataFolder;
124 +extern std::string szScriptsFolder;
126 int CLuaHandler::l_domoticz_updateDevice(lua_State* lua_state)
128 @@ -155,9 +155,9 @@ bool CLuaHandler::executeLuaScript(const
130 std::stringstream lua_DirT;
132 - lua_DirT << szUserDataFolder << "scripts\\lua_parsers\\";
133 + lua_DirT << szScriptsFolder << "lua_parsers\\";
135 - lua_DirT << szUserDataFolder << "scripts/lua_parsers/";
136 + lua_DirT << szScriptsFolder << "lua_parsers/";
138 std::string lua_Dir = lua_DirT.str();
140 --- a/main/SQLHelper.cpp
141 +++ b/main/SQLHelper.cpp
142 @@ -633,6 +633,7 @@ const char *sqlCreateMobileDevices =
143 "[LastUpdate] DATETIME DEFAULT(datetime('now', 'localtime'))"
146 +extern std::string szScriptsFolder;
147 extern std::string szUserDataFolder;
149 CSQLHelper::CSQLHelper(void)
150 @@ -3683,9 +3684,9 @@ uint64_t CSQLHelper::UpdateValueInt(cons
151 //Execute possible script
152 std::string scriptname;
154 - scriptname = szUserDataFolder + "scripts\\domoticz_main.bat";
155 + scriptname = szScriptsFolder + "domoticz_main.bat";
157 - scriptname = szUserDataFolder + "scripts/domoticz_main";
158 + scriptname = szScriptsFolder + "domoticz_main";
160 if (file_exist(scriptname.c_str()))
162 @@ -6641,7 +6642,7 @@ bool CSQLHelper::HandleOnOffAction(const
163 std::string scriptname = OnAction.substr(9);
165 if (scriptname.find("/") != 0)
166 - scriptname = szUserDataFolder + "scripts/" + scriptname;
167 + scriptname = szScriptsFolder + scriptname;
169 std::string scriptparams="";
171 @@ -6675,7 +6676,7 @@ bool CSQLHelper::HandleOnOffAction(const
172 std::string scriptname = OffAction.substr(9);
174 if (scriptname.find("/") != 0)
175 - scriptname = szUserDataFolder + "scripts/" + scriptname;
176 + scriptname = szScriptsFolder + scriptname;
178 std::string scriptparams = "";
179 int pindex = scriptname.find(' ');
180 --- a/main/WebServer.cpp
181 +++ b/main/WebServer.cpp
184 #define round(a) ( int ) ( a + .5 )
186 +extern std::string szScriptsFolder;
187 extern std::string szUserDataFolder;
188 extern std::string szWWWFolder;
190 @@ -2987,9 +2988,9 @@ namespace http {
191 if (scriptname.find("..") != std::string::npos)
194 - scriptname = szUserDataFolder + "scripts\\" + scriptname;
195 + scriptname = szScriptsFolder + scriptname;
197 - scriptname = szUserDataFolder + "scripts/" + scriptname;
198 + scriptname = szScriptsFolder + scriptname;
200 if (!file_exist(scriptname.c_str()))
202 --- a/main/domoticz.cpp
203 +++ b/main/domoticz.cpp
204 @@ -136,6 +136,7 @@ static const _facilities facilities[] =
206 std::string logfacname = "user";
208 +std::string szScriptsFolder;
209 std::string szStartupFolder;
210 std::string szUserDataFolder;
211 std::string szWWWFolder;
212 @@ -696,6 +697,19 @@ int main(int argc, char**argv)
213 szUserDataFolder = szroot;
216 + szScriptsFolder=szStartupFolder;
217 + if (cmdLine.HasSwitch("-scripts"))
219 + if (cmdLine.GetArgumentCount("-scripts") != 1)
221 + _log.Log(LOG_ERROR, "Please specify a path for scripts directory");
224 + std::string szroot = cmdLine.GetSafeArgument("-scripts", 0, "");
225 + if (szroot.size() != 0)
226 + szScriptsFolder = szroot;
229 if (cmdLine.HasSwitch("-startupdelay"))
231 if (cmdLine.GetArgumentCount("-startupdelay") != 1)
232 --- a/main/mainworker.cpp
233 +++ b/main/mainworker.cpp
236 #define round(a) ( int ) ( a + .5 )
238 +extern std::string szScriptsFolder;
239 extern std::string szStartupFolder;
240 extern std::string szUserDataFolder;
241 extern std::string szWWWFolder;
242 @@ -1473,8 +1474,8 @@ void MainWorker::Do_Work()
243 m_sql.GetPreferencesVar("ReleaseChannel", nValue);
244 bool bIsBetaChannel = (nValue != 0);
246 - std::string scriptname = szUserDataFolder + "scripts/download_update.sh";
247 - std::string strparm = szUserDataFolder;
248 + std::string scriptname = szScriptsFolder + "download_update.sh";
249 + std::string strparm = szScriptsFolder;
253 --- a/notifications/NotificationHTTP.cpp
254 +++ b/notifications/NotificationHTTP.cpp
256 #include "../main/SQLHelper.h"
257 #include "../main/Logger.h"
259 -extern std::string szUserDataFolder;
260 +extern std::string szScriptsFolder;
262 CNotificationHTTP::CNotificationHTTP() : CNotificationBase(std::string("http"), OPTIONS_NONE)
264 @@ -105,7 +105,7 @@ bool CNotificationHTTP::SendMessageImple
265 std::string scriptparams = "";
267 if (scriptname.find("/") != 0)
268 - scriptname = szUserDataFolder + "scripts/" + scriptname;
269 + scriptname = szScriptsFolder + scriptname;
272 uPos = scriptname.find(" ");
273 --- a/push/GooglePubSubPush.cpp
274 +++ b/push/GooglePubSubPush.cpp
275 @@ -22,7 +22,7 @@ extern "C" {
276 using namespace boost::python;
279 -extern std::string szUserDataFolder;
280 +extern std::string szScriptsFolder;
282 // this should be filled in by the preprocessor
283 extern const char * Python_exe;
284 @@ -231,11 +231,11 @@ void CGooglePubSubPush::DoGooglePubSubPu
286 #ifdef ENABLE_PYTHON_DECAP
288 - python_DirT << szUserDataFolder << "scripts\\python\\";
289 - std::string filename = szUserDataFolder + "scripts\\python\\" + "googlepubsub.py";
290 + python_DirT << szScriptsFolder << "python\\";
291 + std::string filename = szScriptsFolder + "python\\" + "googlepubsub.py";
293 - python_DirT << szUserDataFolder << "scripts/python/";
294 - std::string filename = szUserDataFolder + "scripts/python/" + "googlepubsub.py";
295 + python_DirT << szScriptsFolder << "python/";
296 + std::string filename = szScriptsFolder + "python/" + "googlepubsub.py";
300 --- a/hardware/EvohomeScript.cpp
301 +++ b/hardware/EvohomeScript.cpp
306 -extern std::string szUserDataFolder;
307 +extern std::string szScriptsFolder;
310 CEvohomeScript::CEvohomeScript(const int ID)
311 @@ -143,7 +143,7 @@ void CEvohomeScript::RunScript(const cha
312 std::string scriptname = OnAction.substr(9);
314 if (scriptname.find("/") != 0)
315 - scriptname = szUserDataFolder + "scripts/" + scriptname;
316 + scriptname = szScriptsFolder + "scripts/" + scriptname;
318 std::string scriptparams="";
320 --- a/main/EventsPythonModule.cpp
321 +++ b/main/EventsPythonModule.cpp
324 int PythonEventsInitalized = 0;
326 - bool PythonEventsInitialize(std::string szUserDataFolder) {
327 + bool PythonEventsInitialize(std::string szScriptsFolder) {
329 if (!Plugins::Py_LoadLibrary())
335 - ssPath = szUserDataFolder + "scripts\\python\\;";
336 + ssPath = szScriptsFolder + "python\\;";
338 - ssPath = szUserDataFolder + "scripts/python/:";
339 + ssPath = szScriptsFolder + "python/:";
342 std::wstring sPath = std::wstring(ssPath.begin(), ssPath.end());