You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

342 lines
11 KiB

  1. --- a/hardware/OpenZWave.cpp
  2. +++ b/hardware/OpenZWave.cpp
  3. @@ -948,7 +948,7 @@ bool COpenZWave::OpenSerialConnector()
  4. m_nodes.clear();
  5. m_bNeedSave = false;
  6. - std::string ConfigPath = szStartupFolder + "Config/";
  7. + std::string ConfigPath = "/usr/share/domoticz/openzwave/";
  8. std::string UserPath = ConfigPath;
  9. if (szStartupFolder != szUserDataFolder)
  10. {
  11. --- a/main/EventSystem.cpp
  12. +++ b/main/EventSystem.cpp
  13. @@ -33,7 +33,7 @@ extern "C" {
  14. #endif
  15. }
  16. -extern std::string szUserDataFolder;
  17. +extern std::string szScriptsFolder;
  18. extern http::server::CWebServerHelper m_webservers;
  19. static std::string m_printprefix;
  20. @@ -149,7 +149,7 @@ void CEventSystem::StartEventSystem()
  21. GetCurrentScenesGroups();
  22. GetCurrentUserVariables();
  23. #ifdef ENABLE_PYTHON
  24. - Plugins::PythonEventsInitialize(szUserDataFolder);
  25. + Plugins::PythonEventsInitialize(szScriptsFolder);
  26. #endif
  27. m_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&CEventSystem::Do_Work, this)));
  28. @@ -181,9 +181,9 @@ void CEventSystem::LoadEvents()
  29. {
  30. std::string dzv_Dir,s;
  31. #ifdef WIN32
  32. - dzv_Dir = szUserDataFolder + "scripts\\dzVents\\generated_scripts\\";
  33. + dzv_Dir = szScriptsFolder + "dzVents\\generated_scripts\\";
  34. #else
  35. - dzv_Dir = szUserDataFolder + "scripts/dzVents/generated_scripts/";
  36. + dzv_Dir = szScriptsFolder + "dzVents/generated_scripts/";
  37. #endif
  38. boost::unique_lock<boost::shared_mutex> eventsMutexLock(m_eventsMutex);
  39. _log.Log(LOG_STATUS, "EventSystem: reset all events...");
  40. @@ -274,18 +274,18 @@ void CEventSystem::LoadEvents()
  41. void CEventSystem::Do_Work()
  42. {
  43. #ifdef WIN32
  44. - m_lua_Dir = szUserDataFolder + "scripts\\lua\\";
  45. - m_dzv_Dir = szUserDataFolder + "scripts\\dzVents\\runtime\\";
  46. + m_lua_Dir = szScriptsFolder + "lua\\";
  47. + m_dzv_Dir = szScriptsFolder + "dzVents\\runtime\\";
  48. #else
  49. - m_lua_Dir = szUserDataFolder + "scripts/lua/";
  50. - m_dzv_Dir = szUserDataFolder + "scripts/dzVents/runtime/";
  51. + m_lua_Dir = szScriptsFolder + "lua/";
  52. + m_dzv_Dir = szScriptsFolder + "dzVents/runtime/";
  53. #endif
  54. #ifdef ENABLE_PYTHON
  55. #ifdef WIN32
  56. - m_python_Dir = szUserDataFolder + "scripts\\python\\";
  57. + m_python_Dir = szScriptsFolder + "python\\";
  58. #else
  59. - m_python_Dir = szUserDataFolder + "scripts/python/";
  60. + m_python_Dir = szScriptsFolder + "python/";
  61. #endif
  62. #endif
  63. m_stoprequested = false;
  64. @@ -1426,9 +1426,9 @@ void CEventSystem::EvaluateEvent(const s
  65. {
  66. std::string dzv_scripts;
  67. #ifdef WIN32
  68. - dzv_scripts = szUserDataFolder + "scripts\\dzVents\\scripts\\";
  69. + dzv_scripts = szScriptsFolder + "dzVents\\scripts\\";
  70. #else
  71. - dzv_scripts = szUserDataFolder + "scripts/dzVents/scripts/";
  72. + dzv_scripts = szScriptsFolder + "dzVents/scripts/";
  73. #endif
  74. DirectoryListing(FileEntries, dzv_scripts, false, true);
  75. for (itt = FileEntries.begin(); itt != FileEntries.end(); ++itt)
  76. @@ -2404,7 +2404,7 @@ bool CEventSystem::parseBlocklyActions(c
  77. }
  78. #if !defined WIN32
  79. if (sPath.find("/") != 0)
  80. - sPath = szUserDataFolder + "scripts/" + sPath;
  81. + sPath = szScriptsFolder + sPath;
  82. #endif
  83. m_sql.AddTaskItem(_tTaskItem::ExecuteScript(0.2f, sPath, sParam));
  84. @@ -3508,11 +3508,11 @@ void CEventSystem::EvaluateLua(const std
  85. {
  86. std::stringstream lua_DirT;
  87. - lua_DirT << szUserDataFolder <<
  88. + lua_DirT << szScriptsFolder <<
  89. #ifdef WIN32
  90. - "scripts\\dzVents\\";
  91. + "dzVents\\";
  92. #else
  93. - "scripts/dzVents/";
  94. + "dzVents/";
  95. #endif
  96. lua_pushstring(lua_state, "script_path");
  97. @@ -4695,9 +4695,9 @@ namespace http {
  98. std::stringstream template_file;
  99. #ifdef WIN32
  100. - template_file << szUserDataFolder << "scripts\\templates\\" << eventType << "." << interpreter;
  101. + template_file << szScriptsFolder << "templates\\" << eventType << "." << interpreter;
  102. #else
  103. - template_file << szUserDataFolder << "scripts/templates/" << eventType << "." << interpreter;
  104. + template_file << szScriptsFolder << "templates/" << eventType << "." << interpreter;
  105. #endif
  106. std::ifstream file;
  107. std::stringstream template_content;
  108. --- a/main/LuaHandler.cpp
  109. +++ b/main/LuaHandler.cpp
  110. @@ -22,7 +22,7 @@ extern "C" {
  111. #include "mainworker.h"
  112. #include "../hardware/hardwaretypes.h"
  113. -extern std::string szUserDataFolder;
  114. +extern std::string szScriptsFolder;
  115. int CLuaHandler::l_domoticz_updateDevice(lua_State* lua_state)
  116. {
  117. @@ -155,9 +155,9 @@ bool CLuaHandler::executeLuaScript(const
  118. {
  119. std::stringstream lua_DirT;
  120. #ifdef WIN32
  121. - lua_DirT << szUserDataFolder << "scripts\\lua_parsers\\";
  122. + lua_DirT << szScriptsFolder << "lua_parsers\\";
  123. #else
  124. - lua_DirT << szUserDataFolder << "scripts/lua_parsers/";
  125. + lua_DirT << szScriptsFolder << "lua_parsers/";
  126. #endif
  127. std::string lua_Dir = lua_DirT.str();
  128. --- a/main/SQLHelper.cpp
  129. +++ b/main/SQLHelper.cpp
  130. @@ -633,6 +633,7 @@ const char *sqlCreateMobileDevices =
  131. "[LastUpdate] DATETIME DEFAULT(datetime('now', 'localtime'))"
  132. ");";
  133. +extern std::string szScriptsFolder;
  134. extern std::string szUserDataFolder;
  135. CSQLHelper::CSQLHelper(void)
  136. @@ -3683,9 +3684,9 @@ uint64_t CSQLHelper::UpdateValueInt(cons
  137. //Execute possible script
  138. std::string scriptname;
  139. #ifdef WIN32
  140. - scriptname = szUserDataFolder + "scripts\\domoticz_main.bat";
  141. + scriptname = szScriptsFolder + "domoticz_main.bat";
  142. #else
  143. - scriptname = szUserDataFolder + "scripts/domoticz_main";
  144. + scriptname = szScriptsFolder + "domoticz_main";
  145. #endif
  146. if (file_exist(scriptname.c_str()))
  147. {
  148. @@ -6641,7 +6642,7 @@ bool CSQLHelper::HandleOnOffAction(const
  149. std::string scriptname = OnAction.substr(9);
  150. #if !defined WIN32
  151. if (scriptname.find("/") != 0)
  152. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  153. + scriptname = szScriptsFolder + scriptname;
  154. #endif
  155. std::string scriptparams="";
  156. //Add parameters
  157. @@ -6675,7 +6676,7 @@ bool CSQLHelper::HandleOnOffAction(const
  158. std::string scriptname = OffAction.substr(9);
  159. #if !defined WIN32
  160. if (scriptname.find("/") != 0)
  161. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  162. + scriptname = szScriptsFolder + scriptname;
  163. #endif
  164. std::string scriptparams = "";
  165. int pindex = scriptname.find(' ');
  166. --- a/main/WebServer.cpp
  167. +++ b/main/WebServer.cpp
  168. @@ -59,6 +59,7 @@
  169. #define round(a) ( int ) ( a + .5 )
  170. +extern std::string szScriptsFolder;
  171. extern std::string szUserDataFolder;
  172. extern std::string szWWWFolder;
  173. @@ -2987,9 +2988,9 @@ namespace http {
  174. if (scriptname.find("..") != std::string::npos)
  175. return;
  176. #ifdef WIN32
  177. - scriptname = szUserDataFolder + "scripts\\" + scriptname;
  178. + scriptname = szScriptsFolder + scriptname;
  179. #else
  180. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  181. + scriptname = szScriptsFolder + scriptname;
  182. #endif
  183. if (!file_exist(scriptname.c_str()))
  184. return;
  185. --- a/main/domoticz.cpp
  186. +++ b/main/domoticz.cpp
  187. @@ -136,6 +136,7 @@ static const _facilities facilities[] =
  188. };
  189. std::string logfacname = "user";
  190. #endif
  191. +std::string szScriptsFolder;
  192. std::string szStartupFolder;
  193. std::string szUserDataFolder;
  194. std::string szWWWFolder;
  195. @@ -696,6 +697,19 @@ int main(int argc, char**argv)
  196. szUserDataFolder = szroot;
  197. }
  198. + szScriptsFolder=szStartupFolder;
  199. + if (cmdLine.HasSwitch("-scripts"))
  200. + {
  201. + if (cmdLine.GetArgumentCount("-scripts") != 1)
  202. + {
  203. + _log.Log(LOG_ERROR, "Please specify a path for scripts directory");
  204. + return 1;
  205. + }
  206. + std::string szroot = cmdLine.GetSafeArgument("-scripts", 0, "");
  207. + if (szroot.size() != 0)
  208. + szScriptsFolder = szroot;
  209. + }
  210. +
  211. if (cmdLine.HasSwitch("-startupdelay"))
  212. {
  213. if (cmdLine.GetArgumentCount("-startupdelay") != 1)
  214. --- a/main/mainworker.cpp
  215. +++ b/main/mainworker.cpp
  216. @@ -159,6 +159,7 @@
  217. #define round(a) ( int ) ( a + .5 )
  218. +extern std::string szScriptsFolder;
  219. extern std::string szStartupFolder;
  220. extern std::string szUserDataFolder;
  221. extern std::string szWWWFolder;
  222. @@ -1473,8 +1474,8 @@ void MainWorker::Do_Work()
  223. m_sql.GetPreferencesVar("ReleaseChannel", nValue);
  224. bool bIsBetaChannel = (nValue != 0);
  225. - std::string scriptname = szUserDataFolder + "scripts/download_update.sh";
  226. - std::string strparm = szUserDataFolder;
  227. + std::string scriptname = szScriptsFolder + "download_update.sh";
  228. + std::string strparm = szScriptsFolder;
  229. if (bIsBetaChannel)
  230. strparm += " /beta";
  231. --- a/notifications/NotificationHTTP.cpp
  232. +++ b/notifications/NotificationHTTP.cpp
  233. @@ -6,7 +6,7 @@
  234. #include "../main/SQLHelper.h"
  235. #include "../main/Logger.h"
  236. -extern std::string szUserDataFolder;
  237. +extern std::string szScriptsFolder;
  238. CNotificationHTTP::CNotificationHTTP() : CNotificationBase(std::string("http"), OPTIONS_NONE)
  239. {
  240. @@ -105,7 +105,7 @@ bool CNotificationHTTP::SendMessageImple
  241. std::string scriptparams = "";
  242. #if !defined WIN32
  243. if (scriptname.find("/") != 0)
  244. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  245. + scriptname = szScriptsFolder + scriptname;
  246. #endif
  247. //Add parameters
  248. uPos = scriptname.find(" ");
  249. --- a/push/GooglePubSubPush.cpp
  250. +++ b/push/GooglePubSubPush.cpp
  251. @@ -22,7 +22,7 @@ extern "C" {
  252. using namespace boost::python;
  253. #endif
  254. -extern std::string szUserDataFolder;
  255. +extern std::string szScriptsFolder;
  256. // this should be filled in by the preprocessor
  257. extern const char * Python_exe;
  258. @@ -231,11 +231,11 @@ void CGooglePubSubPush::DoGooglePubSubPu
  259. #ifdef ENABLE_PYTHON_DECAP
  260. #ifdef WIN32
  261. - python_DirT << szUserDataFolder << "scripts\\python\\";
  262. - std::string filename = szUserDataFolder + "scripts\\python\\" + "googlepubsub.py";
  263. + python_DirT << szScriptsFolder << "python\\";
  264. + std::string filename = szScriptsFolder + "python\\" + "googlepubsub.py";
  265. #else
  266. - python_DirT << szUserDataFolder << "scripts/python/";
  267. - std::string filename = szUserDataFolder + "scripts/python/" + "googlepubsub.py";
  268. + python_DirT << szScriptsFolder << "python/";
  269. + std::string filename = szScriptsFolder + "python/" + "googlepubsub.py";
  270. #endif
  271. wchar_t * argv[1];
  272. --- a/hardware/EvohomeScript.cpp
  273. +++ b/hardware/EvohomeScript.cpp
  274. @@ -30,7 +30,7 @@
  275. #include <string>
  276. -extern std::string szUserDataFolder;
  277. +extern std::string szScriptsFolder;
  278. CEvohomeScript::CEvohomeScript(const int ID)
  279. @@ -143,7 +143,7 @@ void CEvohomeScript::RunScript(const cha
  280. std::string scriptname = OnAction.substr(9);
  281. #if !defined WIN32
  282. if (scriptname.find("/") != 0)
  283. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  284. + scriptname = szScriptsFolder + "scripts/" + scriptname;
  285. #endif
  286. std::string scriptparams="";
  287. //Add parameters
  288. --- a/main/EventsPythonModule.cpp
  289. +++ b/main/EventsPythonModule.cpp
  290. @@ -108,7 +108,7 @@
  291. int PythonEventsInitalized = 0;
  292. - bool PythonEventsInitialize(std::string szUserDataFolder) {
  293. + bool PythonEventsInitialize(std::string szScriptsFolder) {
  294. if (!Plugins::Py_LoadLibrary())
  295. {
  296. @@ -131,9 +131,9 @@
  297. std::string ssPath;
  298. #ifdef WIN32
  299. - ssPath = szUserDataFolder + "scripts\\python\\;";
  300. + ssPath = szScriptsFolder + "python\\;";
  301. #else
  302. - ssPath = szUserDataFolder + "scripts/python/:";
  303. + ssPath = szScriptsFolder + "python/:";
  304. #endif
  305. std::wstring sPath = std::wstring(ssPath.begin(), ssPath.end());