docs: Update 7 files
This commit is contained in:
@@ -46,28 +46,45 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|||||||
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
file(GLOB_RECURSE SOURCES "src/*.cpp")
|
||||||
file(GLOB_RECURSE HEADERS "src/*.hpp")
|
file(GLOB_RECURSE HEADERS "src/*.hpp")
|
||||||
|
|
||||||
# Add custom target to run cmake_prebuild.sh at the start of the build process
|
# Define the generated output files
|
||||||
add_custom_target(run_prebuild_script ALL
|
set(AGENT_REMOTE_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-remote.cpp)
|
||||||
|
set(AGENT_LOCAL_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-local.cpp)
|
||||||
|
|
||||||
|
# Get list of input files that trigger regeneration
|
||||||
|
file(GLOB AGENT_REMOTE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/agent-remote/*")
|
||||||
|
file(GLOB AGENT_LOCAL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/agent-local/*")
|
||||||
|
|
||||||
|
# Custom command with proper dependency tracking
|
||||||
|
# Runs cmake_prebuild.sh only when input files change or outputs are missing
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${AGENT_REMOTE_CPP} ${AGENT_LOCAL_CPP}
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "Running cmake_prebuild.sh..."
|
COMMAND ${CMAKE_COMMAND} -E echo "Running cmake_prebuild.sh..."
|
||||||
COMMAND ${CMAKE_COMMAND} -E env bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
||||||
|
DEPENDS
|
||||||
|
${AGENT_REMOTE_FILES}
|
||||||
|
${AGENT_LOCAL_FILES}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake_prebuild.sh
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
COMMENT "Generating agent source files from agent-remote/ and agent-local/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Custom target for manual invocation (e.g., "ninja run_prebuild_script")
|
||||||
|
add_custom_target(run_prebuild_script DEPENDS ${AGENT_REMOTE_CPP} ${AGENT_LOCAL_CPP})
|
||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
add_executable(dropshell ${SOURCES})
|
add_executable(dropshell ${SOURCES})
|
||||||
add_dependencies(dropshell run_prebuild_script)
|
|
||||||
|
|
||||||
# Mark the generated files as GENERATED so CMake knows they'll be created during build
|
# Mark the generated files as GENERATED so CMake knows they'll be created during build
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-remote.cpp
|
${AGENT_REMOTE_CPP}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-local.cpp
|
${AGENT_LOCAL_CPP}
|
||||||
PROPERTIES GENERATED TRUE
|
PROPERTIES GENERATED TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Explicitly add the generated agent files, as they might not be in the source directory when globbed at the start.
|
# Explicitly add the generated agent files
|
||||||
target_sources(dropshell PRIVATE
|
target_sources(dropshell PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-remote.cpp
|
${AGENT_REMOTE_CPP}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/autogen/_agent-local.cpp
|
${AGENT_LOCAL_CPP}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set include directories
|
# Set include directories
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ install_bb64
|
|||||||
|
|
||||||
# confirm we're in a good state.
|
# confirm we're in a good state.
|
||||||
|
|
||||||
|
echo "Confirming state..."
|
||||||
|
|
||||||
required_files=(
|
required_files=(
|
||||||
"$AGENT_PATH/bb64"
|
"$AGENT_PATH/bb64"
|
||||||
"$AGENT_PATH/common.sh"
|
"$AGENT_PATH/common.sh"
|
||||||
@@ -87,6 +89,10 @@ done
|
|||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
chmod a+x ${AGENT_PATH}/*.sh
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
echo "Completed dropshell agent installation."
|
echo "Completed dropshell agent installation."
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ set -e
|
|||||||
# CMake pre-build script.
|
# CMake pre-build script.
|
||||||
# Runs before the build process.
|
# Runs before the build process.
|
||||||
|
|
||||||
# This script creates two files:
|
|
||||||
# src/utils/createagent.hpp
|
|
||||||
# src/utils/createagent.cpp
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
# Create temporary directory for dehydrate
|
# Create temporary directory for dehydrate
|
||||||
|
|||||||
@@ -531,13 +531,12 @@ complete -F _dropshell_completions ds
|
|||||||
|
|
||||||
// create server_info.env
|
// create server_info.env
|
||||||
info << "Creating server_info.env on remote server... " <<std::flush;
|
info << "Creating server_info.env on remote server... " <<std::flush;
|
||||||
|
std::string lsiep = localpath::temp_files() + "/" + filenames::server_info_env;
|
||||||
|
if (std::filesystem::exists(lsiep)) std::filesystem::remove(lsiep);
|
||||||
|
if (!server.createServerInfoEnv(lsiep)) return 1;
|
||||||
std::string rsiep = remotefile(server.get_server_name(),user.user).server_info_env();
|
std::string rsiep = remotefile(server.get_server_name(),user.user).server_info_env();
|
||||||
sCommand cmd("","echo 'SERVER=\""+server.get_server_name()+"\"' > "+rsiep,{});
|
shared_commands::rsync_file_to_remote(lsiep,rsiep,server,false,user.user);
|
||||||
if (! execute_ssh_command(server.get_SSH_INFO(user.user),cmd,cMode::Defaults | cMode::NoBB64, nullptr))
|
if (std::filesystem::exists(lsiep)) std::filesystem::remove(lsiep);
|
||||||
{
|
|
||||||
error << std::endl << "Failed to create " << rsiep << " on " << server.get_server_name() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
info << "done." << std::endl;
|
info << "done." << std::endl;
|
||||||
|
|
||||||
// run the agent installer. Can't use BB64 yet, as we're installing it on the remote server.
|
// run the agent installer. Can't use BB64 yet, as we're installing it on the remote server.
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace dropshell
|
|||||||
std::string user)
|
std::string user)
|
||||||
{
|
{
|
||||||
ASSERT(!local_path.empty() && !remote_path.empty(), "Local or remote path not specified. Can't rsync.");
|
ASSERT(!local_path.empty() && !remote_path.empty(), "Local or remote path not specified. Can't rsync.");
|
||||||
ASSERT(std::filesystem::is_block_file(local_path), "Local path is not a file. Can't rsync.");
|
ASSERT(std::filesystem::is_regular_file(local_path), "Local path "+local_path+" is not a file. Can't rsync.");
|
||||||
|
|
||||||
std::string rsync_cmd = "rsync --mkpath -zpc -e 'ssh -p " + server_env.get_SSH_PORT() + "' " +
|
std::string rsync_cmd = "rsync --mkpath -zpc -e 'ssh -p " + server_env.get_SSH_PORT() + "' " +
|
||||||
quote(local_path) + " " +
|
quote(local_path) + " " +
|
||||||
|
|||||||
@@ -202,6 +202,20 @@ namespace dropshell
|
|||||||
return it != mUsers.end();
|
return it != mUsers.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServerConfig::createServerInfoEnv(std::string filepath) const
|
||||||
|
{
|
||||||
|
std::ofstream ofs(filepath);
|
||||||
|
if (!ofs.is_open())
|
||||||
|
{
|
||||||
|
error << "Couldn't write to " << filepath << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ofs << "# Autogenerated file by dropshell on installation." << std::endl;
|
||||||
|
ofs << "SERVER=\"" << mServerName << "\"" << std::endl;
|
||||||
|
ofs.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ServerConfig::check_remote_dir_exists(const std::string &dir_path, std::string user) const
|
bool ServerConfig::check_remote_dir_exists(const std::string &dir_path, std::string user) const
|
||||||
{
|
{
|
||||||
if (user.empty())
|
if (user.empty())
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ namespace dropshell
|
|||||||
// helper functions
|
// helper functions
|
||||||
bool hasUser(const std::string &user) const;
|
bool hasUser(const std::string &user) const;
|
||||||
|
|
||||||
|
bool createServerInfoEnv(std::string filepath) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool check_remote_dir_exists(const std::string &dir_path, std::string user) const;
|
bool check_remote_dir_exists(const std::string &dir_path, std::string user) const;
|
||||||
bool check_remote_file_exists(const std::string &file_path, std::string user) const;
|
bool check_remote_file_exists(const std::string &file_path, std::string user) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user