aboutsummaryrefslogtreecommitdiffstats
path: root/bin/dev_tools/update_status.sh
blob: 243626a4642a26abbbdd8b3c82d18e6482d7396b (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
#!/bin/sh

#
# Helper routine to see if any active update commands are executing
# in addition to showing the the backgroup updater is running.
#
# Sample result:
# $ ./is_update.sh
# 18149 python3 /opt/srt/bin/common/srtool_update.py --cron-start
# Update:2019-03-16 12:29:21,bin/common/srtool_common.py --score-new-cves NEW --count=100
# Done:2019-03-16 12:29:49,bin/common/srtool_common.py --score-new-cves NEW --count=100
#
# An "Update" without a "Done" is an running tack
#

# Test if the backgroup updater is running
if [ -f .srtupdate.pid ] ; then
	pid=`cat .srtupdate.pid`
	updater=`ps -e -o pid,cmd | grep $pid | grep -v grep | grep cron`
else
	echo "No updater pid file found"
	updater=""
fi
if [ -z "$updater" ] ; then
    echo "!!! WARNING: UPDATER IS NOT RUNNING !!!"
	cat .srtupdate.task
    exit 1
else
	echo "UPDATER:$updater"
fi

# Test if their is an open update in progress
cat .srtupdate.task
is_start=`grep "^Update" .srtupdate.task | grep -v "<cron_start>"` 
is_stop=`grep "^Done" .srtupdate.task` 
if [ -z "$is_stop" ] ; then
    echo "!!! UPDATE JOB RUNNING !!!"
    exit 1
else
    echo "UPDATE PAUSED BETWEEN JOBS."
    exit 0
fi