Last active 1732827231

Revision 43b51cb00b439e07e0bf47bb3abb15f3438a8da1

opengist-install.bash Raw
1#!/usr/bin/bash
2
3version=${1:-1.8.2}
4url="https://github.com/thomiceli/opengist/releases/download/v$version/opengist$version-linux-amd64.tar.gz"
5tar_file=${url##*/}
6binary="opengist$version-linux-amd64"
7
8# create user
9if ! id -u opengist; then
10 useradd -mr -d /var/lib/opengist opengist
11
12 ## create config dir
13 mkdir -p /etc/opengist
14
15 ## fix perms
16 chown -R opengist:opengist /etc/opengist
17 chmod 2770 $_
18fi
19
20# download
21curl -LO "$url"
22
23# extract binary
24tar -xavf "$tar_file" -C /usr/local/bin --strip-components=1 --transform="s@\$@1.8.2-linux-amd64@" opengist/opengist
25
26# extract config
27tar -xavf "$tar_file" -C /etc/opengist --strip-components=1 opengist/config.yml
28
29# symlink
30cd /usr/local/bin
31ln -s $binary opengist
32cd -
33
34# create systemd service
35cat << EOF > /etc/systemd/system/opengist.service
36[Unit]
37Description=opengist Server
38After=network.target
39Requires=nginx.service
40
41[Service]
42Type=simple
43User=opengist
44Group=opengist
45ExecStart=/usr/local/bin/opengist --config /etc/opengist/config.yml
46Restart=on-failure
47
48[Install]
49WantedBy=multi-user.target
50EOF
51
52# activate service
53systemctl daemon-reload
54systemctl enable --now opengist