xref: /plan9-contrib/sys/src/games/music/juke.rc (revision 8ccd4a6360d974db7bd7bbd4f37e7018419ea908)
1#!/bin/rc
2
3wide=`{echo $vgasize | sed 's/(.*)x.*x.*/\1 > 240/' | hoc}
4
5debug=0
6tflag=''
7wflag=''
8host=''
9kb=4096
10flags=()
11sname=$user
12if (! ~ $wide 1) {
13	flags=($flags -t)
14	kb=1024
15}
16while(! ~ $#* 0) {
17	switch ($1) {
18	case -d
19		debug=$2
20		shift
21	case -t
22		tflag='-t'
23	case -h
24		host=$2
25		shift
26	case -w
27		wflags='-w'
28	case -s
29		sname=$2
30		shift
31	case -*
32		echo Usage: classical [-d level] [-t] [-h srvhost]
33		exit usage
34	}
35	shift
36}
37if (! test -e /mnt/playlist){
38	if (! ~ $debug '0') echo mounting playlistfs
39	if (! test -e /srv/playlist.$sname && ! ~ $host ''){
40		import -a $host /srv /srv
41	}
42	if (! mount -b /srv/playlist.$sname /mnt >/dev/null >[2]/dev/null){
43		rm -f /srv/playlist.$sname
44		if (! test -e /sys/lib/music/classic){
45			if (! ~ $debug '0') echo connecting to choline
46			if (! test -e /n/choline/lib/audio)
47				9fs choline
48			if (! bind -a /n/choline/lib/audio /sys/lib/music)
49				exit choline
50		}
51		if (! ~ $debug '0') echo starting playlistfs
52		games/playlistfs -s $sname -d $debug
53	}
54}
55if (! test -w /mnt/juke) {
56	if (! test -e /srv/jukefs.$sname && ! ~ $host ''){
57		import -a $host /srv /srv
58	}
59	if (! mount -b /srv/jukefs.$sname /mnt >/dev/null >[2]/dev/null){
60		if (! ~ $debug '0') echo games/jukefs
61		games/jukefs -s $sname
62	}
63}
64if (~ $wflags '-w') {
65	exec games/jukebox -w -d $debug $tflag &
66}
67exec games/jukebox -d $debug $tflag
68