|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright (c) 2021 The Toltec Contributors |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +pkgnames=(rmfakecloud-proxy) |
| 6 | +pkgdesc="Connect Xochitl to a rmfakecloud server" |
| 7 | +_url=https://github.com/ddvk/rmfakecloud-proxy |
| 8 | +url="$_url" |
| 9 | +_upver=0.0.3 |
| 10 | +pkgver="$_upver-1" |
| 11 | +timestamp=2021-09-26T20:38:44Z |
| 12 | +section="utils" |
| 13 | +maintainer= "Mattéo Delabre <[email protected]>" |
| 14 | +license=MIT |
| 15 | +installdepends=(procps-ng-pgrep findutils) |
| 16 | + |
| 17 | +image=golang:v2.2 |
| 18 | +source=( |
| 19 | + "https://github.com/ddvk/rmfakecloud-proxy/archive/v$_upver.zip" |
| 20 | + rmfakecloudctl |
| 21 | + rmfakecloud-proxy.service |
| 22 | +) |
| 23 | +sha256sums=( |
| 24 | + eaa3fdcce250e23f368a4c9ddcfb99ff178decf31b2a7f84501dfc6fdb2e6d8f |
| 25 | + SKIP |
| 26 | + SKIP |
| 27 | +) |
| 28 | + |
| 29 | +build() { |
| 30 | + eval "$(go env)" |
| 31 | + cat > version.go << GO |
| 32 | +package main |
| 33 | +const Version = "rmfakecloud-proxy ${_upver%-*} ($GOOS-$GOARCH) $GOVERSION\n$_url" |
| 34 | +GO |
| 35 | + |
| 36 | + GOARCH=arm GOARM=7 go build -ldflags="-w -s" -o dist/rmfakecloud-proxy |
| 37 | +} |
| 38 | + |
| 39 | +package() { |
| 40 | + install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/dist/rmfakecloud-proxy |
| 41 | + install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/rmfakecloudctl |
| 42 | + install -D -m 644 -t "$pkgdir"/lib/systemd/system "$srcdir"/rmfakecloud-proxy.service |
| 43 | +} |
| 44 | + |
| 45 | +configure() { |
| 46 | + # shellcheck source=rmfakecloudctl |
| 47 | + source /opt/bin/rmfakecloudctl |
| 48 | + systemctl daemon-reload |
| 49 | + |
| 50 | + # Sync the proxy state to the value of its configuration flag |
| 51 | + if is-enabled; then |
| 52 | + # This branch is reached when upgrading the package |
| 53 | + install-certificates |
| 54 | + systemctl enable --now rmfakecloud-proxy |
| 55 | + install-hosts |
| 56 | + else |
| 57 | + uninstall-certificates |
| 58 | + systemctl disable --now rmfakecloud-proxy |
| 59 | + uninstall-hosts |
| 60 | + fi |
| 61 | + |
| 62 | + if ! is-enabled; then |
| 63 | + cat << MSG |
| 64 | +
|
| 65 | +Run the following commands to use rmfakecloud-proxy: |
| 66 | +
|
| 67 | +$ rmfakecloudctl set-upstream https://your-server.example.org |
| 68 | +$ rmfakecloudctl enable |
| 69 | +
|
| 70 | +Replace your-server.example.org with the address of the server you want to use. |
| 71 | +
|
| 72 | +MSG |
| 73 | + fi |
| 74 | +} |
| 75 | + |
| 76 | +preremove() { |
| 77 | + rmfakecloudctl disable |
| 78 | +} |
| 79 | + |
| 80 | +postremove() { |
| 81 | + systemctl daemon-reload |
| 82 | +} |
0 commit comments