chiark / gitweb /
Updates to Debian scripts:
authorRichard Kettlewell <richard@fanticule>
Mon, 31 Dec 2007 18:24:22 +0000 (18:24 +0000)
committerRichard Kettlewell <richard@fanticule>
Mon, 31 Dec 2007 18:24:22 +0000 (18:24 +0000)
  - debconf for smtp_server and mail_sender
  - cgi is now .../cgi-bin/disorder rather than .../cgi-bin/disorder/disorder
  - auto setup guest login if possible
  - auto remove obsolete trust/allow after first server start
    (specifically, they are commented out so the user can put them
    back if things went awry.)

Things are still rather broken but they're getting there...

debian/conffiles.disorder-server
debian/config.disorder-server
debian/postinst.disorder-server
debian/rules
debian/templates.disorder-server

index 7d1aa67..41df91d 100644 (file)
@@ -1,4 +1,3 @@
 /etc/disorder/config
 /etc/disorder/options
 /etc/init.d/disorder
-/usr/lib/cgi-bin/disorder/.htaccess
index 11bec83..83ffd80 100755 (executable)
@@ -26,6 +26,8 @@ db_input high disorder/roots || true
 db_input high disorder/encoding || true
 db_input high disorder/port || true
 db_input medium disorder/scratches || true
+db_input medium disorder/smtp_server || true
+db_input high disorder/mail_sender || true
 db_go || true
 
 db_get disorder/roots || true
@@ -36,6 +38,10 @@ db_get disorder/encoding || true
 encoding="$RET"
 db_get disorder/port || true
 port="$RET"
+db_get disorder/smtp_server || true
+smtp_server="$RET"
+db_get disorder/mail_sender || true
+mail_sender="$RET"
 
 mkdir -p /etc/disorder
 cat > /etc/disorder/conf.debconf.new <<EOF
@@ -43,16 +49,31 @@ cat > /etc/disorder/conf.debconf.new <<EOF
 # do not edit manually
 # run 'dpkg-reconfigure disorder' instead
 EOF
+
 echo >> /etc/disorder/conf.debconf.new
 echo "# Collection roots"  >> /etc/disorder/conf.debconf.new
 for r in $roots; do
   echo "collection fs $encoding $r" >> /etc/disorder/conf.debconf.new
 done
+
 echo >> /etc/disorder/conf.debconf.new
 echo "# Scratches" >> /etc/disorder/conf.debconf.new
 for s in $scratches; do
   echo "scratch $s" >> /etc/disorder/conf.debconf.new
 done
+
+if test "$mail_sender" != ""; then
+  echo "" >> /etc/disorder/conf.debconf.new
+  echo "# SMTP server" >> /etc/disorder/conf.debconf.new
+  echo "smtp_server $smtp_server" >> /etc/disorder/conf.debconf.new
+fi
+
+if test "$mail_sender" != ""; then
+  echo "" >> /etc/disorder/conf.debconf.new
+  echo "# Source mail address" >> /etc/disorder/conf.debconf.new
+  echo "mail_sender $mail_sender" >> /etc/disorder/conf.debconf.new
+fi
+
 if test "$port" != none && test "$port" != ""; then
   echo >> /etc/disorder/conf.debconf.new
   echo "# Listen for remote clients" >> /etc/disorder/conf.debconf.new
