Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
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
Nurlan
eepm
Commits
99f4e7cb
Commit
99f4e7cb
authored
Jan 27, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite eget
parent
28397e64
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
19 deletions
+43
-19
tools-eget
bin/tools-eget
+43
-19
No files found.
bin/tools-eget
View file @
99f4e7cb
...
...
@@ -20,37 +20,61 @@
# 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
# TODO:
# -P support
# If ftp protocol or have no asterisk, jus download
# TODO: use has()
if
echo
"
$1
"
|
grep
-q
"
\(
^ftp://
\|
[^*]
$\
)"
;
then
$WGET
$1
&&
exit
0
$WGET
"
$1
"
exit
fi
URL
=
$(
echo
$1
|
grep
/
$
||
dirname
$1
)
MASK
=
$(
basename
$1
)
MYTMPDIR
=
"
$(
mktemp
-d
)
"
DIRALLFILES
=
"
$MYTMPDIR
/files/"
get_index
(){
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
line
;
do
touch
$DIRALLFILES
/
$(
basename
"
$line
"
)
done
}
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
||
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