chiark / gitweb /
New scripts/setup which interactively sets up a DisOrder configuration
authorRichard Kettlewell <rjk@greenend.org.uk>
Mon, 14 Jan 2008 20:24:31 +0000 (20:24 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Mon, 14 Jan 2008 20:24:31 +0000 (20:24 +0000)
and (on the Mac) starts the server.  Should be considered experimental
for now!

.bzrignore
README.mac
scripts/Makefile.am
scripts/sedfiles.make
scripts/setup.in [new file with mode: 0755]
server/uk.org.greenend.rjk.disorder.plist.in

index 0ca950c28f44facdaba2a4938967e0d8494b8c99..cccfd7572e55427690ed46c64cd01f1b089cb624 100644 (file)
@@ -142,3 +142,4 @@ server/index.html
 tests/disorder-udplog
 lib/version-string
 lib/version.h
+scripts/setup
index 2bb249a29aea774bb3cb52a42b8babba8acca806..f49c3c4cce50a6f1e0c17318329195c755144f58 100644 (file)
@@ -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.
index fd3a35bbcf25407dd241f4df9e228bd67aaf3088..d79d8d2f614e49fd6a641e85262855fab211f24a 100644 (file)
@@ -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
 #
 
 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)
index 8557a865e8ca2b52959985695b29e0be0007a686..da6727a2e6639ccd27bb0c5581ba7d0c338ce1c5 100644 (file)
@@ -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 (executable)
index 0000000..b64c508
--- /dev/null
@@ -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
index 36ca4d62251ed7f284f652e85f0c27f7f7f82fca..3b753ef1c28c01183e2b6afa9ed4b43cee88950a 100644 (file)
@@ -18,7 +18,7 @@
                <string>--syslog</string>
        </array>
        <key>WorkingDirectory</key>
-       <string>/Users/jukebox</string>
+       <string>pkgstatedir</string>
 <!--   <key>RunAtLoad</key> -->
 <!--   <true/> -->
 </dict>