Skip to content

Proposal: Updating the binary version automatically via shell script #13015

Closed
@keks24

Description

@keks24
  • Operating system:
$ < /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Description

Hello,

I wrote a shell script to update my local Gitea instance automatically. I would like to leave this here, so others have a use of it.

Currently it only downloads the amd64 binary version from GitHub. Others may make it more dynamic.

Maybe it is useful and stable enough to mentioning it here or put it into the contrib directory?

Prerequisites:

The following packages are installed:

  • aria2c
  • curl
  • install
  • gpg
  • logger
  • mkdir
  • rm
  • sha256sum
  • systemctl

An example:

I have not created a GPG keyring on my server and also not signed Gitea's GPG public key with my private key, so the check returns a warning, but better than nothing!

$ update_gitea --release-version 1.12.5
<13>Oct  2 13:05:42 update gitea[18086]: /usr/local/sbin/update_gitea: executed
The release version '1.12.5' is accessable via 'https://github.com/go-gitea/gitea/releases/tag/v1.12.5'. Starting download...

10/02 13:05:42 [NOTICE] Downloading 3 item(s)

10/02 13:05:42 [WARN] aria2c had to connect to the other side using an unknown TLS protocol. The integrity and confidentiality of the connection might be compromised.
Peer: github.com (140.82.121.4:443)

10/02 13:05:42 [WARN] aria2c had to connect to the other side using an unknown TLS protocol. The integrity and confidentiality of the connection might be compromised.
Peer: github.com (140.82.121.4:443)

10/02 13:05:42 [WARN] aria2c had to connect to the other side using an unknown TLS protocol. The integrity and confidentiality of the connection might be compromised.
Peer: github.com (140.82.121.4:443)

10/02 13:05:42 [NOTICE] CUID#9 - Redirecting to https://github-production-release-asset-2e65be.s3.amazonaws.com/72495579/4b060c80-0404-11eb-81f6-0c942f10a257?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20201002
%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201002T130542Z&X-Amz-Expires=300&X-Amz-Signature=0ca95a713bd2a31e5e03e8a0e347e90f6df181a7b1fa6a7b5365879915ca2653&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=72495579&response-content-
disposition=attachment%3B%20filename%3Dgitea-1.12.5-linux-amd64.sha256&response-content-type=application%2Foctet-stream
[...]
Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
781ba3|OK  |    22KiB/s|/usr/local/share/gitea/1.12.5-linux-amd64/gitea-1.12.5-linux-amd64.asc
f9b22b|OK  |     892B/s|/usr/local/share/gitea/1.12.5-linux-amd64/gitea-1.12.5-linux-amd64.sha256
c5c618|OK  |   8.8MiB/s|/usr/local/share/gitea/1.12.5-linux-amd64/gitea-1.12.5-linux-amd64
Status Legend:
(OK):download completed.
gpg: Signature made Thu 01 Oct 2020 20:34:51 UTC
gpg:                using RSA key CC64B1DB67ABBEECAB24B6455FC346329753F4B0
gpg: Good signature from "Teabot <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7C9E 6815 2594 6888 62D6  2AF6 2D9A E806 EC15 92E2
     Subkey fingerprint: CC64 B1DB 67AB BEEC AB24  B645 5FC3 4632 9753 F4B0
gitea-1.12.5-linux-amd64: OK
You are about to install:
'/usr/local/share/gitea/1.12.5-linux-amd64/gitea-1.12.5-linux-amd64'
to
'/usr/local/sbin/gitea'
This will also restart the systemd service unit!

Is this OK? (y/N) y
● gitea.service - Gitea (Git with a cup of tea)
   Loaded: loaded (/etc/systemd/system/gitea.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-10-02 13:07:55 UTC; 17ms ago
 Main PID: 21289 (gitea)
    Tasks: 4 (limit: 4915)
   Memory: 4.0M
   CGroup: /system.slice/gitea.service
           └─21289 /usr/local/sbin/gitea web --config /etc/gitea/app.ini

Oct 02 13:07:55 gitea systemd[1]: Started Gitea (Git with a cup of tea).
Gitea was successfully updated to version '1.12.5'!

The files are downloaded to /usr/local/share/gitea/<some_version>-<some_os>-<some_arch>/. There is no cleanup routine implemented and must be done manually:

$ tree
.
├── 1.12.4-linux-amd64/
│   ├── gitea-1.12.4-linux-amd64
│   ├── gitea-1.12.4-linux-amd64.asc
│   └── gitea-1.12.4-linux-amd64.sha256
└── 1.12.5-linux-amd64/
    ├── gitea-1.12.5-linux-amd64
    ├── gitea-1.12.5-linux-amd64.asc
    └── gitea-1.12.5-linux-amd64.sha256

2 directories, 6 files

Updating the same version once again, skips the download:

$ update_gitea --release-version 1.12.5
<13>Oct  2 13:09:33 update gitea[24335]: /usr/local/sbin/update_gitea: executed
The download directory '/usr/local/share/gitea/1.12.5-linux-amd64' already exists. Installing the binary from there...
gpg: Signature made Thu 01 Oct 2020 20:34:51 UTC
gpg:                using RSA key CC64B1DB67ABBEECAB24B6455FC346329753F4B0
gpg: Good signature from "Teabot <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7C9E 6815 2594 6888 62D6  2AF6 2D9A E806 EC15 92E2
     Subkey fingerprint: CC64 B1DB 67AB BEEC AB24  B645 5FC3 4632 9753 F4B0
gitea-1.12.5-linux-amd64: OK
You are about to install:
'/usr/local/share/gitea/1.12.5-linux-amd64/gitea-1.12.5-linux-amd64'
to
'/usr/local/sbin/gitea'
This will also restart the systemd service unit!

Is this OK? (y/N)
$ update_gitea --help

update_gitea - Download and update a given Gitea version.

Usage: update_gitea <options>

OPTIONS
  -h, --help
     Display this help text.

  -r, --release-version <version>
     Download a given release version

  -v, --version
     Displays the current version of this script.

EXAMPLES:
  Download and update a given Gitea version:
     update_gitea --release-version 1.12.4

Screenshots

20201002-151726_screenshot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions