allow run commands
This commit is contained in:
parent
1a4b82b361
commit
b622adfcf8
@ -17,52 +17,41 @@ _dropshell_completions() {
|
|||||||
|
|
||||||
# Command-specific completions
|
# Command-specific completions
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
status)
|
status|templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands)
|
||||||
# No additional completions for status
|
# No additional completions for these commands
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
return 0
|
||||||
;;
|
;;
|
||||||
servers)
|
servers)
|
||||||
# Use the new autocomplete_list_servers command
|
# Show available server names for 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
|
|
||||||
local servers=($(dropshell autocomplete_list_servers))
|
local servers=($(dropshell autocomplete_list_servers))
|
||||||
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${servers[*]}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Handle completion for service names and commands after run/install/backup
|
# Handle completion for service names and commands after run/install/backup/etc
|
||||||
if [[ ${COMP_CWORD} -ge 2 ]] && [[ "${COMP_WORDS[1]}" == "run" || "${COMP_WORDS[1]}" == "install" || "${COMP_WORDS[1]}" == "backup" ]]; then
|
if [[ ${COMP_CWORD} -ge 2 ]]; then
|
||||||
if [[ ${COMP_CWORD} -eq 3 ]]; then
|
if [[ ${COMP_CWORD} -eq 2 ]]; then
|
||||||
# Second argument is service name
|
# 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 server_name="${COMP_WORDS[2]}"
|
||||||
local services=($(dropshell autocomplete_list_services "$server_name"))
|
local services=($(dropshell autocomplete_list_services "$server_name"))
|
||||||
COMPREPLY=( $(compgen -W "${services[*]}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${services[*]}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
elif [[ ${COMP_CWORD} -eq 4 && "${COMP_WORDS[1]}" == "run" ]]; then
|
elif [[ ${COMP_CWORD} -eq 4 ]]; then
|
||||||
# Third argument is command name (only for run command)
|
if [[ ${COMP_WORDS[1]} == "run" ]]; then
|
||||||
# For now, we'll just complete with common commands
|
# Fourth argument is command name - only relevant for run.
|
||||||
local common_commands="status start stop update backup"
|
local commands=($(dropshell autocomplete_list_commands))
|
||||||
COMPREPLY=( $(compgen -W "${common_commands}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${commands[*]}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
|
else
|
||||||
|
COMPREPLY=()
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -242,7 +242,7 @@ bool server_service::backup() {
|
|||||||
|
|
||||||
std::string ssh_cmd = construct_ssh_cmd();
|
std::string ssh_cmd = construct_ssh_cmd();
|
||||||
std::string script_dir = get_script_dir();
|
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.
|
// 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()))
|
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
|
// Run backup script
|
||||||
std::string backup_cmd = "'cd " + script_dir +
|
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")) {
|
if (!execute_ssh_command(backup_cmd, "Backup script failed")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ fi
|
|||||||
_stop_container "$CONTAINER_NAME"
|
_stop_container "$CONTAINER_NAME"
|
||||||
|
|
||||||
# Create backup of data folder
|
# Create backup of data folder
|
||||||
echo "Creating backup of $DATA_FOLDER..."
|
echo "Creating backup of $LOCAL_DATA_FOLDER..."
|
||||||
if ! tar zcvf "$BACKUP_FILE" -C "$DATA_FOLDER" .; then
|
if ! tar zcvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER" .; then
|
||||||
_start_container "$CONTAINER_NAME"
|
_start_container "$CONTAINER_NAME"
|
||||||
die "Failed to create backup"
|
die "Failed to create backup"
|
||||||
fi
|
fi
|
||||||
|
@ -70,11 +70,10 @@ function create_folder() {
|
|||||||
if ! mkdir -p "$folder"; then
|
if ! mkdir -p "$folder"; then
|
||||||
die "Failed to create folder: $folder"
|
die "Failed to create folder: $folder"
|
||||||
fi
|
fi
|
||||||
|
chmod 777 "$folder"
|
||||||
echo "Folder created: $folder"
|
echo "Folder created: $folder"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check if docker is installed
|
# Check if docker is installed
|
||||||
_check_docker_installed() {
|
_check_docker_installed() {
|
||||||
if ! command -v docker &> /dev/null; then
|
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
|
# Create deploy and data folders
|
||||||
[ -z "$LOCAL_DATA_FOLDER" ] && die "LOCAL_DATA_FOLDER is not set"
|
[ -z "$LOCAL_DATA_FOLDER" ] && die "LOCAL_DATA_FOLDER is not set"
|
||||||
create_folder "$LOCAL_DATA_FOLDER/data"
|
create_folder "$LOCAL_DATA_FOLDER"
|
||||||
create_folder "$LOCAL_DATA_FOLDER/backups"
|
|
||||||
|
|
||||||
# check can pull image on remote host and exit if fails
|
# 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"
|
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 \
|
--restart unless-stopped \
|
||||||
--name ${CONTAINER_NAME} \
|
--name ${CONTAINER_NAME} \
|
||||||
-p ${HOST_PORT}:${CONTAINER_PORT} \
|
-p ${HOST_PORT}:${CONTAINER_PORT} \
|
||||||
-v ${LOCAL_DATA_FOLDER}/data:/skdata \
|
-v ${LOCAL_DATA_FOLDER}:/skdata \
|
||||||
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
|
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user