-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathppg-functions
More file actions
executable file
·37 lines (33 loc) · 1 KB
/
ppg-functions
File metadata and controls
executable file
·37 lines (33 loc) · 1 KB
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
# functions
hostnametoint() {
# read the md5 as a sequence of unsigned ints
ints=$( echo -n $(xhostname) | openssl dgst -md5 -binary | od -d -N32 -w32 | head -n1 | cut -f2- -d' ')
sum=0
for val in $ints; do
sum=$(( $sum + $val ))
done
echo $sum
}
xhostname() {
if [ -x /usr/bin/facter ]; then
hostname=$(/usr/bin/facter fqdn)
fi
if [ -z "$hostname" ]; then
hostname=$(/bin/hostname --fqdn)
fi
echo "${hostname}"
}
ppg_lastgood_cleanup() {
# this cleanup is needed in the ppg v0.20->v0.21
# upgrade path. overhead is trivially minimal so
# we can carry it for a while...
#
# verify against the "full" name with the doubled-up
# refs/heads; that's the want we need to cleanup...
if git rev-parse --verify --quiet refs/heads/refs/heads/ppg/lastgood 1>/dev/null ; then
# use branch mv/rename to preserve reflog
# oddly enough, the rename fails when using the "full"
# refname, so we use the short refname instead
git branch -m refs/heads/ppg/lastgood ppg/lastgood
fi
}