From 91370169de7f552f3a54e5ef9e079a202a5efbfa Mon Sep 17 00:00:00 2001 Message-Id: <91370169de7f552f3a54e5ef9e079a202a5efbfa.1714840573.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 14 Jan 2008 20:24:31 +0000 Subject: [PATCH] New scripts/setup which interactively sets up a DisOrder configuration and (on the Mac) starts the server. Should be considered experimental for now! Organization: Straylight/Edgeware From: Richard Kettlewell --- .bzrignore | 1 + README.mac | 33 ++-- scripts/Makefile.am | 11 +- scripts/sedfiles.make | 8 +- scripts/setup.in | 181 +++++++++++++++++++ server/uk.org.greenend.rjk.disorder.plist.in | 2 +- 6 files changed, 210 insertions(+), 26 deletions(-) create mode 100755 scripts/setup.in diff --git a/.bzrignore b/.bzrignore index 0ca950c..cccfd75 100644 --- a/.bzrignore +++ b/.bzrignore @@ -142,3 +142,4 @@ server/index.html tests/disorder-udplog lib/version-string lib/version.h +scripts/setup diff --git a/README.mac b/README.mac index 2bb249a..f49c3c4 100644 --- a/README.mac +++ b/README.mac @@ -5,25 +5,14 @@ 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! - -Things you will need to do: - -* Create the jukebox user and group - -You might find this URL helpful: - -http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/additionalfeatures/chapter_10_section_9.html - -* Install the plist - -Copy server/uk.org.greenend.rjk.disorder.plist into -/Library/LaunchDaemons. Having done this reload the contents: - - sudo launchctl load /Library/LaunchDaemons - -Note that the RunAtLoad key has been deliberately commented out, if -you want to start the server at boot time you must edit this first. - -* Start the server - - sudo launchctl start uk.org.greenend.rjk.disorder +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. + +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. diff --git a/scripts/Makefile.am b/scripts/Makefile.am index fd3a35b..d79d8d2 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,6 +1,6 @@ # # This file is part of DisOrder. -# Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell +# Copyright (C) 2004-2008 Richard Kettlewell # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,6 +19,13 @@ # dist_pkgdata_DATA=completion.bash +noinst_SCRIPTS=setup + +SEDFILES=setup + +include ${top_srcdir}/scripts/sedfiles.make EXTRA_DIST=htmlman sedfiles.make text2c oggrename make-unidata \ - format-gcov-report make-version-string + format-gcov-report make-version-string setup.in + +CLEANFILES=$(SEDFILES) diff --git a/scripts/sedfiles.make b/scripts/sedfiles.make index 8557a86..da6727a 100644 --- a/scripts/sedfiles.make +++ b/scripts/sedfiles.make @@ -27,7 +27,13 @@ $(SEDFILES) : % : %.in Makefile -e 's!pkgdatadir!${pkgdatadir}!g;' \ -e 's!_version_!${VERSION}!g;' \ < $< > $@.new - chmod 444 $@.new + @if test -x $<; then \ + echo chmod 555 $@.new;\ + chmod 555 $@.new;\ + else \ + echo chmod 444 $@.new;\ + chmod 444 $@.new;\ + fi mv -f $@.new $@ # Local Variables: diff --git a/scripts/setup.in b/scripts/setup.in new file mode 100755 index 0000000..b64c508 --- /dev/null +++ b/scripts/setup.in @@ -0,0 +1,181 @@ +#! /bin/bash +# +# This file is part of DisOrder +# Copyright (C) 2008 Richard Kettlewell +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +# + +set -e + +echo +echo ------------------------------------------------------------------------ +echo "DisOrder setup script" + +case $(uname -s) in +Darwin ) + os=mac + user=daemon + group=daemon + ;; +* ) + os=unknown + user=daemon + group=daemon + ;; +esac + +echo +echo "This script will:" +echo " - overwrite any existing configuration" +case $os in +mac ) + echo " - set the server up to be run at boot time" + echo " - start the server" + ;; +esac +echo +echo "If this is not what you want, press ^C." +echo ------------------------------------------------------------------------ + +while :; do + echo + echo "What directory or directories contain your music files:" + echo "(enter one or more directories separated by spaces)" + read -r roots + ok=true + for root in $roots; do + if [ ! -d $root ]; then + echo "'$root' does not exist" + ok=false + fi + done + if $ok; then + break + fi +done + +if [ -z "$encoding" ]; then + echo + echo "What filesystem encoding should I assume for track names?" + echo "(e.g. UTF-8, ISO-8859-1, ...)" + read -r encoding +fi + +while :; do + echo + echo "What TCP port should DisOrder listen on?" + echo "(enter 'none' for none)" + read -r port + case $port in + none ) + break + ;; + [^0-9] ) + echo "'$port' is not a valid port number" + continue + ;; + * ) + break + ;; + esac +done + +echo +echo "What host should DisOrder use as an SMTP server?" +read -r smtp_server + +echo +echo "What address should mail from DisOrder come from?" +read -r mail_sender + +echo +echo "Proposed DisOrder setup:" +echo " Music directory: $roots" +if [ $port = none ]; then + echo " Do not listen on a TCP port" +else + echo " TCP port to listen on: $port" +fi +echo " SMTP Server: $smtp_server" +echo " Sender address: $mail_sender" + +echo "Is this OK? (Enter 'y' or 'n')" +read -r ok +case $ok in +y ) + ;; +* ) + echo + echo "OK, didn't change anything." + exit 0 + ;; +esac + +mkdir -p pkgconfdir + +rm -f pkgconfdir/config.new +for root in $roots; do + echo "collection fs $encoding $root" >> pkgconfdir/config.new +done +for scratch in slap.ogg scratch.ogg; do + echo "scratch pkgdatadir/$scratch" >> pkgconfdir/config.new +done +echo "user $user" >> pkgconfdir/config.new +if [ $port != none ]; then + echo "listen 0.0.0.0 $port" >> pkgconfdir/config.new +fi + +echo +echo "Proposed pkgconfdir/config:" +sed < pkgconfdir/config.new 's/^/ /' +echo +echo "Is this OK? (Enter 'y' or 'n')" +read -r ok +case $ok in +y ) + ;; +* ) + echo + echo "OK, not installing it." + rm -f pkgconfdir/config.new + exit 0 + ;; +esac +echo +echo "Installing pkgconfdir/config" +mv pkgconfdir/config.new pkgconfdir/config + +echo "Making sure that pkgstatedir exists" +mkdir -p pkgstatedir +chown $user:$group pkgstatedir +chmod 2755 pkgstatedir + +case $os in +mac ) + echo "Installing the plist into /Library/LaunchDaemons/" + cp server/uk.org.greenend.rjk.disorder.plist /Library/LaunchDaemons/. + echo "Reloading launchd" + launchctl load /Library/LaunchDaemons + echo "Starting DisOrder server" + launchctl start uk.org.greenend.rjk.disorder + ;; +* ) + echo "Sorry, I don't know how to install the server on this platform." + echo "You will have to do that by hand." + exit 1 + ;; +esac diff --git a/server/uk.org.greenend.rjk.disorder.plist.in b/server/uk.org.greenend.rjk.disorder.plist.in index 36ca4d6..3b753ef 100644 --- a/server/uk.org.greenend.rjk.disorder.plist.in +++ b/server/uk.org.greenend.rjk.disorder.plist.in @@ -18,7 +18,7 @@ --syslog WorkingDirectory - /Users/jukebox + pkgstatedir -- [mdw]