| Server IP : 216.92.14.13 / Your IP : 216.73.216.171 Web Server : Apache System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : rmlac2fmr ( 1040637) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /sbin/ |
Upload File : |
#! /bin/sh
#
# smartmontools drive database update script
#
# Copyright (C) 2010-13 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 3814 2013-06-04 19:38:25Z chrfranke $
#
set -e
# Set by config.status
PACKAGE="smartmontools"
VERSION="6.2"
prefix="/usr"
exec_prefix="${prefix}"
sbindir="${exec_prefix}/sbin"
datarootdir="${prefix}/share"
datadir="${datarootdir}"
drivedbdir="/var/lib/smartmontools/drivedb"
# Download tools
os_dltools="curl wget lynx"
# drivedb.h update branch
BRANCH="RELEASE_6_2_DRIVEDB"
# Default drivedb location
DEST="$drivedbdir/drivedb.h"
# Smartctl used for syntax check
SMARTCTL="$sbindir/smartctl"
# Download URL for sourceforge code browser
SRCEXPR='http://sourceforge.net/p/smartmontools/code/HEAD/tree/$location/smartmontools/drivedb.h?format=raw'
# 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 '<title>.*Error has Occurred' "$DEST.new" >/dev/null; then
errmsg="download from $location failed (SF code browser 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
rm -f "$DEST.lastcheck"
if [ -f "$DEST" ]; then
if cmp "$DEST" "$DEST.new" >/dev/null 2>/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"