Skip to content

Commit

Permalink
Create rmfakecloud-proxy package (#448)
Browse files Browse the repository at this point in the history
This PR provides a new package intended to ease the setup of rmfakecloud on a device. [rmfakecloud](https://github.com/ddvk/rmfakecloud) is an alternative Xochitl sync server developed by ddvk that anyone can self-host. With this package, connecting to an rmfakecloud server only takes a few steps:

* `opkg install rmfakecloud-proxy`
* `rmfakecloudctl set-upstream https://...` (define the server to use)
* `rmfakecloudctl enable`

One can then run `rmfakecloudctl disable` (or uninstall the package) to revert back to the default reMarkable servers.

Co-authored-by: Nathaniel van Diepen <[email protected]>
  • Loading branch information
matteodelabre and Eeems committed Dec 15, 2021
1 parent 469aa83 commit 7a42f41
Show file tree
Hide file tree
Showing 3 changed files with 457 additions and 0 deletions.
82 changes: 82 additions & 0 deletions package/rmfakecloud-proxy/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(rmfakecloud-proxy)
pkgdesc="Connect Xochitl to a rmfakecloud server"
_url=https://github.com/ddvk/rmfakecloud-proxy
url="$_url"
_upver=0.0.3
pkgver="$_upver-1"
timestamp=2021-09-26T20:38:44Z
section="utils"
maintainer="Mattéo Delabre <[email protected]>"
license=MIT
installdepends=(procps-ng-pgrep findutils)

image=golang:v2.2
source=(
"https://github.com/ddvk/rmfakecloud-proxy/archive/v$_upver.zip"
rmfakecloudctl
rmfakecloud-proxy.service
)
sha256sums=(
eaa3fdcce250e23f368a4c9ddcfb99ff178decf31b2a7f84501dfc6fdb2e6d8f
SKIP
SKIP
)

build() {
eval "$(go env)"
cat > version.go << GO
package main
const Version = "rmfakecloud-proxy ${_upver%-*} ($GOOS-$GOARCH) $GOVERSION\n$_url"
GO

GOARCH=arm GOARM=7 go build -ldflags="-w -s" -o dist/rmfakecloud-proxy
}

package() {
install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/dist/rmfakecloud-proxy
install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/rmfakecloudctl
install -D -m 644 -t "$pkgdir"/lib/systemd/system "$srcdir"/rmfakecloud-proxy.service
}

configure() {
# shellcheck source=rmfakecloudctl
source /opt/bin/rmfakecloudctl
systemctl daemon-reload

# Sync the proxy state to the value of its configuration flag
if is-enabled; then
# This branch is reached when upgrading the package
install-certificates
systemctl enable --now rmfakecloud-proxy
install-hosts
else
uninstall-certificates
systemctl disable --now rmfakecloud-proxy
uninstall-hosts
fi

if ! is-enabled; then
cat << MSG
Run the following commands to use rmfakecloud-proxy:
$ rmfakecloudctl set-upstream https://your-server.example.org
$ rmfakecloudctl enable
Replace your-server.example.org with the address of the server you want to use.
MSG
fi
}

preremove() {
rmfakecloudctl disable
}

postremove() {
systemctl daemon-reload
}
15 changes: 15 additions & 0 deletions package/rmfakecloud-proxy/rmfakecloud-proxy.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=rmfakecloud reverse proxy
Documentation=https://github.com/ddvk/rmfakecloud-proxy
After=home.mount network.target
Before=xochitl.service launcher.service
ConditionPathExists=/opt/etc/rmfakecloud-proxy/enabled
ConditionPathExists=/opt/etc/rmfakecloud-proxy/config

[Service]
Environment=HOME=/home/root
ExecStart=/opt/bin/rmfakecloud-proxy -c /opt/etc/rmfakecloud-proxy/config
Restart=on-failure

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 7a42f41

Please sign in to comment.