-
Notifications
You must be signed in to change notification settings - Fork 2
/
watch-fedora-packages.sh
executable file
·66 lines (57 loc) · 1.94 KB
/
watch-fedora-packages.sh
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
#!/bin/bash
# configuration
LISTOFPKGS="audacious audacity chromium kernel libmicrohttpd libva libcec platform gstreamer gstreamer-plugins-base gstreamer-plugins-good gstreamer-plugins-bad-free qmmp libbluray"
LISTOFDISTS="f28-updates f28-updates-testing f27-updates f27-updates-testing"
# basics
THISSCRIPTSNAME=$(basename ${0})
LOCKFILE="${HOME}/.${THISSCRIPTSNAME}.lock"
DATADIR="${HOME}/.${THISSCRIPTSNAME}"
# koji alive?
if ! koji list-tags &> /dev/null ; then
exit 1
fi
# Are we running already?
if ! lockfile -r 1 "${LOCKFILE}" ; then
if ps --no-heading "$(cat "${LOCKFILE}")" &> /dev/null
then
echo "Existing lockfile and process seems to be still around. Aborting." >&2
exit 1
else
# no process with that pid
rm -f "${LOCKFILE}"
lockfile -r 1 "${LOCKFILE}"
fi
fi
chmod +w "${LOCKFILE}"
echo $$ > "${LOCKFILE}"
# does out setting dir exist
if [[ ! -d ${DATADIR} ]]; then
if ! mkdir -p "${DATADIR}" ; then
echo "Could not create ${DATADIR}. Aborting." >&2
exit 1
fi
fi
# go
i=0
for tag in ${LISTOFDISTS}; do
if ! koji latest-pkg --quiet ${tag} ${LISTOFPKGS} > "${DATADIR}/${tag}.new"; then
echo "koji failed when running 'koji latest-pkg --quiet ${tag} ${LISTOFPKGS}'"
continue
fi
if [[ -e "${DATADIR}/${tag}" ]]; then
if ! (cd ${DATADIR}; diff -u "${tag}" "${tag}.new"); then
echo $'\n'
fi
fi
mv -f "${DATADIR}/${tag}.new" "${DATADIR}/${tag}"
done
# cleanup
rm -f "${LOCKFILE}"
# reminder
if [[ ${REMINDMECHANCE} > 0 ]] && (( $((${RANDOM}%${REMINDMECHANCE})) == 0 ))
then
echo "Hi,"$'\n'$'\n'"this is ${0} on ${HOSTNAME} running for ${USERNAME} aka ${USER}. I'm a
script called from a cron job regularly and now and then use the opportunity to remind you that I'm
still here and working hard for you. Thanks for reading this and have a great day. "$'\n'$'\n'"Yours
sincerely,"$'\n'$'\t'"$(basename ${0})" | fmt -w 76
fi