summaryrefslogtreecommitdiff
blob: 0a8c665b8794e0dc414da69c98e347b5b05faa5b (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
#!/bin/bash

update_db() {
	local src=$1
	local dst=$2

	while read line ; do
		if [[ -z $(echo "${line}" | sed -re 's/(^#.*|^\w*$)//') ]]; then
			echo "${line}" >> "${dst}"
		fi

		id=$(echo "${line}" | grep -o '"[^"]*"')

		grep "${id}" "${dst}" 2>&1 >/dev/null || echo "${line}" >> "${dst}"
	done < "${src}"
}

die() {
	echo "$*"
	exit 1
}

cd /usr/share/hddtemp
wget http://download.savannah.nongnu.org/releases/hddtemp/hddtemp.db -O hddtemp.db -q || die "Failed to download new hddtemp.db file"

# Try to get the Gentoo HDD DB from WebCVS.  If that fails, just use the Gentoo HDD database
# that was installed by the ebuild.
if wget http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-admin/hddtemp/files/hddgentoo.db -O hddtmp.db -q; then
	mv -f hddtmp.db hddgentoo.db
fi

update_db "hddgentoo.db" "hddtemp.db"