Skip to content

Commit 08ba5a2

Browse files
authored
0.20171225
1 parent a15b1e1 commit 08ba5a2

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

usr/bin/war-wget

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function usage()
1313
echo
1414
echo "USAGE: $0 [options] name url/to/html/page"
1515
echo "options:"
16+
echo " -c clean LIST (sample 'js,php,eot,wott,ttf', default = '')"
17+
echo " -r reject LIST (sample 'js,php,eot,wott,ttf', default = '')"
1618
echo " -h help."
1719
echo
1820
exit 1
@@ -22,9 +24,13 @@ then
2224
usage
2325
fi
2426

25-
while getopts ":h" opt
27+
while getopts ":c:r:h" opt
2628
do
2729
case $opt in
30+
c) cleanlist="$OPTARG"
31+
;;
32+
r) rejectlist="$OPTARG"
33+
;;
2834
h) usage
2935
;;
3036
*) echo "Unknown option -$OPTARG"
@@ -49,8 +55,14 @@ then
4955
fi
5056

5157
rm -rf "$tmpdir"
52-
mkdir -p "$tmpdir"
53-
wget -c -t0 -p -k -E -P "$tmpdir/$htmldir" "$htmlurl"
58+
mkdir -p "$tmpdir/$htmldir"
59+
60+
if [ -z "$rejectlist" ]
61+
then
62+
wget -c -t0 -p -k -E -P "$tmpdir/$htmldir" "$htmlurl"
63+
else
64+
wget -c -t0 -p -k -E -R "$rejectlist" -P "$tmpdir/$htmldir" "$htmlurl"
65+
fi
5466

5567
function index_gen()
5668
{
@@ -86,5 +98,11 @@ then
8698
index_gen "$tmpdir/$htmldir"
8799
fi
88100

101+
cleanopt=$(echo "$cleanlist" | sed "s/\,/|/g")
102+
if [ ! -z "$cleanopt" ]
103+
then
104+
find "$tmpdir" -type f -regextype posix-egrep -regex '.*\.('$cleanopt')$' | xargs rm -v
105+
find "$tmpdir" -type f -regextype posix-egrep -regex '.*\.('$cleanopt')\?.*$' | xargs rm -v
106+
fi
89107
tar cz -C "$tmpdir/$htmldir" -f "$warfile" .
90108
rm -rf "$tmpdir"

0 commit comments

Comments
 (0)