-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenqueue-data-from-file
More file actions
executable file
·88 lines (74 loc) · 1.93 KB
/
Copy pathenqueue-data-from-file
File metadata and controls
executable file
·88 lines (74 loc) · 1.93 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
if (( $# < 2 )); then
echo "Usage: $0 <file location of file, read line by line, line termination by newline character>"
exit 1
fi
force_download=false
create_from_template=false
# parse commandline options
getopt --test > "/dev/null" && true
if (( $? != 4 )); then
echo>&2 "ERROR: 'getopt --test' failed in this environment!"
exit 1
fi
long_options="force,create-from-template"
short_options=""
parsed_options=$(getopt --options="$short_options" --longoptions="$long_options" --name "$0" -- "$@") || exit 2
eval set -- "$parsed_options"
while true; do
case "$1" in
--force)
force_download=true
shift ||__expression_may_fail
;;
--create-from-template)
create_from_template=true
shift ||__expression_may_fail
;;
--)
shift
break
;;
*)
echo>&2 "ERROR: Programming error!"
exit 3
;;
esac
done
if [[ "$force_download" == "true" ]]; then
force_download=true
else
force_download=false
fi
if [[ "$create_from_template" == "true" ]]; then
create_from_template=true
else
create_from_template=false
fi
queue_name="$1"
shift ||__expression_may_fail
list_file_name="$1"
shift ||__expression_may_fail
download_index="$1"
shift ||__expression_may_fail
current_date="$(date +%Y%m%d%H%M%S)"
queue_full_file_path=""
if $create_from_template; then #@fixme
queue_full_file_path="$__script_path/var/template-instances/queue-$queue_name-date-$current_date.queue"
cp -- "$__script_path/templates/$queue_name.template" "$queue_full_file_path"
queue_full_file_path=":$queue_full_file_path"
fi
while read -r url; do
if [[ "$url" == "" ]]; then
continue
fi
if ! $force_download; then
enqueue-data "${queue_name}$queue_full_file_path" "$url"
else
enqueue-data "${queue_name}$queue_full_file_path" "$url" "--download-archive=$download_index"
fi
done < "$list_file_name"
__queue_identifier="${queue_name}$queue_full_file_path"
export __queue_identifier
__download_index="$download_index"
export __download_index