summaryrefslogtreecommitdiff
blob: f875f8a825c09fde78de98baefad593ed07cb7ab (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
34
35
36
37
38
39
40
41
--- update-pciids.sh
+++ update-pciids.sh
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+[ "$1" = "-q" ] && quiet="true" || quiet="false"
+
 set -e
 SRC="http://pciids.sourceforge.net/v2.2/pci.ids"
 DEST=pci.ids
@@ -8,6 +8,13 @@
 PCI_COMPRESSED_IDS=
 GREP=grep
 
+# if pci.ids is read-only (because the filesystem is read-only),
+# then just skip this whole process.
+if ! touch ${DEST} >&2 >/dev/null ; then
+	${quiet} || echo "${DEST} is read-only, exiting."
+	exit 0
+fi
+
 if [ -n "$PCI_COMPRESSED_IDS" ] ; then
 	DECOMP="cat"
 	SRC="$SRC.gz"
@@ -22,8 +24,10 @@
 
 if which curl >/dev/null ; then
 	DL="curl -o $DEST.new $SRC"
+    ${quiet} && DL="$DL -s -S"
 elif which wget >/dev/null ; then
 	DL="wget -O $DEST.new $SRC"
+	${quiet} && DL="$DL -q"
 elif which lynx >/dev/null ; then
 	DL="eval lynx -source $SRC >$DEST.new"
 else
@@ -59,4 +66,4 @@
 mv $DEST.neww $DEST
 rm $DEST.new
 
-echo "Done."
+${quiet} || echo "Done."