From 49991d055a889f2bd082695383b664a40107db40 Mon Sep 17 00:00:00 2001
From: H-H-H
Date: Fri, 1 May 2015 19:30:56 +0100
Subject: Adding the command <dobackup>to opensim console which requires a
 region name as an argument and will do an oar of that region if the
 autobackup module is enabled

Signed-off-by: Michael Cerquoni <nebadon2025@gmail.com>
---
 .../World/AutoBackup/AutoBackupModule.cs           | 42 ++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

(limited to 'OpenSim/Region/OptionalModules/World')

diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
index 28dc5f5..c17a368 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
@@ -115,6 +115,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
 
         private delegate T DefaultGetter<T>(string settingName, T defaultValue);
         private bool m_enabled;
+        private ICommandConsole m_console;
+        private List<Scene> m_Scenes = new List<Scene> ();
+
 
         /// <summary>
         /// Whether the shared module should be enabled at all. NOT the same as m_Enabled in AutoBackupModuleState!
@@ -206,8 +209,20 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
         /// Currently a no-op for AutoBackup because we have to wait for region to be fully loaded.
         /// </summary>
         /// <param name="scene"></param>
-        void IRegionModuleBase.AddRegion(Scene scene)
+        void IRegionModuleBase.AddRegion (Scene scene)
         {
+            if (!this.m_enabled) {
+                return;
+            }
+            lock (m_Scenes) {
+                m_Scenes.Add (scene);
+            }
+            m_console = MainConsole.Instance;
+
+            m_console.Commands.AddCommand (
+                "AutoBackup", false, "dobackup",
+                "dobackup",
+                "do backup.", DoBackup);
         }
 
         /// <summary>
@@ -220,7 +235,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
             {
                 return;
             }
-
+            m_Scenes.Remove (scene);
             if (this.m_states.ContainsKey(scene))
             {
                 AutoBackupModuleState abms = this.m_states[scene];
@@ -275,6 +290,29 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
 
         #endregion
 
+
+        private void DoBackup (string module, string[] args)
+        {
+            if (args.Length != 2) {
+                MainConsole.Instance.OutputFormat ("Usage: dobackup <regionname>");
+                return;
+            }  
+            bool found = false;
+            string name = args [1];
+            lock (m_Scenes) {
+                foreach (Scene s in m_Scenes) {
+                    string test = s.Name.ToString ();
+                    if (test == name) {
+                        found = true;
+                        DoRegionBackup (s);
+                    }
+                }
+                if (!found) {
+                    MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name);
+                }
+            }
+        }
+
         /// <summary>
         /// Set up internal state for a given scene. Fairly complex code.
         /// When this method returns, we've started auto-backup timers, put members in Dictionaries, and created a State object for this scene.
-- 
cgit v1.1