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.

262 lines
8.3 KiB

  1. --- a/hardware/OpenZWave.cpp
  2. +++ b/hardware/OpenZWave.cpp
  3. @@ -993,7 +993,7 @@ bool COpenZWave::OpenSerialConnector()
  4. }
  5. m_nodes.clear();
  6. m_bNeedSave = false;
  7. - std::string ConfigPath = szStartupFolder + "Config/";
  8. + std::string ConfigPath = "/usr/share/domoticz/openzwave/";
  9. std::string UserPath = ConfigPath;
  10. if (szStartupFolder != szUserDataFolder)
  11. {
  12. --- a/main/EventSystem.cpp
  13. +++ b/main/EventSystem.cpp
  14. @@ -44,7 +44,7 @@ extern "C" {
  15. using namespace boost::python;
  16. #endif
  17. -extern std::string szUserDataFolder;
  18. +extern std::string szScriptsFolder;
  19. CEventSystem::CEventSystem(void)
  20. {
  21. @@ -1086,9 +1086,9 @@ void CEventSystem::EvaluateEvent(const s
  22. std::stringstream lua_DirT;
  23. #ifdef WIN32
  24. - lua_DirT << szUserDataFolder << "scripts\\lua\\";
  25. + lua_DirT << szScriptsFolder << "lua\\";
  26. #else
  27. - lua_DirT << szUserDataFolder << "scripts/lua/";
  28. + lua_DirT << szScriptsFolder << "lua/";
  29. #endif
  30. std::string lua_Dir = lua_DirT.str();
  31. @@ -1139,9 +1139,9 @@ void CEventSystem::EvaluateEvent(const s
  32. {
  33. std::stringstream python_DirT;
  34. #ifdef WIN32
  35. - python_DirT << szUserDataFolder << "scripts\\python\\";
  36. + python_DirT << szScriptsFolder << "python\\";
  37. #else
  38. - python_DirT << szUserDataFolder << "scripts/python/";
  39. + python_DirT << szScriptsFolder << "python/";
  40. #endif
  41. std::string python_Dir = python_DirT.str();
  42. @@ -2021,7 +2021,7 @@ bool CEventSystem::parseBlocklyActions(c
  43. }
  44. #if !defined WIN32
  45. if (sPath.find("/") != 0)
  46. - sPath = szUserDataFolder + "scripts/" + sPath;
  47. + sPath = szScriptsFolder + sPath;
  48. #endif
  49. m_sql.AddTaskItem(_tTaskItem::ExecuteScript(1, sPath, sParam));
  50. @@ -2133,9 +2133,9 @@ void CEventSystem::EvaluatePython(const
  51. std::stringstream python_DirT;
  52. #ifdef WIN32
  53. - python_DirT << szUserDataFolder << "scripts\\python\\";
  54. + python_DirT << szScriptsFolder << "python\\";
  55. #else
  56. - python_DirT << szUserDataFolder << "scripts/python/";
  57. + python_DirT << szScriptsFolder << "python/";
  58. #endif
  59. std::string python_Dir = python_DirT.str();
  60. if(!Py_IsInitialized()) {
  61. @@ -3909,9 +3909,9 @@ namespace http {
  62. std::stringstream template_file;
  63. #ifdef WIN32
  64. - template_file << szUserDataFolder << "scripts\\templates\\" << eventType << "." << interpreter;
  65. + template_file << szScriptsFolder << "templates\\" << eventType << "." << interpreter;
  66. #else
  67. - template_file << szUserDataFolder << "scripts/templates/" << eventType << "." << interpreter;
  68. + template_file << szScriptsFolder << "templates/" << eventType << "." << interpreter;
  69. #endif
  70. std::ifstream file;
  71. std::stringstream template_content;
  72. --- a/main/LuaHandler.cpp
  73. +++ b/main/LuaHandler.cpp
  74. @@ -22,7 +22,7 @@ extern "C" {
  75. #include "mainworker.h"
  76. #include "../hardware/hardwaretypes.h"
  77. -extern std::string szUserDataFolder;
  78. +extern std::string szScriptsFolder;
  79. int CLuaHandler::l_domoticz_applyXPath(lua_State* lua_state)
  80. {
  81. @@ -319,9 +319,9 @@ bool CLuaHandler::executeLuaScript(const
  82. {
  83. std::stringstream lua_DirT;
  84. #ifdef WIN32
  85. - lua_DirT << szUserDataFolder << "scripts\\lua_parsers\\";
  86. + lua_DirT << szScriptsFolder << "lua_parsers\\";
  87. #else
  88. - lua_DirT << szUserDataFolder << "scripts/lua_parsers/";
  89. + lua_DirT << szScriptsFolder << "lua_parsers/";
  90. #endif
  91. std::string lua_Dir = lua_DirT.str();
  92. --- a/main/SQLHelper.cpp
  93. +++ b/main/SQLHelper.cpp
  94. @@ -612,6 +612,7 @@ const char *sqlCreateMobileDevices =
  95. "[LastUpdate] DATETIME DEFAULT(datetime('now', 'localtime'))"
  96. ");";
  97. +extern std::string szScriptsFolder;
  98. extern std::string szUserDataFolder;
  99. CSQLHelper::CSQLHelper(void)
  100. @@ -3408,9 +3409,9 @@ unsigned long long CSQLHelper::UpdateVal
  101. //Execute possible script
  102. std::string scriptname;
  103. #ifdef WIN32
  104. - scriptname = szUserDataFolder + "scripts\\domoticz_main.bat";
  105. + scriptname = szScriptsFolder + "domoticz_main.bat";
  106. #else
  107. - scriptname = szUserDataFolder + "scripts/domoticz_main";
  108. + scriptname = szScriptsFolder + "domoticz_main";
  109. #endif
  110. if (file_exist(scriptname.c_str()))
  111. {
  112. @@ -6460,7 +6461,7 @@ bool CSQLHelper::HandleOnOffAction(const
  113. std::string scriptname = OnAction.substr(9);
  114. #if !defined WIN32
  115. if (scriptname.find("/") != 0)
  116. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  117. + scriptname = szScriptsFolder + scriptname;
  118. #endif
  119. std::string scriptparams="";
  120. //Add parameters
  121. @@ -6492,7 +6493,7 @@ bool CSQLHelper::HandleOnOffAction(const
  122. std::string scriptname = OffAction.substr(9);
  123. #if !defined WIN32
  124. if (scriptname.find("/") != 0)
  125. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  126. + scriptname = szScriptsFolder + scriptname;
  127. #endif
  128. std::string scriptparams="";
  129. int pindex=scriptname.find(' ');
  130. --- a/main/WebServer.cpp
  131. +++ b/main/WebServer.cpp
  132. @@ -55,6 +55,7 @@
  133. #define round(a) ( int ) ( a + .5 )
  134. +extern std::string szScriptsFolder;
  135. extern std::string szUserDataFolder;
  136. extern std::string szWWWFolder;
  137. @@ -2614,9 +2615,9 @@ namespace http {
  138. if (scriptname.find("..") != std::string::npos)
  139. return;
  140. #ifdef WIN32
  141. - scriptname = szUserDataFolder + "scripts\\" + scriptname;
  142. + scriptname = szScriptsFolder + scriptname;
  143. #else
  144. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  145. + scriptname = szScriptsFolder + scriptname;
  146. #endif
  147. if (!file_exist(scriptname.c_str()))
  148. return;
  149. --- a/main/domoticz.cpp
  150. +++ b/main/domoticz.cpp
  151. @@ -135,6 +135,7 @@ static const _facilities facilities[] =
  152. };
  153. std::string logfacname = "user";
  154. #endif
  155. +std::string szScriptsFolder;
  156. std::string szStartupFolder;
  157. std::string szUserDataFolder;
  158. std::string szWWWFolder;
  159. @@ -603,6 +604,19 @@ int main(int argc, char**argv)
  160. szUserDataFolder = szroot;
  161. }
  162. + szScriptsFolder=szStartupFolder;
  163. + if (cmdLine.HasSwitch("-scripts"))
  164. + {
  165. + if (cmdLine.GetArgumentCount("-scripts") != 1)
  166. + {
  167. + _log.Log(LOG_ERROR, "Please specify a path for scripts directory");
  168. + return 1;
  169. + }
  170. + std::string szroot = cmdLine.GetSafeArgument("-scripts", 0, "");
  171. + if (szroot.size() != 0)
  172. + szScriptsFolder = szroot;
  173. + }
  174. +
  175. if (cmdLine.HasSwitch("-startupdelay"))
  176. {
  177. if (cmdLine.GetArgumentCount("-startupdelay") != 1)
  178. --- a/main/mainworker.cpp
  179. +++ b/main/mainworker.cpp
  180. @@ -139,6 +139,7 @@
  181. #define round(a) ( int ) ( a + .5 )
  182. +extern std::string szScriptsFolder;
  183. extern std::string szStartupFolder;
  184. extern std::string szUserDataFolder;
  185. extern std::string szWWWFolder;
  186. @@ -1394,8 +1395,8 @@ void MainWorker::Do_Work()
  187. m_sql.GetPreferencesVar("ReleaseChannel", nValue);
  188. bool bIsBetaChannel = (nValue != 0);
  189. - std::string scriptname = szUserDataFolder + "scripts/download_update.sh";
  190. - std::string strparm = szUserDataFolder;
  191. + std::string scriptname = szScriptsFolder + "download_update.sh";
  192. + std::string strparm = szScriptsFolder;
  193. if (bIsBetaChannel)
  194. strparm += " /beta";
  195. --- a/notifications/NotificationHTTP.cpp
  196. +++ b/notifications/NotificationHTTP.cpp
  197. @@ -6,7 +6,7 @@
  198. #include "../main/SQLHelper.h"
  199. #include "../main/Logger.h"
  200. -extern std::string szUserDataFolder;
  201. +extern std::string szScriptsFolder;
  202. CNotificationHTTP::CNotificationHTTP() : CNotificationBase(std::string("http"), OPTIONS_NONE)
  203. {
  204. @@ -97,7 +97,7 @@ bool CNotificationHTTP::SendMessageImple
  205. std::string scriptparams = "";
  206. #if !defined WIN32
  207. if (scriptname.find("/") != 0)
  208. - scriptname = szUserDataFolder + "scripts/" + scriptname;
  209. + scriptname = szScriptsFolder + scriptname;
  210. #endif
  211. //Add parameters
  212. uPos = scriptname.find(" ");
  213. --- a/push/GooglePubSubPush.cpp
  214. +++ b/push/GooglePubSubPush.cpp
  215. @@ -20,7 +20,7 @@ extern "C" {
  216. using namespace boost::python;
  217. #endif
  218. -extern std::string szUserDataFolder;
  219. +extern std::string szScriptsFolder;
  220. // this should be filled in by the preprocessor
  221. extern const char * Python_exe;
  222. @@ -222,11 +222,11 @@ void CGooglePubSubPush::DoGooglePubSubPu
  223. #ifdef ENABLE_PYTHON
  224. #ifdef WIN32
  225. - python_DirT << szUserDataFolder << "scripts\\python\\";
  226. - std::string filename = szUserDataFolder + "scripts\\python\\" + "googlepubsub.py";
  227. + python_DirT << szScriptsFolder << "python\\";
  228. + std::string filename = szScriptsFolder + "python\\" + "googlepubsub.py";
  229. #else
  230. - python_DirT << szUserDataFolder << "scripts/python/";
  231. - std::string filename = szUserDataFolder + "scripts/python/" + "googlepubsub.py";
  232. + python_DirT << szScriptsFolder << "python/";
  233. + std::string filename = szScriptsFolder + "python/" + "googlepubsub.py";
  234. #endif
  235. char * argv[1];