xref: /inferno-os/dis/grid/spreesrv (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1#!/dis/sh
2
3
4load std
5autoload=std
6pctl forkns newpgrp
7echo -n 62.254.170.99 > /dev/sysname
8
9# from /dis/svc/auth (except -n option)
10fn auth {
11	or {ftest -e /net/dns} {ftest -e /env/emuhost} {ndb/dns}
12	or {ftest -e /net/cs} {ndb/cs}
13	# svc/registry	# unclear if we should
14	or {ftest -f /keydb/signerkey} {echo 'auth: need to use createsignerkey(8)' >[1=2]; exit nosignerkey}
15	or {ftest -f /keydb/keys} {echo 'auth: need to create /keydb/keys' >[1=2]; exit nokeys}
16	nopt := ()
17	if{ftest -r /tmp/gamepasswd} {
18		nopt=-n /tmp/gamepasswd
19	}
20	and {auth/keyfs $nopt} {
21		listen -v -t -A 'tcp!*!inflogin' {auth/logind&}
22		listen -v -t -A 'tcp!*!infkey' {auth/keysrv&}
23		listen -v -t -A 'tcp!*!infsigner' {auth/signer&}
24		listen -v -t -A 'tcp!*!infcsigner' {auth/countersigner&}
25	}
26}
27
28fn ck {
29	or {$*} {
30		echo signer startup failed >[1=2]
31		rm -f /mnt/registry/tcp!doppio!inflogin
32		kill -g ${pid}
33		raise error
34	}
35}
36
37fn register {
38	{
39		or {echo $*} {
40			echo spreesrv: register $* failed >[1=2]
41		}
42		sleep 2000000
43	} $* > /mnt/registry/new &
44}
45sysname="{cat /dev/sysname}
46
47ck ndb/cs
48ck mount -A 'tcp!$registry!registry' /mnt/registry
49
50@ {
51	pctl forkns
52	ck listen -f /usr/i4e/keyring/spree tcp!$sysname!1234 {
53		if {~ $user spree} {
54			export /lib/spreearchive &
55		}
56	}
57}
58
59# start auth services and announce them in the registry.
60ck bind /keydb/gamesignerkey /keydb/signerkey
61ck bind /keydb/gamekeys /keydb/keys
62ck auth
63pk=`{getpk /keydb/signerkey}
64ck register tcp!$sysname!inflogin resource login pk $pk
65ck register tcp!$sysname!infkey resource infkey pk $pk
66
67ck grid/register -a resource createuser -a signer $pk { grid/usercreatesrv }
68