'Generic Commit'
This commit is contained in:
25
install.sh
25
install.sh
@@ -7,30 +7,21 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
|||||||
|
|
||||||
PROJECT="simple-object-server"
|
PROJECT="simple-object-server"
|
||||||
|
|
||||||
|
function die() {
|
||||||
|
echo "error: $1" && exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Set target directory - use ~/.local/bin by default, /usr/local/bin if root
|
# Set target directory - use ~/.local/bin by default, /usr/local/bin if root
|
||||||
if [ "$(id -u)" = "0" ]; then
|
TARGET_DIR="/usr/local/bin"
|
||||||
TARGET_DIR="/usr/local/bin"
|
if [ "$(id -u)" != "0" ]; then
|
||||||
else
|
|
||||||
TARGET_DIR="${HOME}/.local/bin"
|
TARGET_DIR="${HOME}/.local/bin"
|
||||||
# Create ~/.local/bin if it doesn't exist
|
|
||||||
mkdir -p "${TARGET_DIR}"
|
mkdir -p "${TARGET_DIR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v wget >/dev/null 2>&1; then
|
command -v wget >/dev/null 2>&1 || die "wget is not installed. Please install wget and try again."
|
||||||
echo "wget is not installed. Please install wget and try again."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
if [ "${ARCH}" = "x86_64" ]; then
|
|
||||||
ARCH="amd64"
|
|
||||||
elif [ "${ARCH}" = "aarch64" ]; then
|
|
||||||
ARCH="arm64"
|
|
||||||
else
|
|
||||||
echo "Unsupported architecture: ${ARCH}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
wget https://getbin.xyz/simple-object-server:${ARCH} -O "${TARGET_DIR}/simple-object-server"
|
wget "https://getbin.xyz/simple-object-server:latest-${ARCH}" -O "${TARGET_DIR}/simple-object-server"
|
||||||
chmod +x "${TARGET_DIR}/simple-object-server"
|
chmod +x "${TARGET_DIR}/simple-object-server"
|
||||||
|
|
||||||
|
18
publish.sh
18
publish.sh
@@ -3,6 +3,9 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
TEMP_DIR="${SCRIPT_DIR}/temp"
|
||||||
|
SOS="${TEMP_DIR}/sos"
|
||||||
|
|
||||||
echo "Publishing simple-object-server to gitea.jde.nz/public/simple-object-server:latest"
|
echo "Publishing simple-object-server to gitea.jde.nz/public/simple-object-server:latest"
|
||||||
|
|
||||||
@@ -13,10 +16,11 @@ function die() {
|
|||||||
|
|
||||||
[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified"
|
[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified"
|
||||||
|
|
||||||
|
# clear output dir
|
||||||
rm -rf "${SCRIPT_DIR}/output"
|
rm -rf "${SCRIPT_DIR}/output"
|
||||||
mkdir -p "${SCRIPT_DIR}/output"
|
mkdir -p "${SCRIPT_DIR}/output"
|
||||||
|
|
||||||
|
# build release version
|
||||||
export CMAKE_BUILD_TYPE="Release"
|
export CMAKE_BUILD_TYPE="Release"
|
||||||
export PROJECT="simple-object-server"
|
export PROJECT="simple-object-server"
|
||||||
|
|
||||||
@@ -30,18 +34,12 @@ docker build \
|
|||||||
|
|
||||||
[ -f ${SCRIPT_DIR}/output/simple-object-server ] || die "Build failed."
|
[ -f ${SCRIPT_DIR}/output/simple-object-server ] || die "Build failed."
|
||||||
|
|
||||||
# uplaod to getbin.xyz
|
# download the sos binary
|
||||||
|
mkdir -p "${TEMP_DIR}"
|
||||||
# # download the sos binary
|
trap 'rm -rf "${TEMP_DIR}"' EXIT
|
||||||
SOS="${SCRIPT_DIR}/temp/sos"
|
|
||||||
mkdir -p "${SCRIPT_DIR}/temp"
|
|
||||||
trap 'rm -rf "${SCRIPT_DIR}/temp"' EXIT
|
|
||||||
|
|
||||||
curl -L -o "${SOS}" "https://getbin.xyz/sos"
|
curl -L -o "${SOS}" "https://getbin.xyz/sos"
|
||||||
chmod +x "${SOS}"
|
chmod +x "${SOS}"
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
|
||||||
|
|
||||||
# upload arch-specific binary
|
# upload arch-specific binary
|
||||||
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/output/${PROJECT}" "${PROJECT}:latest-${ARCH}"
|
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/output/${PROJECT}" "${PROJECT}:latest-${ARCH}"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user