From 667fc392e957df71290b5b36f86e964ac939fd5e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 5 Apr 2011 14:11:25 +0100 Subject: tools/migration: Support for ~/ in paths --- tools/migration/migrator/prosody_files.lua | 2 +- tools/migration/prosody-migrator.lua | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'tools/migration') diff --git a/tools/migration/migrator/prosody_files.lua b/tools/migration/migrator/prosody_files.lua index 0a610d0e..fe48e7a4 100644 --- a/tools/migration/migrator/prosody_files.lua +++ b/tools/migration/migrator/prosody_files.lua @@ -22,7 +22,7 @@ module "prosody_files" local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end local function is_file(path) return lfs.attributes(path, "mode") == "file"; end local function clean_path(path) - return path:gsub("\\", "/"):gsub("//+", "/"); + return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os.getenv("HOME") or "~"); end local encode, decode; do local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index 20631fb1..feebe484 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -3,6 +3,15 @@ CFG_SOURCEDIR=os.getenv("PROSODY_SRCDIR"); CFG_CONFIGDIR=os.getenv("PROSODY_CFGDIR"); +-- Substitute ~ with path to home directory in paths +if CFG_CONFIGDIR then + CFG_CONFIGDIR = CFG_CONFIGDIR:gsub("^~", os.getenv("HOME")); +end + +if CFG_SOURCEDIR then + CFG_SOURCEDIR = CFG_SOURCEDIR:gsub("^~", os.getenv("HOME")); +end + local default_config = (CFG_CONFIGDIR or ".").."/migrator.cfg.lua"; -- Command-line parsing -- cgit v1.2.3 From 747f5e7ccf990ad014969251fe3c8ecce95226ff Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 5 Apr 2011 14:34:06 +0100 Subject: tools/migration/prosody-migrator.lua: Add messages to show when migration is in progress --- tools/migration/prosody-migrator.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/migration') diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index feebe484..2a8bf1c3 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -125,9 +125,10 @@ local writer = require("migrator."..otype).writer(config[to_store]); local json = require "util.json"; +io.stderr:write("Migrating...\n"); for x in reader do --print(json.encode(x)) writer(x); end writer(nil); -- close - +io.stderr:write("Done!\n"); -- cgit v1.2.3 From f9191fdb2c019fac2d6dd41d878813a001aa12eb Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 5 Apr 2011 14:34:48 +0100 Subject: tools/migration/migrator/prosody_files.lua: Fix for previous commit --- tools/migration/migrator/prosody_files.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools/migration') diff --git a/tools/migration/migrator/prosody_files.lua b/tools/migration/migrator/prosody_files.lua index fe48e7a4..4e42f564 100644 --- a/tools/migration/migrator/prosody_files.lua +++ b/tools/migration/migrator/prosody_files.lua @@ -13,6 +13,7 @@ local mtools = require "migrator.mtools"; local next = next; local pairs = pairs; local json = require "util.json"; +local os_getenv = os.getenv; prosody = {}; local dm = require "util.datamanager" @@ -22,7 +23,7 @@ module "prosody_files" local function is_dir(path) return lfs.attributes(path, "mode") == "directory"; end local function is_file(path) return lfs.attributes(path, "mode") == "file"; end local function clean_path(path) - return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os.getenv("HOME") or "~"); + return path:gsub("\\", "/"):gsub("//+", "/"):gsub("^~", os_getenv("HOME") or "~"); end local encode, decode; do local urlcodes = setmetatable({}, { __index = function (t, k) t[k] = char(tonumber("0x"..k)); return t[k]; end }); -- cgit v1.2.3