add some logic to reservation remove
Signed-off-by: Nico Schottelius <nico@ikn.schottelius.org>
This commit is contained in:
parent
c065f8ee82
commit
92cbfa951b
1 changed files with 44 additions and 3 deletions
|
@ -1,17 +1,58 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius, 2010
|
||||
# Copying: GPLv3
|
||||
#
|
||||
# Add the following line to your .netrc:
|
||||
# machine wiki.systems.ethz.ch login YOURLOGNIN password YOURPASSWORD
|
||||
#
|
||||
|
||||
site='https://wiki.systems.ethz.ch/systems_utilisation?action=raw'
|
||||
|
||||
month="$(date +%m)"
|
||||
export year="$(date +%Y)"
|
||||
export month="$(date +%m)"
|
||||
export day="$(date +%d)"
|
||||
|
||||
#
|
||||
# get reservations
|
||||
# get current date
|
||||
# do not change reservations that
|
||||
#
|
||||
# a) are permanent
|
||||
# b) are in the future
|
||||
# b) end in the future
|
||||
# c) are empty
|
||||
#
|
||||
# for all other reservations: delete
|
||||
#
|
||||
|
||||
curl --netrc ${site} | awk -F'\|\|' '$4 !~ /(permanent|time-frame|^ *$)/ { print $0 }'
|
||||
curl --silent --netrc ${site} | \
|
||||
sed 's/||/|/g' | \
|
||||
awk -F'|' \
|
||||
'$4 !~ /(permanent|time-frame|^ *$)/ {
|
||||
|
||||
orig = $0
|
||||
|
||||
# Dateformat: YYYY-MM-DD - YYYY-MM-DD
|
||||
# Remove beginning date
|
||||
sub(/....-..-.. - /, "", $4)
|
||||
split($4, enddate, "-")
|
||||
year = enddate[1]
|
||||
month = enddate[2]
|
||||
day = enddate[3]
|
||||
|
||||
cyear = ENVIRON["year"]
|
||||
cmonth = ENVIRON["month"]
|
||||
cday = ENVIRON["day"]
|
||||
|
||||
if(year >= cyear && month >= cmonth && day >= cday) {
|
||||
print orig
|
||||
} else {
|
||||
print "|| " $2 " || || || || BOOKABLE ||"
|
||||
}
|
||||
|
||||
print $2 ":" year cyear " " month " " day
|
||||
}
|
||||
# print unchangable lines
|
||||
$4 ~ /(permanent|time-frame|^ *$)/ { print $0 }
|
||||
' | \
|
||||
sed 's/|/||/g'
|
||||
|
||||
|
|
Loading…
Reference in a new issue