Last active
November 14, 2023 23:27
-
-
Save dotysan/99c7815f7dfea784695f1b592faa017e to your computer and use it in GitHub Desktop.
Install rclone on a Go-less system using Go in Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# | |
# Install rclone on a Go-less system using Go in Docker. | |
# | |
set -ex | |
# latest stable release | |
RC_TAG=v1.64.2 | |
GO_VER=1-bookworm | |
main() { | |
src | |
cd rclone.git | |
git switch --detach $RC_TAG | |
img | |
bld | |
#tst | |
ins | |
cd .. | |
cln | |
} | |
src() { | |
! test -d rclone.git ||return 0 | |
git clone [email protected]:rclone/rclone.git rclone.git | |
} | |
img() { | |
docker pull golang:$GO_VER | |
docker build -t build-rclone - <<-EOF | |
FROM golang:$GO_VER | |
# give make build proper perms in .:/rclone | |
RUN useradd --uid $UID --user-group \ | |
--create-home --shell /bin/bash $USER | |
# build static binary | |
ENV CGO_ENABLED=0 | |
WORKDIR /rclone | |
EOF | |
} | |
bld() { | |
docker run --rm \ | |
--volume "$PWD:/rclone" \ | |
--user "$UID:$UID" \ | |
build-rclone \ | |
go build | |
#make | |
} | |
tst() { | |
docker run --rm \ | |
--volume "$PWD:/rclone" \ | |
--user "$UID:$UID" \ | |
build-rclone \ | |
make test | |
} | |
ins() { | |
mkdir --parents ~/.local/bin | |
cp --force --preserve rclone ~/.local/bin/ | |
} | |
cln() { | |
rm --force --recursive rclone.git | |
docker image rm build-rclone | |
} | |
main | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment