Compare commits
5 commits
359bd375d2
...
d0723239c0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0723239c0 | ||
|
|
5d06f119cd | ||
|
|
2816d2aade | ||
|
|
a081be36b3 | ||
|
|
071198677e |
|
|
@ -7,6 +7,12 @@
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"repository": "ssh://backup.example.org///repos/example",
|
"repository": "ssh://backup.example.org///repos/example",
|
||||||
"compression": "lz4",
|
"compression": "lz4",
|
||||||
|
"encryption": {
|
||||||
|
"kind": "repokey",
|
||||||
|
"data": {
|
||||||
|
"passphrase": "top_secret"
|
||||||
|
}
|
||||||
|
},
|
||||||
"pruning": {
|
"pruning": {
|
||||||
"keep_weekly": 1,
|
"keep_weekly": 1,
|
||||||
"keep_yearly": 2
|
"keep_yearly": 2
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,76 @@ namespace _mimir.conf
|
||||||
],
|
],
|
||||||
"default": "lz4"
|
"default": "lz4"
|
||||||
},
|
},
|
||||||
|
"encryption": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"nullable": false,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"kind": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["none"]
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"nullable": true,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
],
|
||||||
|
"default": {}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"kind"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nullable": false,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"kind": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["repokey"]
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"nullable": true,
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"passphrase": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"passphrase"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"kind",
|
||||||
|
"data"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default": {
|
||||||
|
"kind": "none",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
},
|
||||||
"pruning": {
|
"pruning": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"keep_within": {
|
||||||
|
"nullable": false,
|
||||||
|
"type": "string",
|
||||||
|
"default": "2w"
|
||||||
|
},
|
||||||
"keep_weekly": {
|
"keep_weekly": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|
@ -282,14 +348,7 @@ namespace _mimir.conf
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
type type_target_parameters_borg = {
|
type type_target_parameters_borg = _mimir.transfer.borg.type_parameters;
|
||||||
repository : string;
|
|
||||||
compression : string;
|
|
||||||
pruning : {
|
|
||||||
keep_weekly : int;
|
|
||||||
keep_yearly : int;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,29 @@ namespace _mimir.helpers.borg
|
||||||
repository_directory : string,
|
repository_directory : string,
|
||||||
{
|
{
|
||||||
"encryption": encryption = "none",
|
"encryption": encryption = "none",
|
||||||
|
"passphrase": passphrase = null,
|
||||||
} : {
|
} : {
|
||||||
encryption ?: string;
|
encryption ?: string;
|
||||||
|
passphrase ?: (null | string);
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
return lib_plankton.string.coin(
|
return lib_plankton.string.coin(
|
||||||
"borg init --encryption={{encryption}} {{repository_directory}}",
|
"{{macro_env_passphrase}}borg init --encryption={{encryption}} {{repository_directory}}",
|
||||||
{
|
{
|
||||||
|
"macro_env_passphrase": (
|
||||||
|
(passphrase === null)
|
||||||
|
?
|
||||||
|
""
|
||||||
|
:
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"BORG_PASSPHRASE='{{passphrase}}' BORG_DISPLAY_PASSPHRASE=n ",
|
||||||
|
{
|
||||||
|
"passphrase": passphrase,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
"repository_directory": repository_directory,
|
"repository_directory": repository_directory,
|
||||||
"encryption": encryption,
|
"encryption": encryption,
|
||||||
}
|
}
|
||||||
|
|
@ -54,15 +68,29 @@ namespace _mimir.helpers.borg
|
||||||
directories : Array<string>,
|
directories : Array<string>,
|
||||||
{
|
{
|
||||||
"compression": compression = "none",
|
"compression": compression = "none",
|
||||||
|
"passphrase": passphrase = null,
|
||||||
} : {
|
} : {
|
||||||
compression ?: string;
|
compression ?: string;
|
||||||
|
passphrase ?: (null | string);
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
return lib_plankton.string.coin(
|
return lib_plankton.string.coin(
|
||||||
"borg create --compression={{compression}} {{repository_directory}}::{{archive_name}} {{directories}}",
|
"{{macro_env_passphrase}}borg create --compression={{compression}} {{repository_directory}}::{{archive_name}} {{directories}}",
|
||||||
{
|
{
|
||||||
|
"macro_env_passphrase": (
|
||||||
|
(passphrase === null)
|
||||||
|
?
|
||||||
|
""
|
||||||
|
:
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"BORG_PASSPHRASE='{{passphrase}}' ",
|
||||||
|
{
|
||||||
|
"passphrase": passphrase,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
"repository_directory": repository_directory,
|
"repository_directory": repository_directory,
|
||||||
"archive_name": archive_name,
|
"archive_name": archive_name,
|
||||||
"compression": compression,
|
"compression": compression,
|
||||||
|
|
@ -80,16 +108,30 @@ namespace _mimir.helpers.borg
|
||||||
{
|
{
|
||||||
"keep_weekly": keep_weekly = null,
|
"keep_weekly": keep_weekly = null,
|
||||||
"keep_yearly": keep_yearly = null,
|
"keep_yearly": keep_yearly = null,
|
||||||
|
"passphrase": passphrase = null,
|
||||||
} : {
|
} : {
|
||||||
keep_weekly ?: (null | int);
|
keep_weekly ?: (null | int);
|
||||||
keep_yearly ?: (null | int);
|
keep_yearly ?: (null | int);
|
||||||
|
passphrase ?: (null | string);
|
||||||
} = {
|
} = {
|
||||||
}
|
}
|
||||||
) : string
|
) : string
|
||||||
{
|
{
|
||||||
return lib_plankton.string.coin(
|
return lib_plankton.string.coin(
|
||||||
"borg prune --keep-within=2w{{macro_keep_weekly}}{{macro_keep_yearly}} {{repository_directory}}",
|
"{{macro_env_passphrase}}borg prune --keep-within={{keep_within}}{{macro_keep_weekly}}{{macro_keep_yearly}} {{repository_directory}}",
|
||||||
{
|
{
|
||||||
|
"macro_env_passphrase": (
|
||||||
|
(passphrase === null)
|
||||||
|
?
|
||||||
|
""
|
||||||
|
:
|
||||||
|
lib_plankton.string.coin(
|
||||||
|
"BORG_PASSPHRASE='{{passphrase}}' ",
|
||||||
|
{
|
||||||
|
"passphrase": passphrase,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
"repository_directory": repository_directory,
|
"repository_directory": repository_directory,
|
||||||
"keep_within": age,
|
"keep_within": age,
|
||||||
"macro_keep_weekly": (
|
"macro_keep_weekly": (
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@ namespace _mimir.transfer
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export type type_logic = {
|
export type type_logic = {
|
||||||
|
init : (
|
||||||
|
(
|
||||||
|
)
|
||||||
|
=>
|
||||||
|
Array<string>
|
||||||
|
);
|
||||||
execute : (
|
execute : (
|
||||||
(
|
(
|
||||||
name : string,
|
name : string,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ namespace _mimir.transfer
|
||||||
{
|
{
|
||||||
"repository": target.parameters.repository,
|
"repository": target.parameters.repository,
|
||||||
"compression": target.parameters.compression,
|
"compression": target.parameters.compression,
|
||||||
|
"encryption": target.parameters.encryption,
|
||||||
"pruning": target.parameters.pruning,
|
"pruning": target.parameters.pruning,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,114 @@ along with »mimir«. If not, see <http://www.gnu.org/licenses/>.
|
||||||
namespace _mimir.transfer.borg
|
namespace _mimir.transfer.borg
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export type type_encryption = (
|
||||||
|
{
|
||||||
|
kind : "none";
|
||||||
|
data : {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
{
|
||||||
|
kind : "repokey";
|
||||||
|
data : {
|
||||||
|
passphrase : string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
|
|
||||||
|
{
|
||||||
|
kind : "keyfile";
|
||||||
|
data : {
|
||||||
|
path : string;
|
||||||
|
passphrase : string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export type type_parameters = {
|
export type type_parameters = {
|
||||||
repository : string;
|
repository : string;
|
||||||
compression : string;
|
compression : string;
|
||||||
|
encryption : type_encryption;
|
||||||
pruning : {
|
pruning : {
|
||||||
|
keep_within : string;
|
||||||
keep_weekly : int;
|
keep_weekly : int;
|
||||||
keep_yearly : int;
|
keep_yearly : int;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function get_passphrase(
|
||||||
|
parameters : type_parameters
|
||||||
|
) : (null | string)
|
||||||
|
{
|
||||||
|
switch (parameters.encryption.kind)
|
||||||
|
{
|
||||||
|
case "none":
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "repokey":
|
||||||
|
{
|
||||||
|
return parameters.encryption.data.passphrase;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
throw (new Error("unhandled encryption kind"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
export function init(
|
||||||
|
parameters : type_parameters,
|
||||||
|
) : Array<string>
|
||||||
|
{
|
||||||
|
const result : Array<string> = [];
|
||||||
|
result.push(
|
||||||
|
_mimir.helpers.borg.init(
|
||||||
|
parameters.repository,
|
||||||
|
{
|
||||||
|
"encryption": ((encryption : type_encryption) => {
|
||||||
|
switch (encryption.kind)
|
||||||
|
{
|
||||||
|
case "none":
|
||||||
|
{
|
||||||
|
return "none";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "repokey":
|
||||||
|
{
|
||||||
|
return "repokey";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
throw (new Error("unhandled encryption kind"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) (parameters.encryption),
|
||||||
|
"passphrase": get_passphrase(parameters),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
export function execute(
|
export function execute(
|
||||||
|
|
@ -54,6 +150,7 @@ namespace _mimir.transfer.borg
|
||||||
),
|
),
|
||||||
[directory],
|
[directory],
|
||||||
{
|
{
|
||||||
|
"passphrase": get_passphrase(parameters),
|
||||||
"compression": parameters.compression,
|
"compression": parameters.compression,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -61,7 +158,7 @@ namespace _mimir.transfer.borg
|
||||||
result.push(
|
result.push(
|
||||||
_mimir.helpers.borg.prune(
|
_mimir.helpers.borg.prune(
|
||||||
parameters.repository,
|
parameters.repository,
|
||||||
"2w",
|
parameters.pruning.keep_within,
|
||||||
{
|
{
|
||||||
"keep_weekly": parameters.pruning.keep_weekly,
|
"keep_weekly": parameters.pruning.keep_weekly,
|
||||||
"keep_yearly": parameters.pruning.keep_yearly,
|
"keep_yearly": parameters.pruning.keep_yearly,
|
||||||
|
|
@ -79,6 +176,7 @@ namespace _mimir.transfer.borg
|
||||||
) : _mimir.transfer.type_logic
|
) : _mimir.transfer.type_logic
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
"init": () => init(parameters),
|
||||||
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
|
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,10 @@ namespace _mimir.transfer.local
|
||||||
) : _mimir.transfer.type_logic
|
) : _mimir.transfer.type_logic
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
/**
|
||||||
|
* @todo?
|
||||||
|
*/
|
||||||
|
"init": () => [],
|
||||||
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
|
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,10 +168,27 @@ namespace _mimir
|
||||||
}
|
}
|
||||||
case "init":
|
case "init":
|
||||||
{
|
{
|
||||||
/**
|
const conf : _mimir.conf.type_conf = await _mimir.conf.get(args["conf_path"]);
|
||||||
* @todo implement
|
|
||||||
*/
|
let commands : Array<string> = [];
|
||||||
return Promise.reject(new Error("not implemented"));
|
const commands_add : ((command : string) => void) = (command) => {
|
||||||
|
commands.push(command);
|
||||||
|
};
|
||||||
|
const commands_apply : (() => void) = () => {
|
||||||
|
process.stdout.write(commands.join("\n") + "\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
// transfer
|
||||||
|
{
|
||||||
|
const target_logic : _mimir.transfer.type_logic = _mimir.transfer.get_logic(conf.target);
|
||||||
|
commands = commands.concat(
|
||||||
|
target_logic.init(
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
commands_apply();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "run":
|
case "run":
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ def main():
|
||||||
"--build-directory",
|
"--build-directory",
|
||||||
type = str,
|
type = str,
|
||||||
dest = "build_directory",
|
dest = "build_directory",
|
||||||
default = "build",
|
default = "/tmp/mimir",
|
||||||
metavar = "<build-directory>",
|
metavar = "<build-directory>",
|
||||||
help = "directory to where the build was put",
|
help = "directory to where the build was put",
|
||||||
)
|
)
|
||||||
|
|
@ -45,7 +45,7 @@ def main():
|
||||||
"--recursive",
|
"--recursive",
|
||||||
"--update",
|
"--update",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"--exclude='conf.json'",
|
"--exclude='*mmr.json'",
|
||||||
("%s/" % args.build_directory),
|
("%s/" % args.build_directory),
|
||||||
(
|
(
|
||||||
("%s" % args.target_directory)
|
("%s" % args.target_directory)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## consts
|
## consts
|
||||||
|
|
||||||
dir=lib/plankton
|
dir=$(pwd)/lib/plankton
|
||||||
|
|
||||||
modules=""
|
modules=""
|
||||||
modules="${modules} base"
|
modules="${modules} base"
|
||||||
|
|
@ -17,6 +17,14 @@ modules="${modules} log"
|
||||||
|
|
||||||
## exec
|
## exec
|
||||||
|
|
||||||
|
mkdir -p ${dir}
|
||||||
|
mkdir /tmp/sandbox -p
|
||||||
|
cd /tmp/sandbox
|
||||||
|
ptk fetch node ${modules}
|
||||||
|
schwamm --include=/tmp/sandbox/plankton.swm.json --output=dump:logic-decl > ${dir}/plankton.d.ts
|
||||||
|
schwamm --include=/tmp/sandbox/plankton.swm.json --output=dump:logic-impl > ${dir}/plankton.js
|
||||||
|
exit
|
||||||
|
|
||||||
mkdir -p ${dir}
|
mkdir -p ${dir}
|
||||||
cd ${dir}
|
cd ${dir}
|
||||||
ptk bundle node ${modules}
|
ptk bundle node ${modules}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue