1 |
# |
2 |
# This program is free software; you can redistribute it and/or modify |
3 |
# it under the terms of the GNU General Public License as published by |
4 |
# the Free Software Foundation; either version 2 of the License, or |
5 |
# (at your option) any later version. |
6 |
# |
7 |
# This program is distributed in the hope that it will be useful, |
8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 |
# GNU General Public License for more details. |
11 |
# |
12 |
# You should have received a copy of the GNU General Public License |
13 |
# along with this program; if not, write to the Free Software |
14 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 |
|
16 |
set -e |
17 |
|
18 |
if [ ! -d "$TARBALLDIR" ]; then |
19 |
echo "Error: \"$TARBALLDIR\" does not exist." >&2 |
20 |
exit 1 |
21 |
fi |
22 |
|
23 |
if [ $(id -u) -ne 0 ]; then |
24 |
echo "Error: You must run this script as root." >&2 |
25 |
exit 1 |
26 |
fi |
27 |
|
28 |
LOCALFILE= |
29 |
NO_CHECK= |
30 |
while [ -n "$1" ]; do |
31 |
if [ "$1" = "--force" ]; then |
32 |
NO_CHECK=1 |
33 |
else |
34 |
LOCALFILE="$1" |
35 |
fi |
36 |
done |
37 |
|
38 |
checkmd5sum() { |
39 |
[ -e "$1" ] || return 1 |
40 |
FILEMD5="$(md5sum $1 | cut -d" " -f1)" |
41 |
[ -n "$FILEMD5" ] || return 1 |
42 |
MD5NUM=1 |
43 |
eval MD5SUM="\$MD5SUM$MD5NUM" |
44 |
while [ "$MD5SUM" ]; do |
45 |
[ "$MD5SUM" = "$FILEMD5" ] && return 0 |
46 |
MD5NUM=$((MD5NUM+1)) |
47 |
eval MD5SUM="\$MD5SUM$MD5NUM" |
48 |
done |
49 |
return 1 |
50 |
} |
51 |
|
52 |
|
53 |
if [ -n "$LOCALFILE" ]; then |
54 |
if [ ! -e "$LOCALFILE" ]; then |
55 |
echo "Error: Specified file \"$LOCALFILE\" does not exist." >&2 |
56 |
exit 1 |
57 |
fi |
58 |
if [ -z "$NO_CHECK" ] && ! checkmd5sum "$LOCALFILE" &>/dev/null; then |
59 |
echo "Error: Specified file fails md5 hash check." >&2 |
60 |
exit 1 |
61 |
fi |
62 |
|
63 |
cp "$LOCALFILE" "$TARBALLDIR/$FILENAME" |
64 |
|
65 |
else |
66 |
URLNUM=1 |
67 |
FAILURE=false |
68 |
echo "Note that by downloading the Adobe Flash Player you indicate your acceptance of" |
69 |
echo "the EULA, available from http://www.adobe.com/products/eulas/players/flash/" |
70 |
while ! checkmd5sum "$TARBALLDIR/$FILENAME"; do |
71 |
eval URL="\$URL$URLNUM" |
72 |
if [ -z "$URL" ]; then |
73 |
FAILURE=true |
74 |
break |
75 |
fi |
76 |
URLNUM=$((URLNUM+1)) |
77 |
echo "Downloading from $URL:" |
78 |
curl --connect-timeout 20 -m 10800 -L "$URL" > "$TARBALLDIR/$FILENAME" |
79 |
done |
80 |
if $FAILURE && [ -z "$NO_CHECK" ]; then |
81 |
echo "Error: Unable to download Flash Player. This is likely due to this package" >&2 |
82 |
echo " being too old. Please contact plf-discuss@zarb.org or" >&2 |
83 |
echo " report a bug in the PLF bugzilla at http://plf.zarb.org/bugzilla/" >&2 |
84 |
echo " so that the package will be updated. Thank you." >&2 |
85 |
echo "" >&2 |
86 |
echo " In the meantime, you can download Flash Player manually from" >&2 |
87 |
echo " http://get.adobe.com/flashplayer/" >&2 |
88 |
exit 1 |
89 |
fi |
90 |
fi |
91 |
|
92 |
FILENUM=1 |
93 |
FILE_SRC="$FILE1_SRC" |
94 |
FILE_DST="$FILE1_DST" |
95 |
while [ -n "$FILE_SRC" ]; do |
96 |
if [ "$FILETYPE" = "rpm" ]; then |
97 |
rpm2cpio "$TARBALLDIR/$FILENAME" | cpio -i --to-stdout --quiet "$FILE_SRC" > "$FILE_DST" |
98 |
else |
99 |
tar -xzOf "$TARBALLDIR/$FILENAME" "$FILE_SRC" > "$FILE_DST" |
100 |
fi |
101 |
FILENUM=$((FILENUM+1)) |
102 |
eval FILE_SRC="\$FILE${FILENUM}_SRC" |
103 |
eval FILE_DST="\$FILE${FILENUM}_DST" |
104 |
done |
105 |
|
106 |
echo "Installation successful." |