From cd1e0f64d809eed89c34f0aa8874cfd3e10c919b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 3 Mar 2021 06:12:36 +0000 Subject: [PATCH] add rclone --- rclone/README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++ rclone/install.ps1 | 57 ++++++++++++++++++++++++++++++++++++++++++++++ rclone/install.sh | 44 +++++++++++++++++++++++++++++++++++ rclone/releases.js | 19 ++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 rclone/README.md create mode 100644 rclone/install.ps1 create mode 100644 rclone/install.sh create mode 100644 rclone/releases.js diff --git a/rclone/README.md b/rclone/README.md new file mode 100644 index 0000000..bd1918a --- /dev/null +++ b/rclone/README.md @@ -0,0 +1,55 @@ +--- +title: rclone +homepage: https://github.com/rclone/rclone +tagline: | + rclone: "rsync for cloud storage". +--- + +To update or switch versions, run `webi rclone@stable` (or `@v1.54`, `@beta`, +etc). + +## Cheat Sheet + +> rclone is like rsync, but optimized for cloud storage and SSDs. rclone is also +> faster than rsync for many use cases. + +`rclone` is compatible with a wide range of cloud storage providers including: + +- Google Drive +- S3 + - (AWS, Minio, Digital Ocean, etc) +- Dropbox +- Backblaze B2 +- One Drive +- Swift +- Hubic +- Wasabi +- Google Cloud Storage +- Yandex Files + +### How to copy local files, like rsync + +`rclone`s cloud-first, SSD-first optimizations can cause performance issues when +copying between HDDs. For performance more similar to `cp` (better than `rsync`) +you can use the following options: + +`--tranfers=1` will only copy one file at a time, preventing thrashing and +fragmentation. + +`--check-first` will catalog files before copying. + +`--order-by name` will copy files one directory at a time. + +Example: + +```bash +rclone sync -vP --transfers=1 --order-by name --check-first ~/ /Volumes/Backup/home +``` + +Example, excluding common temporary directories: + +```bash +rclone sync -vP --transfers=1 --order-by name --check-first \ + --exclude 'node_modules/**' --exclude '.Spotlight-*/**' --exclude '.cache*/**' \ + ~/ /Volumes/Backup/home +``` diff --git a/rclone/install.ps1 b/rclone/install.ps1 new file mode 100644 index 0000000..cac2d75 --- /dev/null +++ b/rclone/install.ps1 @@ -0,0 +1,57 @@ +#!/usr/bin/env pwsh + +################## +# Install rclone # +################## + +# Every package should define these variables +$pkg_cmd_name = "rclone" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\rclone.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\rclone-v$Env:WEBI_VERSION\bin\rclone.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\rclone-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\rclone-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading rclone from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing rclone" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\rclone-v*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\rclone.exe" -Recurse -ErrorAction Ignore + + # Unpack archive file into this temporary directory + # Windows BSD-tar handles zip. Imagine that. + echo "Unpacking $pkg_download" + & tar xf "$pkg_download" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force + Move-Item -Path ".\rclone.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/rclone/install.sh b/rclone/install.sh new file mode 100644 index 0000000..d00f404 --- /dev/null +++ b/rclone/install.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +function __init_rclone() { + set -e + set -u + + ################## + # Install rclone # + ################## + + # Every package should define these 6 variables + pkg_cmd_name="rclone" + + pkg_dst_cmd="$HOME/.local/bin/rclone" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/rclone-v$WEBI_VERSION/bin/rclone" + pkg_src_dir="$HOME/.local/opt/rclone-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + pkg_install() { + # $HOME/.local/opt/rclone-v0.6.5/bin + mkdir -p "$(dirname $pkg_src_cmd)" + + # mv ./rclone* "$HOME/.local/opt/rclone-v0.6.5/bin/rclone" + mv ./rclone*/rclone "$pkg_src_cmd" + + # chmod a+x "$HOME/.local/opt/rclone-v0.6.5/bin/rclone" + chmod a+x "$pkg_src_cmd" + } + + pkg_get_current_version() { + # 'rclone version' has output in this format: + # rclone v1.54.0 + # - os/arch: darwin/amd64 + # - go version: go1.15.7 + # This trims it down to just the version number: + # 1.54.0 + echo "$(rclone --version 2>/dev/null | head -n 1 | cut -d' ' -f2 | sed 's:^v::')" + } + +} + +__init_rclone diff --git a/rclone/releases.js b/rclone/releases.js new file mode 100644 index 0000000..2f3747c --- /dev/null +++ b/rclone/releases.js @@ -0,0 +1,19 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'rclone'; +var repo = 'rclone'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + all.releases = all.releases.slice(0, 10); + console.info(JSON.stringify(all, null, 2)); + }); +} -- 2.25.1