/usr/sbin/update-smart-drivedb is in smartmontools 5.41+svn3365-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | #! /bin/sh
#
# smartmontools drive database update script
#
# Copyright (C) 2010-11 Christian Franke <smartmontools-support@lists.sourceforge.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# You should have received a copy of the GNU General Public License
# (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
#
# $Id: update-smart-drivedb.in 3294 2011-03-16 21:36:58Z chrfranke $
#
set -e
# Set by config.status
PACKAGE="smartmontools"
VERSION="5.41"
prefix="/usr"
exec_prefix="${prefix}"
sbindir="${exec_prefix}/sbin"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
drivedbdir="${datadir}/${PACKAGE}"
# Download tools
os_dltools="curl wget lynx"
# drivedb.h update branch
BRANCH="RELEASE_5_41_DRIVEDB"
# Default drivedb location
DEST="$drivedbdir/drivedb.h"
# Smartctl used for syntax check
SMARTCTL="$sbindir/smartctl"
# Trac repository browser (does not return HTTP 404 errors)
#SRCEXPR='http://sourceforge.net/apps/trac/smartmontools/export/HEAD/$location/smartmontools/drivedb.h'
# ViewVC repository browser
SRCEXPR='http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/$location/smartmontools/drivedb.h?revision=HEAD'
# Parse options
q="-q "
case "$1" in
-v) q=; shift ;;
esac
case "$*" in
-*|*\ *)
cat <<EOF
smartmontools $VERSION drive database update script
Usage: $0 [-v] [DESTFILE]
-v verbose output
Updates $DEST
or DESTFILE from smartmontools SVN repository.
Tries to download first from branch $BRANCH
and then from trunk.
EOF
exit 1
;;
"") ;;
*) DEST="$1" ;;
esac
# Abort if 'which' is not available
which which >/dev/null || exit 1
# Find download tool
DOWNLOAD=
for t in $os_dltools; do
if which $t >/dev/null 2>/dev/null; then
case $t in
curl) DOWNLOAD="curl ${q:+-s }"'-f -o "$DEST.new" "$SRC"' ;;
lynx) DOWNLOAD='lynx -source "$SRC" >"$DEST.new"' ;;
wget) DOWNLOAD="wget $q"'-O "$DEST.new" "$SRC"' ;;
fetch) DOWNLOAD='fetch -o "$DEST.new" "$SRC"' ;; # FreeBSD
ftp) DOWNLOAD='ftp -o "$DEST.new" "$SRC"' ;; # OpenBSD
esac
break
fi
done
if [ -z "$DOWNLOAD" ]; then
echo "$0: found none of: $os_dltools" >&2; exit 1
fi
# Try possible branch first, then trunk
for location in "branches/$BRANCH" "trunk"; do
test -n "$q" || echo "Download from $location"
errmsg=
rm -f "$DEST.new"
SRC="`eval echo "$SRCEXPR"`"
if (eval $DOWNLOAD); then :; else
errmsg="download from $location failed (HTTP error)"
continue
fi
if grep -i 'ViewVC Exception' "$DEST.new" >/dev/null; then
errmsg="download from $location failed (ViewVC error)"
continue
fi
break
done
if [ -n "$errmsg" ]; then
rm -f "$DEST.new"
echo "$0: $errmsg" >&2
exit 1
fi
# Adjust timestamp and permissions
touch "$DEST.new"
chmod 0644 "$DEST.new"
# Check syntax
rm -f "$DEST.error"
if $SMARTCTL -B "$DEST.new" -P showall >/dev/null; then :; else
mv "$DEST.new" "$DEST.error"
echo "$DEST.error: rejected by $SMARTCTL, probably no longer compatible" >&2
exit 1
fi
# Keep old file if identical, ignore differences in Id string
rm -f "$DEST.lastcheck"
if [ -f "$DEST" ]; then
if cat "$DEST" | sed 's|\$''Id''[^$]*\$|$''Id''$|' | cmp - "$DEST.new" >/dev/null; then
rm -f "$DEST.new"
touch "$DEST.lastcheck"
echo "$DEST is already up to date"
exit 0
fi
mv "$DEST" "$DEST.old"
fi
mv "$DEST.new" "$DEST"
echo "$DEST updated from $location"
|