-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.sh
More file actions
35 lines (30 loc) · 708 Bytes
/
fetch.sh
File metadata and controls
35 lines (30 loc) · 708 Bytes
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
yes=
if [ "$1" = "--yes" ]; then
yes=1
shift
fi
day=$1
if [ $# -eq 0 ]; then
day=$(TZ=UTC date +%-d)
echo "OK, we have to guess the day, let's guess $day???"
else
shift
if [ "$1" = "--yes" ]; then
yes=1
shift
fi
fi
daypad=$(seq -f %02g $day $day)
if [ "$yes" = "1" ]; then
for f in $(ls secrets/*); do
target=alt-input/$daypad$(basename $f)
if [ -f $target ]; then
echo "THE INPUT ALREADY EXISTS!!!"
else
curl --cookie session=$(cat $f) --user-agent 'https://github.com/petertseng/adventofcode-hs-2022/blob/master/fetch.sh' -o $target https://adventofcode.com/2022/day/$day/input
sleep 1
fi
done
else
curl -o input$day http://example.com
fi