From ba866494cda179e1963d7e9f9f9c8509c7dc8137 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 14 May 2025 23:01:56 +1200 Subject: [PATCH] fix perms --- README.md | 1 - server_autosetup.sh | 7 ------- src/commands/install.cpp | 15 +++++++-------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9f0b7ef..740c198 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ curl -fsSL https://gitea.jde.nz/public/dropshell/releases/download/latest/server Manual steps: 1. `apt install curl wget jq` 1. `curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh && rm get-docker.sh` -1. `curl -fsSL https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh | bash` 1. `useradd -m dropshell && usermod -aG docker dropshell && chsh -s /bin/bash dropshell` 1. Put appropriate ssh keys in `/home/dropshell/.ssh/authorized_keys` 1. Test ssh'ing into the server. diff --git a/server_autosetup.sh b/server_autosetup.sh index ebbfd7e..5dd37a8 100755 --- a/server_autosetup.sh +++ b/server_autosetup.sh @@ -55,13 +55,6 @@ 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 873a720..2b3cfcf 100644 --- a/src/commands/install.cpp +++ b/src/commands/install.cpp @@ -307,21 +307,20 @@ namespace dropshell 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 + "'"; + // first install bb64. + std::string remote_cmd = + "ssh -p " + server_env.get_SSH_INFO().port + " " + server_env.get_SSH_INFO().user + "@" + server_env.get_SSH_INFO().host + + " 'mkdir -p " + quote(agent_path) + " && curl -fsSL \"https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh\" | bash -s -- " + + quote(agent_path) + " " + quote("$(id -u "+server_env.get_SSH_USER()+"):$(id -g "+server_env.get_SSH_USER()+")")+"'"; - std::cout << "Executing: " << fullcmd << std::endl; - if (!execute_local_command(fullcmd, nullptr, cMode::Silent)) { + std::cout << "Executing: " << remote_cmd << std::endl; + if (!execute_local_command(remote_cmd, 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;