X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/93ca72f2d7a75e383f6b7b2460cee8b1c4ae2cfe..c40544fdbbfd762bed24b65d96d9d1ca0bdec3f7:/debian/postinst.disorder-server diff --git a/debian/postinst.disorder-server b/debian/postinst.disorder-server index 53402b5..bc4a938 100755 --- a/debian/postinst.disorder-server +++ b/debian/postinst.disorder-server @@ -34,55 +34,70 @@ 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 } -case "$1" in -configure ) - if grep -q ^jukebox: /etc/passwd; then - : +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 - add_jukebox_user + echo "Cannot determine whether guest user has been set up." + echo fi - if test ! -f /etc/disorder/config.private; then - rootpw=`pwgen 16 1` - webpw=`pwgen 16 1` - if test -z "$rootpw" || test -z "$webpw"; then - # We used to ignore the exit status of pwgen due to a bug in an old - # version of Debian. That bug seems to be gone, but this check is - # harmless and could catch future bugs. - echo "$0: pwgen failed" 1>&2 - exit 1 - fi - # We set the umask so that private files aren't transiently world-readable - u=`umask` - umask 077 + rm -f "$TMPFILE" +} - echo allow root "$rootpw" > /etc/disorder/config.private.new - echo allow www-data "$webpw" >> /etc/disorder/config.private.new - chgrp jukebox /etc/disorder/config.private.new +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 - - if test ! -f /etc/disorder/config.www-data; then - echo password "$webpw" > /etc/disorder/config.www-data.new - chgrp www-data /etc/disorder/config.www-data.new - chmod 640 /etc/disorder/config.www-data.new - mv /etc/disorder/config.www-data.new /etc/disorder/config.www-data - fi - umask $u fi +} - if test ! -f /etc/disorder/http.users; then - u=`umask` - umask 077 - touch /etc/disorder/http.users - chgrp www-data /etc/disorder/http.users - chmod 640 /etc/disorder/http.users - umask $u +case "$1" in +configure ) + if grep -q ^jukebox: /etc/passwd; then + : + else + add_jukebox_user fi chown jukebox:jukebox /var/lib/disorder configure_init_d restart_server + fix_configuration + setup_guest db_stop ;; abort-upgrade )