Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
eget
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
eget
Commits
1ee5b413
Commit
1ee5b413
authored
Nov 10, 2017
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update eget from eepm project
parent
4b7f3a2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
22 deletions
+57
-22
eget
eget
+57
-22
No files found.
eget
View file @
1ee5b413
...
...
@@ -3,8 +3,9 @@
# Example use:
# eget ftp://ftp.altlinux.ru/pub/security/ssl/*
#
# Copyright (C) 2014-2014 Etersoft
# Copyright (C) 2014-2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2014-2014, 2016 Etersoft
# Copyright (C) 2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016-2017 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -20,37 +21,71 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
WGET
=
"wget"
WGET
=
"wget -q"
if
[
"
$1
"
=
"-q"
]
;
then
WGET
=
"wget -q"
shift
fi
if
echo
"
$1
"
|
grep
-q
"
\(
^ftp://
\|
[^*]
$\
)"
;
then
$WGET
$1
&&
exit
0
# TODO:
# download to this file
WGET_OPTION_TARGET
=
if
[
"
$1
"
=
"-O"
]
;
then
TARGETFILE
=
"
$2
"
WGET_OPTION_TARGET
=
"-O
$2
"
shift
2
fi
URL
=
$(
echo
$1
|
grep
/
$
||
dirname
$1
)
MASK
=
$(
basename
$1
)
MYTMPDIR
=
"
$(
mktemp
-d
)
"
DIRALLFILES
=
"
$MYTMPDIR
/files/"
get_index
(){
# TODO:
# -P support
# If ftp protocol or have no asterisk, just download
# TODO: use has()
if
echo
"
$1
"
|
grep
-q
"^ftp://"
||
echo
"
$1
"
|
grep
-qv
"[*?]"
;
then
$WGET
$WGET_OPTION_TARGET
"
$1
"
exit
fi
echo
"Fall to http workaround"
URL
=
$(
echo
"
$1
"
|
grep
"/$"
||
dirname
"
$1
"
)
# mask allowed only in last part of path
MASK
=
$(
basename
"
$1
"
)
get_index
()
{
MYTMPDIR
=
"
$(
mktemp
-d
)
"
INDEX
=
$MYTMPDIR
/index
$WGET
$URL
-O
$INDEX
}
save_temp_files
(){
mkdir
-p
$DIRALLFILES
ALLFILES
=
"
$MYTMPDIR
/allfiles"
cat
$INDEX
|
grep
-o
-E
'href="([^\*/"#]+)"'
|
cut
-d
'"'
-f2
>
$ALLFILES
while
read
line
;
do
touch
$DIRALLFILES
/
$line
done
<
$ALLFILES
print_files
()
{
cat
$INDEX
|
grep
-o
-E
'href="([^\*/"#]+)"'
|
cut
-d
'"'
-f2
}
create_fake_files
()
{
DIRALLFILES
=
"
$MYTMPDIR
/files/"
mkdir
-p
"
$DIRALLFILES
"
print_files |
while
read
-r
line
;
do
touch
$DIRALLFILES
/
$(
basename
"
$line
"
)
done
rm
-f
$INDEX
}
sort_files
(){
download_files
()
{
ERROR
=
0
for
line
in
$DIRALLFILES
/
$MASK
;
do
$WGET
$URL
/
`
basename
"
$line
"
`
-P
$CURRENTDIR
/
$WGET
$URL
/
$(
basename
"
$line
"
)
||
ERROR
=
1
done
return
$ERROR
}
get_index
save_temp_files
sort_files
get_index
||
{
rm
-rf
"
$MYTMPDIR
"
;
exit
;
}
create_fake_files
download_files
||
echo
"There was some download errors"
>
&2
rm
-rf
"
$MYTMPDIR
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment