1 --- a/hardware/OpenZWave.cpp
2 +++ b/hardware/OpenZWave.cpp
3 @@ -993,7 +993,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 @@ -44,7 +44,7 @@ extern "C" {
15 using namespace boost::python;
18 -extern std::string szUserDataFolder;
19 +extern std::string szScriptsFolder;
21 CEventSystem::CEventSystem(void)
23 @@ -1086,9 +1086,9 @@ void CEventSystem::EvaluateEvent(const s
24 std::stringstream lua_DirT;
27 - lua_DirT << szUserDataFolder << "scripts\\lua\\";
28 + lua_DirT << szScriptsFolder << "lua\\";
30 - lua_DirT << szUserDataFolder << "scripts/lua/";
31 + lua_DirT << szScriptsFolder << "lua/";
34 std::string lua_Dir = lua_DirT.str();
35 @@ -1139,9 +1139,9 @@ void CEventSystem::EvaluateEvent(const s
37 std::stringstream python_DirT;
39 - python_DirT << szUserDataFolder << "scripts\\python\\";
40 + python_DirT << szScriptsFolder << "python\\";
42 - python_DirT << szUserDataFolder << "scripts/python/";
43 + python_DirT << szScriptsFolder << "python/";
46 std::string python_Dir = python_DirT.str();
47 @@ -2021,7 +2021,7 @@ bool CEventSystem::parseBlocklyActions(c
50 if (sPath.find("/") != 0)
51 - sPath = szUserDataFolder + "scripts/" + sPath;
52 + sPath = szScriptsFolder + sPath;
55 m_sql.AddTaskItem(_tTaskItem::ExecuteScript(1, sPath, sParam));
56 @@ -2133,9 +2133,9 @@ void CEventSystem::EvaluatePython(const
57 std::stringstream python_DirT;
60 - python_DirT << szUserDataFolder << "scripts\\python\\";
61 + python_DirT << szScriptsFolder << "python\\";
63 - python_DirT << szUserDataFolder << "scripts/python/";
64 + python_DirT << szScriptsFolder << "python/";
66 std::string python_Dir = python_DirT.str();
67 if(!Py_IsInitialized()) {
68 @@ -3909,9 +3909,9 @@ namespace http {
70 std::stringstream template_file;
72 - template_file << szUserDataFolder << "scripts\\templates\\" << eventType << "." << interpreter;
73 + template_file << szScriptsFolder << "templates\\" << eventType << "." << interpreter;
75 - template_file << szUserDataFolder << "scripts/templates/" << eventType << "." << interpreter;
76 + template_file << szScriptsFolder << "templates/" << eventType << "." << interpreter;
79 std::stringstream template_content;
80 --- a/main/LuaHandler.cpp
81 +++ b/main/LuaHandler.cpp
82 @@ -22,7 +22,7 @@ extern "C" {
83 #include "mainworker.h"
84 #include "../hardware/hardwaretypes.h"
86 -extern std::string szUserDataFolder;
87 +extern std::string szScriptsFolder;
89 int CLuaHandler::l_domoticz_applyXPath(lua_State* lua_state)
91 @@ -319,9 +319,9 @@ bool CLuaHandler::executeLuaScript(const
93 std::stringstream lua_DirT;
95 - lua_DirT << szUserDataFolder << "scripts\\lua_parsers\\";
96 + lua_DirT << szScriptsFolder << "lua_parsers\\";
98 - lua_DirT << szUserDataFolder << "scripts/lua_parsers/";
99 + lua_DirT << szScriptsFolder << "lua_parsers/";
101 std::string lua_Dir = lua_DirT.str();
103 --- a/main/SQLHelper.cpp
104 +++ b/main/SQLHelper.cpp
105 @@ -612,6 +612,7 @@ const char *sqlCreateMobileDevices =
106 "[LastUpdate] DATETIME DEFAULT(datetime('now', 'localtime'))"
109 +extern std::string szScriptsFolder;
110 extern std::string szUserDataFolder;
112 CSQLHelper::CSQLHelper(void)
113 @@ -3408,9 +3409,9 @@ unsigned long long CSQLHelper::UpdateVal
114 //Execute possible script
115 std::string scriptname;
117 - scriptname = szUserDataFolder + "scripts\\domoticz_main.bat";
118 + scriptname = szScriptsFolder + "domoticz_main.bat";
120 - scriptname = szUserDataFolder + "scripts/domoticz_main";
121 + scriptname = szScriptsFolder + "domoticz_main";
123 if (file_exist(scriptname.c_str()))
125 @@ -6460,7 +6461,7 @@ bool CSQLHelper::HandleOnOffAction(const
126 std::string scriptname = OnAction.substr(9);
128 if (scriptname.find("/") != 0)
129 - scriptname = szUserDataFolder + "scripts/" + scriptname;
130 + scriptname = szScriptsFolder + scriptname;
132 std::string scriptparams="";
134 @@ -6492,7 +6493,7 @@ bool CSQLHelper::HandleOnOffAction(const
135 std::string scriptname = OffAction.substr(9);
137 if (scriptname.find("/") != 0)
138 - scriptname = szUserDataFolder + "scripts/" + scriptname;
139 + scriptname = szScriptsFolder + scriptname;
141 std::string scriptparams="";
142 int pindex=scriptname.find(' ');
143 --- a/main/WebServer.cpp
144 +++ b/main/WebServer.cpp
147 #define round(a) ( int ) ( a + .5 )
149 +extern std::string szScriptsFolder;
150 extern std::string szUserDataFolder;
151 extern std::string szWWWFolder;
153 @@ -2614,9 +2615,9 @@ namespace http {
154 if (scriptname.find("..") != std::string::npos)
157 - scriptname = szUserDataFolder + "scripts\\" + scriptname;
158 + scriptname = szScriptsFolder + scriptname;
160 - scriptname = szUserDataFolder + "scripts/" + scriptname;
161 + scriptname = szScriptsFolder + scriptname;
163 if (!file_exist(scriptname.c_str()))
165 --- a/main/domoticz.cpp
166 +++ b/main/domoticz.cpp
167 @@ -135,6 +135,7 @@ static const _facilities facilities[] =
169 std::string logfacname = "user";
171 +std::string szScriptsFolder;
172 std::string szStartupFolder;
173 std::string szUserDataFolder;
174 std::string szWWWFolder;
175 @@ -603,6 +604,19 @@ int main(int argc, char**argv)
176 szUserDataFolder = szroot;
179 + szScriptsFolder=szStartupFolder;
180 + if (cmdLine.HasSwitch("-scripts"))
182 + if (cmdLine.GetArgumentCount("-scripts") != 1)
184 + _log.Log(LOG_ERROR, "Please specify a path for scripts directory");
187 + std::string szroot = cmdLine.GetSafeArgument("-scripts", 0, "");
188 + if (szroot.size() != 0)
189 + szScriptsFolder = szroot;
192 if (cmdLine.HasSwitch("-startupdelay"))
194 if (cmdLine.GetArgumentCount("-startupdelay") != 1)
195 --- a/main/mainworker.cpp
196 +++ b/main/mainworker.cpp
199 #define round(a) ( int ) ( a + .5 )
201 +extern std::string szScriptsFolder;
202 extern std::string szStartupFolder;
203 extern std::string szUserDataFolder;
204 extern std::string szWWWFolder;
205 @@ -1394,8 +1395,8 @@ void MainWorker::Do_Work()
206 m_sql.GetPreferencesVar("ReleaseChannel", nValue);
207 bool bIsBetaChannel = (nValue != 0);
209 - std::string scriptname = szUserDataFolder + "scripts/download_update.sh";
210 - std::string strparm = szUserDataFolder;
211 + std::string scriptname = szScriptsFolder + "download_update.sh";
212 + std::string strparm = szScriptsFolder;
216 --- a/notifications/NotificationHTTP.cpp
217 +++ b/notifications/NotificationHTTP.cpp
219 #include "../main/SQLHelper.h"
220 #include "../main/Logger.h"
222 -extern std::string szUserDataFolder;
223 +extern std::string szScriptsFolder;
225 CNotificationHTTP::CNotificationHTTP() : CNotificationBase(std::string("http"), OPTIONS_NONE)
227 @@ -97,7 +97,7 @@ bool CNotificationHTTP::SendMessageImple
228 std::string scriptparams = "";
230 if (scriptname.find("/") != 0)
231 - scriptname = szUserDataFolder + "scripts/" + scriptname;
232 + scriptname = szScriptsFolder + scriptname;
235 uPos = scriptname.find(" ");
236 --- a/push/GooglePubSubPush.cpp
237 +++ b/push/GooglePubSubPush.cpp
238 @@ -20,7 +20,7 @@ extern "C" {
239 using namespace boost::python;
242 -extern std::string szUserDataFolder;
243 +extern std::string szScriptsFolder;
245 // this should be filled in by the preprocessor
246 extern const char * Python_exe;
247 @@ -222,11 +222,11 @@ void CGooglePubSubPush::DoGooglePubSubPu
251 - python_DirT << szUserDataFolder << "scripts\\python\\";
252 - std::string filename = szUserDataFolder + "scripts\\python\\" + "googlepubsub.py";
253 + python_DirT << szScriptsFolder << "python\\";
254 + std::string filename = szScriptsFolder + "python\\" + "googlepubsub.py";
256 - python_DirT << szUserDataFolder << "scripts/python/";
257 - std::string filename = szUserDataFolder + "scripts/python/" + "googlepubsub.py";
258 + python_DirT << szScriptsFolder << "python/";
259 + std::string filename = szScriptsFolder + "python/" + "googlepubsub.py";