allow run commands

This commit is contained in:
Your Name
2025-04-21 19:56:14 +12:00
parent 1a4b82b361
commit b622adfcf8
6 changed files with 30 additions and 43 deletions

View File

@ -17,52 +17,41 @@ _dropshell_completions() {
# Command-specific completions
case "${prev}" in
status)
# No additional completions for status
status|templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands)
# No additional completions for these commands
COMPREPLY=()
return 0
;;
servers)
# Use the new autocomplete_list_servers command
local servers=($(dropshell autocomplete_list_servers))
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
return 0
;;
templates)
# No additional completions for templates
COMPREPLY=()
;;
autocomplete_list_services)
# Use the new autocomplete_list_servers command for server names
local servers=($(dropshell autocomplete_list_servers))
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
return 0
;;
autocomplete_list_commands)
# No additional completions needed
COMPREPLY=()
return 0
;;
run|install|backup)
# First argument after run/install/backup is server name
# Show available server names for servers command
local servers=($(dropshell autocomplete_list_servers))
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
return 0
;;
*)
# Handle completion for service names and commands after run/install/backup
if [[ ${COMP_CWORD} -ge 2 ]] && [[ "${COMP_WORDS[1]}" == "run" || "${COMP_WORDS[1]}" == "install" || "${COMP_WORDS[1]}" == "backup" ]]; then
if [[ ${COMP_CWORD} -eq 3 ]]; then
# Second argument is service name
# Handle completion for service names and commands after run/install/backup/etc
if [[ ${COMP_CWORD} -ge 2 ]]; then
if [[ ${COMP_CWORD} -eq 2 ]]; then
# Second argument is server name
local servers=($(dropshell autocomplete_list_servers))
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
return 0
elif [[ ${COMP_CWORD} -eq 3 ]]; then
# Third argument is service name
local server_name="${COMP_WORDS[2]}"
local services=($(dropshell autocomplete_list_services "$server_name"))
COMPREPLY=( $(compgen -W "${services[*]}" -- ${cur}) )
return 0
elif [[ ${COMP_CWORD} -eq 4 && "${COMP_WORDS[1]}" == "run" ]]; then
# Third argument is command name (only for run command)
# For now, we'll just complete with common commands
local common_commands="status start stop update backup"
COMPREPLY=( $(compgen -W "${common_commands}" -- ${cur}) )
return 0
elif [[ ${COMP_CWORD} -eq 4 ]]; then
if [[ ${COMP_WORDS[1]} == "run" ]]; then
# Fourth argument is command name - only relevant for run.
local commands=($(dropshell autocomplete_list_commands))
COMPREPLY=( $(compgen -W "${commands[*]}" -- ${cur}) )
return 0
else
COMPREPLY=()
return 0
fi
fi
fi
;;

View File

@ -242,7 +242,7 @@ bool server_service::backup() {
std::string ssh_cmd = construct_ssh_cmd();
std::string script_dir = get_script_dir();
std::string script_path = script_dir + "/backup.sh";
std::string script_path = script_dir + "/_backup.sh";
// Check if basic installed stuff is in place.
if (!check_service_dir_exists(ssh_cmd) || !check_remote_file_exists(ssh_cmd, script_path) || !check_remote_file_exists(ssh_cmd, get_env_path()))
@ -279,7 +279,7 @@ bool server_service::backup() {
// Run backup script
std::string backup_cmd = "'cd " + script_dir +
" && /bin/bash _backup.sh " + get_env_path() + " " + server_backup_path + "'";
" && /bin/bash \""+script_path+"\" " + get_env_path() + " " + server_backup_path + "'";
if (!execute_ssh_command(backup_cmd, "Backup script failed")) {
return false;
}