This commit is contained in:
parent
b5bc7b611d
commit
9e9d80570c
@ -289,11 +289,6 @@ std::map<std::string, ServiceStatus> service_runner::get_all_services_status(std
|
||||
std::string command = "_allservicesstatus";
|
||||
std::string service_name = "dropshell-agent";
|
||||
|
||||
if (!gTemplateManager().template_command_exists(service_name, command))
|
||||
{
|
||||
std::cerr << "Error: " << service_name << " does not contain the " << command << " script" << std::endl;
|
||||
return status;
|
||||
}
|
||||
|
||||
server_env_manager env(server_name);
|
||||
if (!env.is_valid()) {
|
||||
@ -301,8 +296,14 @@ std::map<std::string, ServiceStatus> service_runner::get_all_services_status(std
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
std::string remote_service_template_path = remotepath::service_template(server_name,service_name);
|
||||
std::string script_path = remote_service_template_path + "/shared/" + command + ".sh";
|
||||
sCommand scommand(remote_service_template_path, "bash " + quote(script_path), {});
|
||||
|
||||
std::string output;
|
||||
if (!env.run_remote_template_command_and_capture_output(service_name, command, {}, output, true, {}))
|
||||
cMode mode = cMode::CaptureOutput | cMode::RawCommand;
|
||||
if (!execute_ssh_command(env.get_SSH_INFO(), scommand, mode, &output))
|
||||
return status;
|
||||
|
||||
std::stringstream ss(output);
|
||||
|
@ -1,13 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script contains the common code for the autocommands.
|
||||
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
|
||||
|
||||
MYID=$(id -u)
|
||||
MYGRP=$(id -g)
|
||||
|
||||
BACKUP_TEMP_PATH="$TEMP_DIR/backup"
|
||||
|
||||
_autocommandrun_volume() {
|
||||
local command="$1"
|
||||
local volume_name="$2"
|
||||
@ -112,7 +108,8 @@ _autocommandparse() {
|
||||
|
||||
local command="$1"
|
||||
shift
|
||||
echo "autocommandparse: command=$command"
|
||||
local backup_temp_path="$1"
|
||||
shift
|
||||
|
||||
# Extract the backup file and temp path (last two arguments)
|
||||
local args=("$@")
|
||||
@ -132,7 +129,7 @@ _autocommandparse() {
|
||||
|
||||
# create backup folder unique to key/value.
|
||||
local bfolder=$(echo "${key}_${value}" | tr -cd '[:alnum:]_-')
|
||||
local targetpath="${BACKUP_TEMP_PATH}/${bfolder}"
|
||||
local targetpath="${backup_temp_path}/${bfolder}"
|
||||
mkdir -p ${targetpath}
|
||||
|
||||
# Key must be one of volume, path or file
|
||||
@ -155,31 +152,57 @@ _autocommandparse() {
|
||||
|
||||
|
||||
autocreate() {
|
||||
_autocommandparse create "$@"
|
||||
_check_required_env_vars "TEMP_DIR"
|
||||
|
||||
local create_temp_path="$TEMP_DIR/create"
|
||||
mkdir -p "$create_temp_path"
|
||||
_autocommandparse create "$create_temp_path" "$@"
|
||||
rm -rf "$create_temp_path"
|
||||
}
|
||||
|
||||
|
||||
autonuke() {
|
||||
_autocommandparse nuke "$@"
|
||||
_check_required_env_vars "TEMP_DIR"
|
||||
|
||||
local nuke_temp_path="$TEMP_DIR/nuke"
|
||||
mkdir -p "$nuke_temp_path"
|
||||
_autocommandparse nuke "$nuke_temp_path" "$@"
|
||||
rm -rf "$nuke_temp_path"
|
||||
}
|
||||
|
||||
|
||||
autobackup() {
|
||||
mkdir -p "$BACKUP_TEMP_PATH"
|
||||
echo "_autocommandparse [backup] [$@]"
|
||||
_autocommandparse backup "$@"
|
||||
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
|
||||
local backup_temp_path="$TEMP_DIR/backup"
|
||||
|
||||
tar zcvf "$BACKUP_FILE" -C "$BACKUP_TEMP_PATH" .
|
||||
mkdir -p "$backup_temp_path"
|
||||
echo "_autocommandparse [backup] [$backup_temp_path] [$@]"
|
||||
|
||||
# backup the files into the temp path.
|
||||
_autocommandparse backup "$backup_temp_path" "$@"
|
||||
|
||||
# create the backup file.
|
||||
tar zcvf "$BACKUP_FILE" -C "$backup_temp_path" .
|
||||
|
||||
rm -rf "$backup_temp_path"
|
||||
}
|
||||
|
||||
|
||||
autorestore() {
|
||||
echo "_autocommandparse [restore] [$@]"
|
||||
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
|
||||
local backup_temp_path="$TEMP_DIR/restore"
|
||||
|
||||
mkdir -p "$BACKUP_TEMP_PATH"
|
||||
tar zxvf "$BACKUP_FILE" -C "$BACKUP_TEMP_PATH" --strip-components=1
|
||||
echo "_autocommandparse [restore] [$backup_temp_path] [$@]"
|
||||
|
||||
_autocommandparse restore "$@"
|
||||
mkdir -p "$backup_temp_path"
|
||||
|
||||
# extract the backup file into the temp path.
|
||||
tar zxvf "$BACKUP_FILE" -C "$backup_temp_path" --strip-components=1
|
||||
|
||||
# restore the files from the temp path.
|
||||
_autocommandparse restore "$backup_temp_path" "$@"
|
||||
|
||||
rm -rf "$backup_temp_path"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user