summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: cf40606d2f07dc6cb1a01969011b04b51c9d9917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Maintainer: taotieren <admin@taotieren.com>

pkgbase=serverstatus-git
pkgname=(serverstatus-git
    serverstatus-clients-linux-git
    serverstatus-clients-psutil-git
    serverstatus-server-git)
pkgver=1.1.1.r2.g4a9f5ad
pkgrel=1
groups=()
pkgdesc="云探针、多服务器探针、云监控、多服务器云监控"
arch=(any)
url="https://github.com/cppla/ServerStatus"
license=('MIT')
provides=(${pkgbase%-git})
conflicts=(${pkgbase%-git})
depends=(glibc
    openssl
    systemd
    python)
makedepends=(git)
optdepends=(python-psutil)
source=("${pkgbase}::git+${url}.git")
sha256sums=('SKIP')

pkgver() {
    cd "${srcdir}/${pkgbase}"
    ( set -o pipefail
        git describe --long --tag --abbrev=7 2>/dev/null | sed 's/^v//g;s/\([^-]*-g\)/r\1/;s/-/./g' ||
        printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
    )
}

prepare()
{
    git -C "${srcdir}/${pkgbase}" clean -dfx
}

build() {
    cd "${srcdir}/${pkgbase}"
    make -C server PREFIX=/usr
}

package_serverstatus-git() {
    depends=(
    serverstatus-clients-linux-git
    serverstatus-clients-psutil-git
    serverstatus-server-git)
}

package_serverstatus-clients-linux-git() {
    pkgdesc+="-- Linux 客户端"
    depends=(python
        systemd)
    arch=(any)
    provides=(${pkgname%-git})
    conflicts=(${pkgname%-git})

    install -Dm0755 "${srcdir}/${pkgbase}/clients/client-linux.py" -t ${pkgdir}/usr/share/${pkgbase%-git}/clients
    install -Dm0644 /dev/stdin ${pkgdir}/usr/lib/systemd/system/${pkgname%-git}.service << EOF
[Unit]
Description=ServerStatus-Client
After=network.target

[Service]
ExecStart=/usr/bin/python /usr/share/serverstatus/clients/client-linux.py
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
}
package_serverstatus-clients-psutil-git() {
    pkgdesc+="-- Linux psutil 客户端"
    depends=(python
        python-psutil
        systemd)
    arch=(any)
    provides=(${pkgname%-git})
    conflicts=(${pkgname%-git})
    install -Dm0755 "${srcdir}/${pkgbase}/clients/client-psutil.py" -t ${pkgdir}/usr/share/${pkgbase%-git}/clients
    install -Dm0644 /dev/stdin ${pkgdir}/usr/lib/systemd/system/${pkgname%-git}.service << EOF
[Unit]
Description=ServerStatus-Client psutil
After=network.target

[Service]
ExecStart=/usr/bin/python /usr/share/serverstatus/clients/client-psutil.py
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
}

package_serverstatus-server-git() {
    pkgdesc+="-- 服务端"
    depends=(
        glibc
        openssl
        systemd)
    arch=(x86_64
        aarch64
        riscv64)
    provides=(${pkgname%-git})
    conflicts=(${pkgname%-git})

    cd "${srcdir}/${pkgbase}"

    install -Dm0755 "${srcdir}/${pkgbase}/server/sergate" -t ${pkgdir}/usr/bin
    install -Dm0755 "${srcdir}/${pkgbase}/server/config.json" -t ${pkgdir}/usr/share/${pkgbase%-git}/server
    cp -rva "${srcdir}/${pkgbase}"/web ${pkgdir}/usr/share/${pkgbase%-git}
    cp -rva "${srcdir}/${pkgbase}"/plugin ${pkgdir}/usr/share/${pkgbase%-git}
    install -Dm0644 /dev/stdin ${pkgdir}/usr/lib/systemd/system/${pkgname%-git}.service << EOF
[Unit]
Description=ServerStatus-Server
After=network.target

[Service]
ExecStart=sergate --config=/usr/share/serverstatus/server/config.json --web-dir=/usr/share/serverstatus/web
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF
}