allow run commands
This commit is contained in:
parent
1a4b82b361
commit
b622adfcf8
src
templates/squashkiwi
@ -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
|
||||
;;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ fi
|
||||
_stop_container "$CONTAINER_NAME"
|
||||
|
||||
# Create backup of data folder
|
||||
echo "Creating backup of $DATA_FOLDER..."
|
||||
if ! tar zcvf "$BACKUP_FILE" -C "$DATA_FOLDER" .; then
|
||||
echo "Creating backup of $LOCAL_DATA_FOLDER..."
|
||||
if ! tar zcvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .; then
|
||||
_start_container "$CONTAINER_NAME"
|
||||
die "Failed to create backup"
|
||||
fi
|
||||
|
@ -70,11 +70,10 @@ function create_folder() {
|
||||
if ! mkdir -p "$folder"; then
|
||||
die "Failed to create folder: $folder"
|
||||
fi
|
||||
chmod 777 "$folder"
|
||||
echo "Folder created: $folder"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Check if docker is installed
|
||||
_check_docker_installed() {
|
||||
if ! command -v docker &> /dev/null; then
|
||||
|
@ -7,8 +7,7 @@ _check_docker_installed || die "Docker test failed, aborting installation..."
|
||||
|
||||
# Create deploy and data folders
|
||||
[ -z "$LOCAL_DATA_FOLDER" ] && die "LOCAL_DATA_FOLDER is not set"
|
||||
create_folder "$LOCAL_DATA_FOLDER/data"
|
||||
create_folder "$LOCAL_DATA_FOLDER/backups"
|
||||
create_folder "$LOCAL_DATA_FOLDER"
|
||||
|
||||
# check can pull image on remote host and exit if fails
|
||||
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
|
||||
|
@ -6,7 +6,7 @@ DOCKER_RUN_CMD="docker run -d \
|
||||
--restart unless-stopped \
|
||||
--name ${CONTAINER_NAME} \
|
||||
-p ${HOST_PORT}:${CONTAINER_PORT} \
|
||||
-v ${LOCAL_DATA_FOLDER}/data:/skdata \
|
||||
-v ${LOCAL_DATA_FOLDER}:/skdata \
|
||||
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user