aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-04-17 13:20:06 +0000
committerAdam Frisby2008-04-17 13:20:06 +0000
commita0fc29878e3279891d2ce9d53b537cbe52946f5e (patch)
tree2baff67d85fc62dc946a863867c76323999b477a /OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
parent* Added a directory for the SVN module. More about to come. (diff)
downloadopensim-SC_OLD-a0fc29878e3279891d2ce9d53b537cbe52946f5e.zip
opensim-SC_OLD-a0fc29878e3279891d2ce9d53b537cbe52946f5e.tar.gz
opensim-SC_OLD-a0fc29878e3279891d2ce9d53b537cbe52946f5e.tar.bz2
opensim-SC_OLD-a0fc29878e3279891d2ce9d53b537cbe52946f5e.tar.xz
* Added a directory for the SVN module. More about to come.* SVNBackupModule
* See OpenSim.ini.example settings for how to use * Only compatible with svn:// and http:// authentication for the moment (and only using simple authentication). SSL/SSH key support is supported by the library used (SvnDotNet), but is not yet supported in OpenSim. * Use the command "svn save" to make a copy of your regions to SVN. Presently this is not an automatic process, but such a feature is on the todo list. * It will in your repository create a subdirectory for each region with the regions UUID, inside there it will create a 'terrain load' compatible 'heightmap.r32', and a load-xml2 compatible 'objects.xml' plus information files. * Untested on Linux, some compatibility work may be needed by Linux peoples. The dependencies will be the same as for SvnDotNet which is supposedly mono-compatible.
Diffstat (limited to 'OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs')
-rw-r--r--OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs78
1 files changed, 39 insertions, 39 deletions
diff --git a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
index a27ccec..e12c1f1 100644
--- a/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
+++ b/OpenSim/Region/Modules/SvnSerialiser/SvnBackupModule.cs
@@ -1,31 +1,4 @@
1/* 1using System;
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic; 2using System.Collections.Generic;
30using Nini.Config; 3using Nini.Config;
31using OpenSim.Region.Environment.Interfaces; 4using OpenSim.Region.Environment.Interfaces;
@@ -35,6 +8,8 @@ using OpenSim.Region.Environment.Modules.ExportSerialiser;
35using PumaCode.SvnDotNet.SubversionSharp; 8using PumaCode.SvnDotNet.SubversionSharp;
36using PumaCode.SvnDotNet.AprSharp; 9using PumaCode.SvnDotNet.AprSharp;
37 10
11using Slash=System.IO.Path;
12
38namespace OpenSim.Region.Modules.SvnSerialiser 13namespace OpenSim.Region.Modules.SvnSerialiser
39{ 14{
40 public class SvnBackupModule : IRegionModule 15 public class SvnBackupModule : IRegionModule
@@ -42,11 +17,12 @@ namespace OpenSim.Region.Modules.SvnSerialiser
42 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 17 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43 18
44 private SvnClient m_svnClient; 19 private SvnClient m_svnClient;
20 private bool m_enabled = false;
45 private bool m_installBackupOnLoad = false; 21 private bool m_installBackupOnLoad = false;
46 private string m_svnurl = "svn://url.tld/repository/"; 22 private string m_svnurl = "svn://your.svn.tld/";
47 private string m_svnuser = "user"; 23 private string m_svnuser = "user";
48 private string m_svnpass = "password"; 24 private string m_svnpass = "password";
49 private string m_svndir = "modsvn/"; 25 private string m_svndir = "SVNmodule\\repo";
50 private IRegionSerialiser m_serialiser; 26 private IRegionSerialiser m_serialiser;
51 private List<Scene> m_scenes = new List<Scene>(); 27 private List<Scene> m_scenes = new List<Scene>();
52 28
@@ -54,13 +30,24 @@ namespace OpenSim.Region.Modules.SvnSerialiser
54 30
55 public void SaveRegion(Scene scene) 31 public void SaveRegion(Scene scene)
56 { 32 {
57 List<string> filenames = m_serialiser.SerialiseRegion(scene, m_svndir); 33 m_log.Info("[SVNBACKUP]: Saving a region to SVN with name " + scene.RegionInfo.RegionName);
58 foreach (string filename in filenames) 34
35 List<string> filenames = m_serialiser.SerialiseRegion(scene, m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + "\\");
36
37 try
59 { 38 {
60 m_svnClient.Add3(filename, false, true, false); 39 m_svnClient.Add3(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString(), true, false, false);
61 } 40 }
41 // Ignore this error, it means the sim is already under version control.
42 catch (SvnException) { }
43
44 List<string> svnfilenames = new List<string>();
45 foreach (string filename in filenames)
46 svnfilenames.Add(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString() + Slash.DirectorySeparatorChar + filename);
47 svnfilenames.Add(m_svndir + Slash.DirectorySeparatorChar + scene.RegionInfo.RegionID.ToString());
62 48
63 m_svnClient.Commit3(filenames, true, false); 49 m_svnClient.Commit3(svnfilenames, true, false);
50 m_log.Info("[SVNBACKUP]: Backup successful.");
64 } 51 }
65 52
66 #endregion 53 #endregion
@@ -81,7 +68,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
81 { 68 {
82 if (!commitItems.IsNull) 69 if (!commitItems.IsNull)
83 { 70 {
84 foreach (SvnClientCommitItem item in commitItems) 71 foreach (SvnClientCommitItem2 item in commitItems)
85 { 72 {
86 m_log.Debug("[SVNBACKUP]: Updated " + item.Path.ToString() + " (" + item.Kind.ToString() + ") " + item.Revision.ToString()); 73 m_log.Debug("[SVNBACKUP]: Updated " + item.Path.ToString() + " (" + item.Kind.ToString() + ") " + item.Revision.ToString());
87 m_log.Debug("[SVNBACKUP]: " + item.Url.ToString() + " -> " + item.CopyFromUrl.ToString()); 74 m_log.Debug("[SVNBACKUP]: " + item.Url.ToString() + " -> " + item.CopyFromUrl.ToString());
@@ -102,6 +89,19 @@ namespace OpenSim.Region.Modules.SvnSerialiser
102 89
103 public void Initialise(Scene scene, IConfigSource source) 90 public void Initialise(Scene scene, IConfigSource source)
104 { 91 {
92 try
93 {
94 if (!source.Configs["SVN"].GetBoolean("Enabled", false))
95 return;
96
97 m_enabled = true;
98
99 m_svndir = source.Configs["SVN"].GetString("Directory", m_svndir);
100 m_svnurl = source.Configs["SVN"].GetString("URL", m_svnurl);
101 m_svnuser = source.Configs["SVN"].GetString("Username", m_svnuser);
102 m_svnpass = source.Configs["SVN"].GetString("Password", m_svnpass);
103 } catch(Exception) { }
104
105 lock (m_scenes) 105 lock (m_scenes)
106 { 106 {
107 m_scenes.Add(scene); 107 m_scenes.Add(scene);
@@ -112,14 +112,14 @@ namespace OpenSim.Region.Modules.SvnSerialiser
112 112
113 void EventManager_OnPluginConsole(string[] args) 113 void EventManager_OnPluginConsole(string[] args)
114 { 114 {
115 if (args[0] == "testsvn") 115 if (args[0] == "svn" && args[1] == "save")
116 SaveRegion(m_scenes[0]); 116 SaveRegion(m_scenes[0]);
117 } 117 }
118 118
119 public void PostInitialise() 119 public void PostInitialise()
120 { 120 {
121 m_log.Info("[SVNBACKUP]: Disabled."); 121 if (m_enabled == false)
122 return; 122 return;
123 123
124 m_log.Info("[SVNBACKUP]: Connecting..."); 124 m_log.Info("[SVNBACKUP]: Connecting...");
125 125
@@ -140,7 +140,7 @@ namespace OpenSim.Region.Modules.SvnSerialiser
140 140
141 if (m_installBackupOnLoad) 141 if (m_installBackupOnLoad)
142 { 142 {
143 143 //TODO
144 } 144 }
145 } 145 }
146 146