index 4ee3e0a..bc4a938 100755 (executable)
@@ -34,6 +34,56 @@ configure_init_d() {
 
 restart_server() {
   /etc/init.d/disorder restart
+  # Wait for the server to get going.  This is a horrid bodge and ought
+  # to be done away with, but is required for the time being.  Sorry.
+  sleep 5
+}
+
+setup_guest() {
+  echo "Checking whether guest user exists..."
+  TMPFILE="$(mktemp -t)"
+  if disorder users > "$TMPFILE"; then
+    if grep -q '^guest$' "$TMPFILE"; then
+      echo "Guest user has already been set up."
+    else
+      echo "Attempting to set up guest user..."
+      if disorder setup-guest; then
+        echo "Created guest user."
+      else
+        echo "Failed to create guest user."
+        echo "You can use 'disorder setup-guest' to do this step manually."
+        echo
+      fi
+    fi
+  else
+    echo "Cannot determine whether guest user has been set up."
+    echo
+  fi
+  rm -f "$TMPFILE"
+}
+
+fix_configuration() {
+  # Once the server has started up, we can remove some of the obsolete
+  # directives from the config file.
+  if grep -q ^trust /etc/disorder/config; then
+    echo "Removing obsolete 'trust' directive from /etc/disorder/config"
+    sed < /etc/disorder/config > /etc/disorder/config.new \
+       's/^trust/#trust/'
+    chmod 644 /etc/disorder/config.new
+    mv /etc/disorder/config.new /etc/disorder/config
+  fi
+  if test -e /etc/disorder/config.private \
+      && grep -q ^allow /etc/disorder/config.private; then
+    echo "Removing obsolete 'allow' directive(s) from /etc/disorder/config.private"
+    u=$(umask)
+    umask 077
+    sed < /etc/disorder/config.private > /etc/disorder/config.private.new \
+       's/^allow/#allow/'
+    umask $u
+    chmod 640 /etc/disorder/config.private.new
+    chown root:jukebox /etc/disorder/config.private.new
+    mv /etc/disorder/config.private.new /etc/disorder/config.private
+  fi
 }
 
 case "$1" in
@@ -46,6 +96,8 @@ configure )
   chown jukebox:jukebox /var/lib/disorder
   configure_init_d
   restart_server
+  fix_configuration
+  setup_guest
   db_stop
   ;;
 abort-upgrade )
index 9eb4d19..e9f8d9f 100755 (executable)
@@ -150,7 +150,7 @@ pkg-disorder-server: build
        rm -rf debian/disorder-server/usr/share/man/man5
        $(MKDIR) debian/disorder-server/etc/disorder
        $(MKDIR) debian/disorder-server/etc/init.d
-       $(MKDIR) debian/disorder-server/usr/lib/cgi-bin/disorder
+       $(MKDIR) debian/disorder-server/usr/lib/cgi-bin
        $(MKDIR) debian/disorder-server/var/lib/disorder
        $(INSTALL_SCRIPT) examples/disorder.init \
                debian/disorder-server/etc/init.d/disorder
@@ -159,13 +159,11 @@ pkg-disorder-server: build
        $(INSTALL_DATA) debian/etc.disorder.options \
                debian/disorder-server/etc/disorder/options
        $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) server/disorder.cgi \
-               $(shell pwd)/debian/disorder-server/usr/lib/cgi-bin/disorder/disorder
+               $(shell pwd)/debian/disorder-server/usr/lib/cgi-bin/disorder
        dpkg-shlibdeps -Tdebian/substvars.disorder-server \
-               debian/disorder-server/usr/lib/cgi-bin/disorder/* \
+               debian/disorder-server/usr/lib/cgi-bin/disorder \
                debian/disorder-server/usr/sbin/* \
                debian/disorder-server/usr/lib/disorder/*.so*
-       $(INSTALL_DATA) debian/htaccess \
-               debian/disorder-server/usr/lib/cgi-bin/disorder/.htaccess
        rm -rf debian/disorder-server/usr/share/doc/disorder-server
        ln -s disorder debian/disorder-server/usr/share/doc/disorder-server
        dpkg-gencontrol -isp -pdisorder-server -Pdebian/disorder-server -Tdebian/substvars.disorder-server
index b1a14c4..f2ad1e0 100644 (file)
@@ -27,3 +27,19 @@ Description: Port number for clients to connect to
  Enter the port number that the server should listen on for clients.  This
  can be set to 'none' to permit only local clients or a port number for
  remote clients to connect to, e.g. using Disobedience.
+
+Template: disorder/smtp_server
+Type: string
+Default: localhost
+Description: SMTP server for web interface
+ The web interface requires an SMTP server in order to send messages to
+ newly registered users, and to send password reminders.  Enter the hostname
+ or IP address to use.
+
+Template: disorder/mail_sender
+Type: string
+Default: 
+Description: Sender address for email from web interface
+ The web interface needs to know what email address it should send messages
+ from.  It is possible that users will reply to this address if they are
+ unsure what to do.