This commit is contained in:
parent
940c2a12a1
commit
f79abd346e
@ -1,4 +1,6 @@
|
|||||||
# can you make this script run in bash, but fall back to sh if bash is not installed?
|
#!/bin/bash
|
||||||
|
|
||||||
|
# set up a remote server for use with dropshell.
|
||||||
|
|
||||||
# check if we are running as root
|
# check if we are running as root
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# install the dropshell host agent on this computer.
|
||||||
|
# (not for remote servers)
|
||||||
|
|
||||||
SCRIPT_DIR=$(dirname "$0")
|
SCRIPT_DIR=$(dirname "$0")
|
||||||
|
|
||||||
echo "Installing dropshell host agent on this computer..."
|
echo "Installing dropshell host agent on this computer..."
|
||||||
@ -22,27 +25,6 @@ _check_required_env_vars() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks if Docker is installed, running, and user has permission. Returns 1 on failure.
|
|
||||||
_check_docker_installed() {
|
|
||||||
if ! command -v docker &> /dev/null; then
|
|
||||||
echo "Docker is not installed"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if docker daemon is running
|
|
||||||
if ! docker info &> /dev/null; then
|
|
||||||
echo "Docker daemon is not running"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check if user has permission to run docker
|
|
||||||
if ! docker run --rm hello-world &> /dev/null; then
|
|
||||||
echo "User does not have permission to run docker"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_bb64() {
|
function install_bb64() {
|
||||||
# check curl installed
|
# check curl installed
|
||||||
@ -77,7 +59,5 @@ set +a
|
|||||||
_check_required_env_vars "AGENT_LOCAL_PATH"
|
_check_required_env_vars "AGENT_LOCAL_PATH"
|
||||||
echo "Installing host agent into $AGENT_LOCAL_PATH"
|
echo "Installing host agent into $AGENT_LOCAL_PATH"
|
||||||
|
|
||||||
_check_docker_installed || _die "Docker is required."
|
|
||||||
|
|
||||||
install_bb64
|
install_bb64
|
||||||
|
|
||||||
|
@ -37,11 +37,16 @@ fi
|
|||||||
|
|
||||||
print_status "Detected OS: $OS $VER"
|
print_status "Detected OS: $OS $VER"
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------------------------------------
|
||||||
|
# INSTALL PREREQUISITE PACKAGES
|
||||||
|
#----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Define packages based on distribution
|
# Define packages based on distribution
|
||||||
case $OS in
|
case $OS in
|
||||||
"Ubuntu"|"Debian GNU/Linux")
|
"Ubuntu"|"Debian GNU/Linux")
|
||||||
# Common packages for both Ubuntu and Debian
|
# Common packages for both Ubuntu and Debian
|
||||||
PACKAGES="cmake make g++ devscripts debhelper build-essential upx"
|
PACKAGES="cmake make g++ devscripts debhelper build-essential upx musl-tools wget tar ccache ninja-build"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
print_error "Unsupported distribution: $OS"
|
print_error "Unsupported distribution: $OS"
|
||||||
@ -73,19 +78,9 @@ for pkg in $PACKAGES; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Verify all required tools are installed
|
# ----------------------------------------------------------------------------------------------------------
|
||||||
print_status "Verifying installation..."
|
# MUSL CROSS COMPILERS
|
||||||
for tool in cmake make g++; do
|
# ----------------------------------------------------------------------------------------------------------
|
||||||
if ! command -v "$tool" &> /dev/null; then
|
|
||||||
print_error "$tool is not installed properly"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Install other required packages
|
|
||||||
apt install -y musl-tools wget tar ccache ninja-build
|
|
||||||
|
|
||||||
# Set install directory
|
# Set install directory
|
||||||
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
||||||
@ -121,17 +116,6 @@ if [ ! -d "$INSTALL_DIR/aarch64-linux-musl-cross" ]; then
|
|||||||
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/aarch64-linux-musl-cross.tgz"
|
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/aarch64-linux-musl-cross.tgz"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print instructions for adding to PATH
|
|
||||||
# cat <<EOF
|
|
||||||
|
|
||||||
# To use the musl cross compilers, add the following to your shell:
|
|
||||||
# export PATH="$INSTALL_DIR/x86_64-linux-musl-cross/bin:$INSTALL_DIR/aarch64-linux-musl-cross/bin:$PATH"
|
|
||||||
|
|
||||||
# Or run:
|
|
||||||
# export PATH="$INSTALL_DIR/x86_64-linux-musl-cross/bin:$INSTALL_DIR/aarch64-linux-musl-cross/bin:\$PATH"
|
|
||||||
|
|
||||||
# EOF
|
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
rm -rf "$TMPDIR"
|
rm -rf "$TMPDIR"
|
||||||
|
|
||||||
@ -149,6 +133,10 @@ if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------------------
|
||||||
|
# DEHYDRATE
|
||||||
|
# ----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# check if dehydrate command is installed
|
# check if dehydrate command is installed
|
||||||
if ! command -v dehydrate &> /dev/null; then
|
if ! command -v dehydrate &> /dev/null; then
|
||||||
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | bash
|
curl -fsSL https://gitea.jde.nz/public/dehydrate/releases/download/latest/install.sh | bash
|
||||||
@ -156,6 +144,9 @@ fi
|
|||||||
|
|
||||||
dehydrate -u
|
dehydrate -u
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------------------------------------
|
||||||
|
# COMPLETE
|
||||||
|
# ----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
print_status "All dependencies installed successfully!"
|
print_status "All dependencies installed successfully!"
|
||||||
print_status "You can now run ./build.sh to build the project"
|
print_status "You can now run ./build.sh to build the project"
|
Loading…
x
Reference in New Issue
Block a user