Skip to content

Commit 6430993

Browse files
committed
Fix version detection
1 parent 6f20de4 commit 6430993

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

scripts/update_p4prom.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ else
150150
fi
151151

152152
p4prom_config_file="$p4prom_config_dir/p4prometheus.yaml"
153+
p4metrics_config_file="$p4prom_config_dir/p4metrics.yaml"
153154

154155
download_and_untar () {
155156
fname=$1
@@ -168,7 +169,7 @@ update_node_exporter () {
168169
msg "Created user $userid"
169170
fi
170171

171-
curr_ver=$(node_exporter --version | grep ' version ' | awk '{print $3}')
172+
curr_ver=$(node_exporter --version 2>&1 | grep ' version ' | awk '{print $3}')
172173
if [[ "$curr_ver" == "$VER_NODE_EXPORTER" ]]; then
173174
msg "Current version $curr_ver of node_exporter is up-to-date"
174175
return
@@ -228,10 +229,10 @@ EOF
228229
}
229230

230231
update_p4prometheus () {
231-
service_name="p4promethes"
232+
service_name="p4prometheus"
232233
progname="p4prometheus"
233234
service_file="/etc/systemd/system/${service_name}.service"
234-
curr_ver=$($progname --version | grep "$progname, version " | awk '{print $3}')
235+
curr_ver=$($progname --version 2>&1 | grep "$progname, version " | awk '{print $3}')
235236
if [[ "$curr_ver" == "v$VER_P4PROMETHEUS" ]]; then
236237
msg "Current version $curr_ver of $progname is up-to-date"
237238
return
@@ -284,14 +285,15 @@ update_p4metrics () {
284285
service_name="p4metrics"
285286
progname="p4metrics"
286287
service_file="/etc/systemd/system/${service_name}.service"
287-
curr_ver=$($progname --version | grep "$progname, version " | awk '{print $3}')
288+
curr_ver=$($progname --version 2>&1 | grep "$progname, version " | awk '{print $3}')
288289
if [[ "$curr_ver" == "v$VER_P4PROMETHEUS" ]]; then
289290
msg "Current version $curr_ver of $progname is up-to-date"
290291
return
291292
fi
292293

293294
systemctl stop $service_name
294295

296+
fname="${progname}.linux-${arch}.gz"
295297
url="https://github.com/perforce/p4prometheus/releases/download/v$PVER/$fname"
296298
msg "downloading and extracting $url"
297299
wget -q "$url"

0 commit comments

Comments
 (0)