blob: 1d7b2deed471fe193dd0712890e1e857d6f2a835 (
plain)
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
|
#!/bin/rc
# pimup -- bring up mail and the calendars, and mount them here.
#
# Safe to run twice: anything already posted in /srv is reused rather
# than started again. Run it from riostart so every window inherits the
# mounts, since a mount only exists in the namespace that made it.
rfork e
cald=/usr/glenda/lib/cal
log=/tmp/pimup.log
>$log
# Wait for a server to announce itself and echo the name it posted.
# rc has no return, so this loops on a condition rather than bailing out.
fn waitsrv {
s=()
i=0
while(~ $#s 0 && test $i -lt 40){
s=`{sed -n 's|.*serving /srv/||p' $1}
if(~ $#s 0){
sleep 1
i=`{echo $i + 1 | bc}
}
}
echo $"s
}
# ---- mail
if(! test -e /srv/upasfs.$user)
upas/fs -s -f /imaps/imap.fastmail.com/calvin@pobox.com \
</dev/null >/dev/null >>[2]$log &
sleep 2
if(test -e /srv/upasfs.$user)
mount /srv/upasfs.$user /mail/fs >>[2]$log
# ---- mount points for the calendars
if(! test -e /srv/pimroot)
mntgen -s pimroot /mnt/pim </dev/null >/dev/null >[2]/dev/null &
sleep 1
mount /srv/pimroot /mnt/pim >[2]/dev/null
ls -d /mnt/pim/calendars >/dev/null >[2]/dev/null
if(! test -e /srv/pimcals)
mntgen -s pimcals /mnt/pim/calendars </dev/null >/dev/null >[2]/dev/null &
sleep 1
mount /srv/pimcals /mnt/pim/calendars >[2]/dev/null
# ---- calendars. Go's getpid() on plan9 is a thread id, so the name rc
# knows as $apid is not the one in /srv: read it out of the log.
fn cal {
name=$1
l=$2
shift
shift
if(! test -f /mnt/pim/calendars/$name/ctl){
>$l
$* >[2]$l </dev/null >/dev/null &
s=`{waitsrv $l}
if(~ $#s 0)
echo 'pimup: '^$name^' did not start, see '^$l >>$log
if(! ~ $#s 0)
mount /srv/^$"s /mnt/pim/calendars/$name >>[2]$log
}
}
cal work /tmp/work.log ical/fs -N work -d $cald
cal local /tmp/local.log ical/fs -N local -d /tmp/callocal
if(test -f $cald/fastmail.pw)
cal fastmail /tmp/dav.log caldav/fs -e https://caldav.fastmail.com/dav/ \
-u calvin@pobox.com -p $cald/fastmail.pw -C Calendar -N fastmail
exit 0
|