diff --git a/README.md b/README.md index 740c198..1000fbe 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ A system management tool for server operations, written in C++. curl -fsSL https://gitea.jde.nz/public/dropshell/releases/download/latest/install.sh | sudo bash ``` +This installs as dropshell, with a symlink ds if the ds command does not already exist. + ## Installation of Agent Install the Agent on each server you wish to manage. Supports amd64 (x86_64) and arm64 (aarch64) architectures. @@ -24,3 +26,7 @@ Manual steps: 1. Test ssh'ing into the server. +## Install Services + +Set up a server and install a service: +1. `ds create-server SERVERNAME` diff --git a/source/multibuild.sh b/source/multibuild.sh index e3beec9..afc3c0a 100755 --- a/source/multibuild.sh +++ b/source/multibuild.sh @@ -6,7 +6,9 @@ set -e -rm -f build_amd64/dropshell build_arm64/dropshell build/dropshell.amd64 build/dropshell.arm64 +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +rm -f $SCRIPT_DIR/build_amd64/dropshell $SCRIPT_DIR/build_arm64/dropshell $SCRIPT_DIR/output/dropshell.amd64 $SCRIPT_DIR/output/dropshell.arm64 # Determine number of CPU cores for parallel build if command -v nproc >/dev/null 2>&1; then @@ -15,6 +17,9 @@ else JOBS=4 # fallback default fi +PREV_PWD=$PWD +cd $SCRIPT_DIR + # Build for amd64 (musl) echo "Building for amd64 (musl)..." cmake -B build_amd64 -DCMAKE_BUILD_TYPE=Release \ @@ -23,8 +28,8 @@ cmake -B build_amd64 -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXE_LINKER_FLAGS="-static" \ -DCMAKE_CXX_FLAGS="-march=x86-64" . cmake --build build_amd64 --target dropshell --config Release -j"$JOBS" -mkdir -p build -cp build_amd64/dropshell build/dropshell.amd64 +mkdir -p output +cp build_amd64/dropshell output/dropshell.amd64 # Build for arm64 (musl) echo "Building for arm64 (musl)..." @@ -35,18 +40,20 @@ cmake -B build_arm64 -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_FLAGS="-march=armv8-a" \ -DCMAKE_SYSTEM_PROCESSOR=aarch64 . cmake --build build_arm64 --target dropshell --config Release -j"$JOBS" -mkdir -p build -cp build_arm64/dropshell build/dropshell.arm64 +mkdir -p output +cp build_arm64/dropshell output/dropshell.arm64 -if [ ! -f build/dropshell.amd64 ]; then - echo "build/dropshell.amd64 not found!" >&2 +if [ ! -f output/dropshell.amd64 ]; then + echo "output/dropshell.amd64 not found!" >&2 exit 1 fi -if [ ! -f build/dropshell.arm64 ]; then - echo "build/dropshell.arm64 not found!" >&2 +if [ ! -f output/dropshell.arm64 ]; then + echo "output/dropshell.arm64 not found!" >&2 exit 1 fi echo "Builds complete:" -ls -lh build/dropshell.* +ls -lh output/dropshell.* + +cd $PREV_PWD \ No newline at end of file diff --git a/source/publish.sh b/source/publish.sh index 1fd7dd4..63b78d5 100755 --- a/source/publish.sh +++ b/source/publish.sh @@ -1,6 +1,10 @@ #!/bin/bash set -e +# directory of this script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +echo "Script directory: $SCRIPT_DIR" + # Check for GITEA_TOKEN_DEPLOY or GITEA_TOKEN if [ -n "$GITEA_TOKEN_DEPLOY" ]; then TOKEN="$GITEA_TOKEN_DEPLOY" @@ -11,27 +15,32 @@ else exit 1 fi +$SCRIPT_DIR/multibuild.sh +BUILD_DIR=$SCRIPT_DIR/build -./multibuild.sh +OLD_PWD=$PWD +cd $SCRIPT_DIR -if [ ! -f "build/dropshell.amd64" ]; then - echo "build/dropshell.amd64 not found!" >&2 + +if [ ! -f "output/dropshell.amd64" ]; then + echo "output/dropshell.amd64 not found!" >&2 echo "Please run multibuild.sh first." >&2 exit 1 fi -if [ ! -f "build/dropshell.arm64" ]; then - echo "build/dropshell.arm64 not found!" >&2 +if [ ! -f "output/dropshell.arm64" ]; then + echo "output/dropshell.arm64 not found!" >&2 echo "Please run multibuild.sh first." >&2 exit 1 fi -TAG=$(./build/dropshell.amd64 --version) +TAG=$("$SCRIPT_DIR/output/dropshell.amd64" --version) +[ -z "$TAG" ] && echo "Failed to get version from dropshell.amd64" >&2 && exit 1 echo "Publishing dropshell version $TAG" # make sure we've commited. -git add . && git commit -m "dropshell release $TAG" && git push +git add "$SCRIPT_DIR/../" && git commit -m "dropshell release $TAG" && git push # Find repo info from .git/config @@ -73,8 +82,10 @@ fi # Upload binaries and install.sh for FILE in dropshell.amd64 dropshell.arm64 install.sh server_autosetup.sh; do - if [ -f "build/$FILE" ]; then - filetoupload="build/$FILE" + if [ -f "output/$FILE" ]; then + filetoupload="output/$FILE" + elif [ -f "../$FILE" ]; then + filetoupload="../$FILE" elif [ -f "$FILE" ]; then filetoupload="$FILE" else @@ -93,3 +104,5 @@ for FILE in dropshell.amd64 dropshell.arm64 install.sh server_autosetup.sh; do done echo "Published dropshell version $TAG to $REPO_URL (tag $TAG) with binaries." + +cd $OLD_PWD \ No newline at end of file