/
openmediavault-update-smart-drivedb
executable file
·53 lines (45 loc) · 1.86 KB
/
openmediavault-update-smart-drivedb
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
#!/bin/sh -l
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2017 Volker Theile
#
# OpenMediaVault 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 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
# Documentation/Howto:
# http://www.thomas-krenn.com/de/wiki/Smartmontools_Drive_Database_aktualisieren
set -e
. /usr/share/openmediavault/scripts/helper-functions
tmpscript=$(mktemp)
cleanup() {
rm -f ${tmpscript}
exit
}
trap cleanup 0 1 2 5 15
# Does the script exist? If not, then exit immediatelly. In this case the
# Debian smartmontools package is not installed.
which update-smart-drivedb >/dev/null || exit 0
# Update the drive database.
filepath=$(which update-smart-drivedb)
version=$(sed -n 's/^VERSION="\(.*\)"$/\1/p' ${filepath})
# Note, the script shipped with the Debian Jessie smartmontools package
# contains a wrong URL. Because of that this must be modified to get the
# script working. To do not modify the original script, which is under
# APT control, we simply create a copy of the script, modify the URL and
# finally execute it.
cp -p ${filepath} ${tmpscript}
sed -i "/^SRCEXPR=/{s#http://*#https://#}" ${tmpscript}
omv_syslog_info "Updating smartmontools ${version} drive database ..."
eval ${tmpscript} >/dev/null