Codebase list osrframework / debian/0.18.0-0kali1 debian / patches / add-script-config-upgrade.patch
debian/0.18.0-0kali1

Tree @debian/0.18.0-0kali1 (Download .tar.gz)

add-script-config-upgrade.patch @debian/0.18.0-0kali1raw · history · blame

Description: Add a script to manage configuration during upgrade
 During a upgrade we have to install the new configuration files in
 ~/.config/OSRFramework:
 - Update configuration.py to create the missing directory "data"
  only if it doesn't exist.
 - Add a script (which is called in postinst when it's an upgrade) to
   remove config directories "default", "plugins", "server", "transforms",
   and install the new directories and files provided by the package.
Author: Sophie Brun <[email protected]>
Origin: vendor
Last-Update: 2018-01-24
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/osrframework/utils/upgrade_config.py
@@ -0,0 +1,12 @@
+# !/usr/bin/python
+
+import os
+import shutil
+
+import osrframework.utils.configuration as configuration
+
+if __name__ == "__main__":
+    if os.path.exists(configuration.getConfigPath()["appPath"]):
+        for confdir in ["default", "plugins", "server", "transforms"]:
+            shutil.rmtree(os.path.join(configuration.getConfigPath()["appPath"], confdir), True)
+    configuration.initialize_config_files()
--- a/osrframework/utils/configuration.py
+++ b/osrframework/utils/configuration.py
@@ -41,8 +41,10 @@ def initialize_config_files():
     for dirconf in ["default", "plugins"]:
         shutil.copytree(os.path.join('/etc/osrframework',dirconf), os.path.join(LOCAL_CONFIG_DIR, dirconf))
 
-    # Create directory data
-    os.mkdir(getConfigPath()["appPathData"])
+    # Create directory data if it doesn't exist (we keep it at the
+    # upgrade)
+    if not os.path.exists(getConfigPath()["appPathData"]):
+        os.mkdir(getConfigPath()["appPathData"])
 
     # Create directory Transforms before copy *.py files
 #    os.mkdir(LOCAL_CONFIG_TRANSFORMS_DIR)