Update scripts.

This commit is contained in:
Your Name 2025-05-04 22:35:51 +12:00
parent 3460224e29
commit bbd7c635a8
15 changed files with 17 additions and 38 deletions

View File

@ -78,6 +78,9 @@ void list_servers() {
tableprint tp("All DropShell Servers");
tp.add_row({"Name", "User", "Address", "Health", "Ports"});
std::cout << "Checking "<<servers.size() << " servers: " << std::flush;
int checked = 0;
transwarp::parallel exec{servers.size()};
auto task = transwarp::for_each(exec, servers.begin(), servers.end(), [&](const ServerInfo& server) {
std::map<std::string, ServiceStatus> status = service_runner::get_all_services_status(server.name);
@ -93,8 +96,12 @@ void list_servers() {
ports_used_str += std::to_string(port) + " ";
tp.add_row({server.name, server.ssh_user, server.ssh_host, serviceticks, ports_used_str});
++checked;
// print out a tick character for each server checked.
std::cout << checked << "" << std::flush;
});
task->wait();
std::cout << std::endl << std::endl;
tp.print();
}

View File

@ -79,7 +79,7 @@ bool service_runner::install() {
}
}
// Copy service files (including service.env)
// Copy service files
{
std::string local_service_path = localpath::service(mServer,mService);
if (local_service_path.empty() || !fs::exists(local_service_path)) {

View File

@ -66,7 +66,7 @@ LocalServiceInfo get_service_info(const std::string &server_name, const std::str
std::map<std::string, std::string> variables;
get_all_service_env_vars(server_name, service_name, variables);
// load the service.env file
// confirm TEMPLATE is defined.
auto it = variables.find("TEMPLATE");
if (it == variables.end()) {
std::cerr << "Error: TEMPLATE variable not defined in service " << service_name << " on server " << server_name << std::endl;
@ -199,7 +199,7 @@ bool create_service(const std::string &server_name, const std::string &template_
std::cout << "Service " << service_name <<" created successfully"<<std::endl;
std::cout << std::endl;
std::cout << "To complete the installation, please:" << std::endl;
std::cout << "1. edit the service.env file: dropshell edit " << server_name << " " << service_name << std::endl;
std::cout << "1. edit the service config file: dropshell edit " << server_name << " " << service_name << std::endl;
std::cout << "2. install the remote service: dropshell install " << server_name << " " << service_name << std::endl;
}
return true;

View File

@ -4,6 +4,6 @@ _check_required_env_vars
# Main script.
echo "Container ${CONTAINER_NAME} logs:"
grey_start
_grey_start
docker logs "${CONTAINER_NAME}"
grey_end
_grey_end

View File

@ -21,7 +21,7 @@ DOCKER_RUN_CMD="docker run -d \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi

View File

@ -1,8 +1,8 @@
# Service settings specific to this server
# (can also override anything in the _default.env file in the template to make it specific to this server)
HOST_PORT=60123
LOCAL_DATA_FOLDER="${HOME}/.example-nginx"
CONTAINER_NAME=example-nginx
LOCAL_DATA_FOLDER="/home/dropshell/nginx-example-website"
CONTAINER_NAME="example-nginx"
IMAGE_TAG="latest"
# Scripts will have these environment variables set, plus those in _default.env, plus:

View File

@ -4,10 +4,6 @@ _check_required_env_vars "LOCAL_DATA_FOLDER" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAG
# Nginx Example Install Script
# Load service environment variables
source ./service.env
# Ensure local data folder exists
if [ ! -d "${LOCAL_DATA_FOLDER}" ]; then
echo "Creating local data folder ${LOCAL_DATA_FOLDER}..."

View File

@ -18,7 +18,7 @@ DOCKER_RUN_CMD="docker run -d \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi

View File

@ -26,7 +26,7 @@ DOCKER_RUN_CMD="docker run -d \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
if ! create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi

View File

@ -4,10 +4,6 @@ _check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_T
# Watchtower Install Script
# Load service environment variables
source ./service.env
echo "Checking Docker installation..."
_check_docker_installed || _die "Docker test failed, aborting installation..."

View File

@ -4,10 +4,6 @@ _check_required_env_vars "CONTAINER_NAME"
# Watchtower Logs Script
# Load service environment variables
source ./service.env
echo "Showing logs for ${CONTAINER_NAME}... (Press Ctrl+C to stop)"
_grey_start
_get_container_logs $CONTAINER_NAME

View File

@ -4,10 +4,6 @@ _check_required_env_vars
# Watchtower Start Script
# Load service environment variables
source ./service.env
# Optional arguments (e.g., --cleanup, --monitor-only)
EXTRA_ARGS=$1

View File

@ -4,10 +4,6 @@ _check_required_env_vars "CONTAINER_NAME"
# Watchtower Status Script
# Load service environment variables
source ./service.env
_is_container_running $CONTAINER_NAME || _die "Service is not running - did not find container $CONTAINER_NAME."
# Optional: Add specific health checks for Watchtower if needed.

View File

@ -4,10 +4,6 @@ _check_required_env_vars
# Watchtower Stop Script
# Load service environment variables
source ./service.env
echo "Stopping service ${CONTAINER_NAME}..."
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
echo "Service ${CONTAINER_NAME} stopped."

View File

@ -4,10 +4,6 @@ _check_required_env_vars
# Watchtower Uninstall Script
# Load service environment variables
source ./service.env
echo "Uninstalling service ${CONTAINER_NAME}..."
_remove_container $CONTAINER_NAME || _die "Failed to remove container ${CONTAINER_NAME}"