Files
dropshell/source/agent-remote/agent-install.sh
Your Name d3f4ef68dd
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 36s
Build-Test-Publish / build (linux/arm64) (push) Successful in 59s
Update source/agent-remote/agent-install.sh
2025-08-23 18:01:51 +12:00

95 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# This script is used to install the dropshell agent on a remote server.
SCRIPT_DIR=$(dirname "$0")
set -a
AGENT_PATH="$SCRIPT_DIR"
set +a
if [ -f "$SCRIPT_DIR/common.sh" ]; then
source "$SCRIPT_DIR/common.sh"
else
echo "Error: common.sh not found in $SCRIPT_DIR"
exit 1
fi
_check_required_env_vars "AGENT_PATH"
function install_bb64() {
BB64_path="${AGENT_PATH}/bb64"
ARCH=$(uname -m)
if ! curl "http://getbin.xyz/bb64:latest-${ARCH}" > "${BB64_path}"; then
_die "Failed to install bb64. Curl returned non-zero exit code."
fi
chown "$(id -u "$USER"):$(id -g "$USER")" "${BB64_path}"
chmod +x "${BB64_path}"
# test if bb64 is installed
if VER=$("${BB64_path}" version); then
echo "bb64 v$VER installed."
else
_die "bb64 did not install correctly."
fi
return 0;
}
#-------------------------------------------------------------------------
# Check pre-requisites
# Check if curl is installed
if ! command -v curl &> /dev/null; then
_die "Curl is not installed. Curl is required for agent installation."
fi
# check docker installation
if ! command -v docker &> /dev/null; then
echo "Docker is not installed. Docker is required for agent installation."
exit 1
fi
# check rsync installation
if ! command -v rsync &> /dev/null; then
echo "Rsync is not installed. Rsync is required for agent installation."
exit 1
fi
#-------------------------------------------------------------------------
echo "Installing dropshell agent..."
install_bb64
#-------------------------------------------------------------------------
# confirm we're in a good state.
required_files=(
"$AGENT_PATH/bb64"
"$AGENT_PATH/_allservicesstatus.sh"
"$AGENT_PATH/common.sh"
"$AGENT_PATH/datacommands.sh"
)
# check if all files exist
for file in "${required_files[@]}"; do
if [ ! -f "$file" ]; then
_die "$file does not exist. Please check the installation."
fi
done
#-------------------------------------------------------------------------
echo "Completed dropshell agent installation."
#-------------------------------------------------------------------------
exit 0