summaryrefslogtreecommitdiffstats
path: root/init.sh
blob: 76dfeeaf9279fa880bde32d804007baa9210b27a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

year=2024

if [ ! $# -eq 1 ]
then
    echo "Usage: $0 <d>"
    exit 1
fi

day=$1
cookiefile=${3:-'./cookie'}
dir=$(printf "day%02d" $day)

echo "Initializing directory $dir/"
rsync -av --ignore-existing skel/ ${dir}/

advent_session=$(cat $cookiefile 2> /dev/null) &&
    echo "Downloading input ..." &&
    curl "https://adventofcode.com/$year/day/$day/input" \
         -H "Cookie: session=$advent_session" > $dir/input.txt