.
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 18s

This commit is contained in:
Your Name 2025-05-10 12:44:37 +12:00
parent b5bc7b611d
commit 9e9d80570c
3 changed files with 46 additions and 22 deletions

View File

@ -289,11 +289,6 @@ std::map<std::string, ServiceStatus> service_runner::get_all_services_status(std
std::string command = "_allservicesstatus"; std::string command = "_allservicesstatus";
std::string service_name = "dropshell-agent"; 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); server_env_manager env(server_name);
if (!env.is_valid()) { if (!env.is_valid()) {
@ -301,8 +296,14 @@ std::map<std::string, ServiceStatus> service_runner::get_all_services_status(std
return status; 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; 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; return status;
std::stringstream ss(output); std::stringstream ss(output);

View File

@ -1,13 +1,9 @@
#!/bin/bash #!/bin/bash
# This script contains the common code for the autocommands. # This script contains the common code for the autocommands.
_check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
MYID=$(id -u) MYID=$(id -u)
MYGRP=$(id -g) MYGRP=$(id -g)
BACKUP_TEMP_PATH="$TEMP_DIR/backup"
_autocommandrun_volume() { _autocommandrun_volume() {
local command="$1" local command="$1"
local volume_name="$2" local volume_name="$2"
@ -112,7 +108,8 @@ _autocommandparse() {
local command="$1" local command="$1"
shift shift
echo "autocommandparse: command=$command" local backup_temp_path="$1"
shift
# Extract the backup file and temp path (last two arguments) # Extract the backup file and temp path (last two arguments)
local args=("$@") local args=("$@")
@ -132,7 +129,7 @@ _autocommandparse() {
# create backup folder unique to key/value. # create backup folder unique to key/value.
local bfolder=$(echo "${key}_${value}" | tr -cd '[:alnum:]_-') local bfolder=$(echo "${key}_${value}" | tr -cd '[:alnum:]_-')
local targetpath="${BACKUP_TEMP_PATH}/${bfolder}" local targetpath="${backup_temp_path}/${bfolder}"
mkdir -p ${targetpath} mkdir -p ${targetpath}
# Key must be one of volume, path or file # Key must be one of volume, path or file
@ -155,31 +152,57 @@ _autocommandparse() {
autocreate() { 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() { 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() { autobackup() {
mkdir -p "$BACKUP_TEMP_PATH" _check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
echo "_autocommandparse [backup] [$@]" local backup_temp_path="$TEMP_DIR/backup"
_autocommandparse 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() { autorestore() {
echo "_autocommandparse [restore] [$@]" _check_required_env_vars "BACKUP_FILE" "TEMP_DIR"
local backup_temp_path="$TEMP_DIR/restore"
mkdir -p "$BACKUP_TEMP_PATH" echo "_autocommandparse [restore] [$backup_temp_path] [$@]"
tar zxvf "$BACKUP_FILE" -C "$BACKUP_TEMP_PATH" --strip-components=1
_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"
} }