gdritter repos lektor / 744056a
Added simple bash scripts Getty Ritter 9 years ago
2 changed file(s) with 76 addition(s) and 0 deletion(s). Collapse all Expand all
1 #/bin/bash -e
2
3 cd $LEKTORDIR
4
5 for FEED in $(ls new)
6 do
7 mkdir -p cur/$FEED
8
9 # print feed header
10 echo "In feed $(cat src/$FEED/name):"
11 echo
12
13 for ENTRY in $(ls new/$FEED)
14 do
15 # print entry
16 echo "$(cat new/$FEED/$ENTRY/title)"
17 cat new/$FEED/$ENTRY/content | head -n 4
18 echo
19
20 # move entry to `cur`
21 mv new/$FEED/$ENTRY cur/$FEED/$ENTRY
22 done
23 done
1 #!/bin/bash -e
2
3 cd $LEKTORDIR
4
5 # the feed information
6 ID='tag:example.com:timekeeper'
7 HASH=$(printf $ID | sha1sum | awk '{ print $1; }' )
8
9 # other metadata
10 HOST=$(hostname)
11 MAX=10
12
13 # create the feed
14 mkdir -p src/$HASH
15 echo $ID >src/$HASH/id
16 echo Timekeeper >src/$HASH/name
17
18 mkdir -p "tmp/$HASH"
19 mkdir -p "new/$HASH"
20
21 # create entries every hour
22 while true; do
23 TIME=$(date '+%s')
24 ENTRY="$HASH/$TIME.$$.$HOST"
25
26 # if the file exists, wait two seconds and try again
27 RETRY=0
28 while [ -e $ENTRY ]
29 do
30 # if we've waited more than $MAX times, then
31 # give up
32 if [ $RETRY -gt $MAX ]; then
33 exit 1
34 fi
35 sleep 2
36 RETRY=$(expr $RETRY + 1)
37 done
38
39 # create the entry
40 mkdir -p tmp/$ENTRY
41
42 # create entry values
43 echo 'Current Time' >tmp/$ENTRY/title
44 echo $TIME >tmp/$ENTRY/content
45 echo "tag:example.com:timekeeper#$TIME" >tmp/$ENTRY/id
46 ln -s $LEKTORDIR/src/$HASH tmp/$ENTRY/feed
47
48 # move the entry to the new location
49 mv tmp/$ENTRY new/$ENTRY
50
51 # wait for half an hour and do it again
52 sleep 3600
53 done