From 47dcfca5f28f772af805f99d9dfc4be70682f625 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 14 May 2025 22:22:15 +1200 Subject: [PATCH] dropshell release 2025.0514.2222 --- build.sh | 41 ++++++------------- publish.sh | 2 +- .../host_autosetup.sh => server_autosetup.sh | 7 ++++ src/commands/install.cpp | 32 ++++++++++++++- src/commands/nuke.cpp | 2 +- 5 files changed, 52 insertions(+), 32 deletions(-) rename remote_host_autosetup/host_autosetup.sh => server_autosetup.sh (92%) diff --git a/build.sh b/build.sh index 3675955..504aa72 100755 --- a/build.sh +++ b/build.sh @@ -9,15 +9,11 @@ GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color -# Parse command line arguments -AUTO_INSTALL=false -for arg in "$@"; do - case $arg in - --auto-install) - AUTO_INSTALL=true - ;; - esac -done +JOBS=4 +# Determine number of CPU cores for parallel build +if command -v nproc >/dev/null 2>&1; then + JOBS=$(nproc) +fi # Function to print status messages @@ -79,7 +75,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug # Build the project print_status "Building project..." -make -j$(nproc) +make -j"$JOBS" # Check if build was successful if [ $? -eq 0 ]; then @@ -90,27 +86,16 @@ else exit 1 fi -# Check if user wants to install -if [ $AUTO_INSTALL = true ]; then - print_status "Auto-installing dropshell..." - sudo make install - if [ $? -eq 0 ]; then - print_status "Installation successful!" - else - print_error "Installation failed!" - exit 1 - fi +print_status "Auto-installing dropshell..." +sudo make install +if [ $? -eq 0 ]; then + print_status "Installation successful!" else - print_status "Installing dropshell..." - sudo make install - if [ $? -eq 0 ]; then - print_status "Installation successful!" - else - print_error "Installation failed!" - exit 1 - fi + print_error "Installation failed!" + exit 1 fi + # Return to original directory cd .. diff --git a/publish.sh b/publish.sh index e011343..1fd7dd4 100755 --- a/publish.sh +++ b/publish.sh @@ -72,7 +72,7 @@ if [ -z "$RELEASE_ID" ]; then fi # Upload binaries and install.sh -for FILE in dropshell.amd64 dropshell.arm64 install.sh; do +for FILE in dropshell.amd64 dropshell.arm64 install.sh server_autosetup.sh; do if [ -f "build/$FILE" ]; then filetoupload="build/$FILE" elif [ -f "$FILE" ]; then diff --git a/remote_host_autosetup/host_autosetup.sh b/server_autosetup.sh similarity index 92% rename from remote_host_autosetup/host_autosetup.sh rename to server_autosetup.sh index 3187005..8dc328e 100755 --- a/remote_host_autosetup/host_autosetup.sh +++ b/server_autosetup.sh @@ -55,6 +55,13 @@ if ! command -v docker &> /dev/null; then rm get-docker.sh fi +# check bb64 installation +if ! command -v bb64 &> /dev/null; then + echo "bb64 is not installed." + echo "Installing bb64..." + curl -fsSL https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh | bash +fi + # check dropshell user exists if ! id "dropshell" &> /dev/null; then echo "Dropshell user does not exist." diff --git a/src/commands/install.cpp b/src/commands/install.cpp index 6adc3ff..873a720 100644 --- a/src/commands/install.cpp +++ b/src/commands/install.cpp @@ -290,15 +290,43 @@ namespace dropshell if (rval != 0) return rval; + std::cout << "Installation complete." << std::endl; return 0; } int install_server(const std::string &server) { - #pragma WARNING "Need to implement install_server" // install the dropshell agent on the given server. - return 1; // NOTIMPL + std::cout << "Installing dropshell agent on " << server << std::endl; + + std::string agent_path = remotepath::agent(server); + if (agent_path.empty()) + { + std::cerr << "Failed to get agent path for " << server << std::endl; + return 1; + } + + // first install bb64. + std::string remote_cmd = + "curl -fsSL https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh | bash -s -- " + agent_path; + + server_env_manager server_env(server); + if (!server_env.is_valid()) { + std::cerr << "Invalid server environment for " << server << std::endl; + return 1; + } + + std::string fullcmd = "ssh -p " + server_env.get_SSH_INFO().port + " " + server_env.get_SSH_INFO().user + "@" + server_env.get_SSH_INFO().host; + fullcmd += " bash -c '" + remote_cmd + "'"; + + std::cout << "Executing: " << fullcmd << std::endl; + if (!execute_local_command(fullcmd, nullptr, cMode::Silent)) { + std::cerr << "Failed to download bb64 to " << agent_path << " on remote server." << std::endl; + } else { + std::cout << "Downloaded bb64 to " << agent_path << " on remote server." << std::endl; + } + return 0; // NOTIMPL } // ------------------------------------------------------------------------------------------------ diff --git a/src/commands/nuke.cpp b/src/commands/nuke.cpp index 1cab57a..6b2bf2a 100644 --- a/src/commands/nuke.cpp +++ b/src/commands/nuke.cpp @@ -9,7 +9,7 @@ #include "utils/assert.hpp" -#pragma TODO("Fix issues with Nuke below.") +#pragma message ("TODO: Fix issues with Nuke below.") /*