3 # This file is part of DisOrder
4 # Copyright (C) 2008 Richard Kettlewell
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 echo ------------------------------------------------------------------------
26 echo "DisOrder setup script"
30 echo "Mac OS X detected"
32 # TODO we should use jukebox and create it if necessary; see below
37 echo "FreeBSD detected"
43 if grep Debian /etc/issue >/dev/null 2>&1; then
44 echo "You appear to be running Debian - please use .debs instead"
47 if grep Ubuntu /etc/issue >/dev/null 2>&1; then
48 echo "You appear to be running Ubuntu - please use .debs instead"
58 echo "WARNING: unknown operating system '$(uname -s)'"
59 echo "This script won't be able to do all setup on this platform"
67 echo "This script will:"
68 echo " - overwrite any existing configuration"
71 echo " - set the server up to be run at boot time"
72 echo " - start the server"
76 echo "If this is not what you want, press ^C."
77 echo ------------------------------------------------------------------------
81 echo "What directory or directories contain your music files:"
82 echo "(enter one or more directories separated by spaces)"
85 for root in $roots; do
86 if [ ! -d $root ]; then
87 echo "'$root' does not exist"
96 if [ -z "$encoding" ]; then
98 echo "What filesystem encoding should I assume for track names?"
99 echo "(e.g. UTF-8, ISO-8859-1, ...)"
105 echo "What TCP port should DisOrder listen on?"
106 echo "(enter 'none' for none)"
113 echo "'$port' is not a valid port number"
123 echo "What host should DisOrder use as an SMTP server?"
127 echo "What address should mail from DisOrder come from?"
131 echo "Proposed DisOrder setup:"
132 echo " Music directory: $roots"
133 if [ $port = none ]; then
134 echo " Do not listen on a TCP port"
136 echo " TCP port to listen on: $port"
138 echo " SMTP Server: $smtp_server"
139 echo " Sender address: $mail_sender"
141 echo "Is this OK? (Enter 'y' or 'n')"
148 echo "OK, didn't change anything."
155 rm -f pkgconfdir/config.new
156 for root in $roots; do
157 echo "collection fs $encoding $root" >> pkgconfdir/config.new
159 for scratch in slap.ogg scratch.ogg; do
160 echo "scratch pkgdatadir/$scratch" >> pkgconfdir/config.new
162 echo "user $user" >> pkgconfdir/config.new
163 if [ $port != none ]; then
164 echo "listen 0.0.0.0 $port" >> pkgconfdir/config.new
166 echo "smtp_server $smtp_server" >> pkgconfdir/config.new
167 echo "mail_sender $mail_sender" >> pkgconfdir/config.new
170 echo "Proposed pkgconfdir/config:"
171 sed < pkgconfdir/config.new 's/^/ /'
173 echo "Is this OK? (Enter 'y' or 'n')"
180 echo "OK, not installing it."
181 rm -f pkgconfdir/config.new
186 echo "Installing pkgconfdir/config"
187 mv pkgconfdir/config.new pkgconfdir/config
189 if [ ! -f pkgconfdir/options.user ]; then
190 echo "Making sure pkgconfdir/options.user exists"
191 touch pkgconfdir/options.user
199 if pw groupshow $group >/dev/null 2>&1; then
200 echo "$group group already exists"
202 echo "Creating $group group"
205 if pw usershow $user >/dev/null 2>&1; then
206 echo "$user user already exists"
208 echo "Creating $user user"
209 pw useradd $user -w no -d pkgstatedir -g $group -c 'DisOrder user'
213 if grep ^$group: /etc/group >/dev/null; then
214 echo "$group group already exists"
216 echo "Creating $group group"
219 if grep ^$user: /etc/passwd >/dev/null; then
220 echo "$user user already exists"
222 echo "Creating $user user"
223 useradd -d pkgstatedir -g $group $user -c 'DisOrder user'
228 echo "Making sure that pkgstatedir exists"
230 chown $user:$group pkgstatedir
231 chmod 2755 pkgstatedir
235 echo "Installing the plist into /Library/LaunchDaemons"
236 cp server/uk.org.greenend.rjk.disorder.plist /Library/LaunchDaemons/.
237 echo "Reloading launchd"
238 launchctl load /Library/LaunchDaemons
239 echo "Starting DisOrder server"
240 launchctl start uk.org.greenend.rjk.disorder
241 echo "Installing CGI"
242 install -m 555 server/disorder.cgi /Library/WebServer/CGI-Executables/disorder
243 echo "Setting up link to CGI;'s dependencies"
244 rm -f /Library/WebServer/Documents/disorder
245 ln -s pkgdatadir/static /Library/WebServer/Documents/disorder
247 echo "You must sudo disorder setup-guest [--no-online-registration] next."
250 echo "Sorry, I don't know how to install the server on this platform."
251 echo "You will have to do that by hand."