From: Richard Kettlewell Date: Wed, 16 Jan 2008 20:54:27 +0000 (+0000) Subject: Finish off Mac support in scripts/setup. X-Git-Tag: 3.0~48 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/d255d2119453d1a399a296614fc2762d66f18ef5?hp=244348f83c4e8695ba6aa7cdc6b9a39377754761 Finish off Mac support in scripts/setup. Update README for supported platforms. I'm not happy with this quite yet. --- diff --git a/README b/README index f0f67ea..3c01bdd 100644 --- a/README +++ b/README @@ -53,19 +53,31 @@ Mailing lists: Developers should read README.developers. +Installation (supported platforms) +================================== -Installation -============ +If you are upgrading from an earlier version, see README.upgrades. + +For Debian and Ubuntu, you are best of using .deb files, either download from +www.greenend.org.uk or built locally with 'fakeroot debian/rules binary'. They +will do the majority of the setup for you, using a debconf interface to collect +details about your system. + +For FreeBSD, see README.freebsd (in conjunction with the notes below) and use +scripts/setup. + +For Mac OS X, see README.mac (in conjunction with the notes below) and use +scripts/setup. + + +Installation (generic) +====================== "This place'd be a paradise tomorrow, if every department had a supervisor with a machine-gun" IMPORTANT: If you are upgrading from an earlier version, see README.upgrades. -On a Debian or Ubuntu system, if you install from .deb files then you should be -able to skip steps 1 to 6 and configure it via debconf. This is strongly -recommended! - 1. Build the software. Do something like this: ./configure --sysconfdir=/etc --localstatedir=/var diff --git a/README.freebsd b/README.freebsd index 3a7bc7b..ac38e77 100644 --- a/README.freebsd +++ b/README.freebsd @@ -4,12 +4,17 @@ DisOrder on FreeBSD The server builds on FreeBSD, using the ports system to supply many of its dependencies. It is not well tested in this environment. In particular, since my FreeBSD VM lacks sound support, only network play -has been tested. Please report successes and failures! +has been tested. + +You must use gmake to build DisOrder. + +After installation you can use scripts/setup to install the server +(creating a 'jukebox' user, etc). -Use gmake to build DisOrder, not BSD make: ./configure gmake sudo gmake install - -Then to set up: sudo scripts/setup + sudo disorder setup-guest [--no-online-registration] + +Please report successes and failures! diff --git a/README.mac b/README.mac index f49c3c4..478954d 100644 --- a/README.mac +++ b/README.mac @@ -2,17 +2,15 @@ DisOrder on OS X ================ The server builds on OS X, using Fink to supply many of its -dependencies. It is not well tested in this environment. Please -report successes and failures! +dependencies. It is not well tested in this environment. -There is an EXPERIMENTAL script in scripts/setup which asks a few -questions, sets up a basic installation and starts the server. To use -it, after having done 'sudo make install', just do 'sudo -scripts/setup' and follow the prompts. +After installation you can use scripts/setup to install the server +(creating a 'jukebox' user, etc). -Its current main deficiences are: - - it uses the 'daemon' user/group instead of creating a 'jukebox' - identity. - - the launchd configuration does not have the server started at - boot time. You must start it manually. This may be changed in a - future version. + ./configure + make + sudo make install + sudo scripts/setup + sudo disorder setup-guest [--no-online-registration] + +Please report successes and failures! diff --git a/examples/uk.org.greenend.rjk.disorder.plist.in b/examples/uk.org.greenend.rjk.disorder.plist.in index 3b753ef..c41e591 100644 --- a/examples/uk.org.greenend.rjk.disorder.plist.in +++ b/examples/uk.org.greenend.rjk.disorder.plist.in @@ -19,7 +19,7 @@ WorkingDirectory pkgstatedir - - + RunAtLoad + diff --git a/scripts/setup.in b/scripts/setup.in index d3d6a48..370013e 100755 --- a/scripts/setup.in +++ b/scripts/setup.in @@ -29,9 +29,8 @@ case $(uname -s) in Darwin ) echo "Mac OS X detected" os=Mac - # TODO we should use jukebox and create it if necessary; see below - user=daemon - group=daemon + user=jukebox + group=jukebox ;; FreeBSD ) echo "FreeBSD detected" @@ -191,11 +190,60 @@ if [ ! -f pkgconfdir/options.user ]; then touch pkgconfdir/options.user fi +# pick ID1 ID2 ... IDn +# Echoes an ID matching none of ID1..IDn +pick() { + local n + n=250 # better not choose 0! + while :; do + ok=true + for k in "$@"; do + if [ $n = $k ]; then + ok=false + break + fi + done + if $ok; then + echo $n + return + fi + n=$((1+$n)) + done +} + case $os in Mac ) - # TODO niutil? + # Apple don't seem to believe in creating a user as a discrete operation + if dscl / -read /Groups/$group >/dev/null 2>&1; then + echo "$group group already exists" + else + echo "Creating $group group" + gids=$(dscl / -list /Groups PrimaryGroupID|awk '{print $2}') + gid=$(pick $gids) + echo "(picked gid $gid)" + dscl / -create /Groups/$group + dscl / -create /Groups/$group PrimaryGroupID $gid + dscl / -create /Groups/$group Password \* + fi + if dscl / -read /Users/$user >/dev/null 2>&1; then + echo "$user user already exists" + else + echo "Creating $user user" + uids=$(dscl / -list /Users UniqueID|awk '{print $2}') + uid=$(pick $uids) + echo "(picked uid $uid)" + gid=$(dscl / -read /Groups/$group PrimaryGroupID | awk '{print $2}') + dscl / -create /Users/$user + dscl / -create /Users/$user UniqueID $uid + dscl / -create /Users/$user UserShell /usr/bin/false + dscl / -create /Users/$user RealName 'DisOrder server' + dscl / -create /Users/$user NFSHomeDirectory pkgstatedir + dscl / -create /Users/$user PrimaryGroupID $gid + dscl / -create /Users/$user Password \* + fi ;; FreeBSD ) + # FreeBSD has a simple well-documented interface if pw groupshow $group >/dev/null 2>&1; then echo "$group group already exists" else diff --git a/scripts/teardown.in b/scripts/teardown.in index dbf593c..63df4eb 100755 --- a/scripts/teardown.in +++ b/scripts/teardown.in @@ -32,8 +32,8 @@ FreeBSD ) rm -rf pkgstatedir rm -rf pkgconfdir echo "* removing user and group" - pw groupdel jukebox || true pw userdel jukebox || true + pw groupdel jukebox || true ;; Darwin ) echo "* stopping server" @@ -45,6 +45,9 @@ Darwin ) rm -f /Library/LaunchDaemons/uk.org.greenend.rjk.disorder.plist rm -rf pkgstatedir rm -rf pkgconfdir + echo "* removing user and group" + dscl / -delete /Users/jukebox || true + dscl / -delete /Groups/jukebox || true ;; * ) echo Unknown operating system >&2