#!/bin/bash
#
# David Joffe 1999/01
# Simple script to run Dave Gnukem in full-screen mode.
# Tests if you are already root, and tries "su" if not.
# See the readme for more information.
#
# Note to self: Is "/bin/bash" a safe assumption for non-Linux?
# FIXME: $USER isn't necessarily "root" if you 'su'd. How to test then?
#

# Test if user is already root

if [ "root" = $USER ]; then {
  echo 'Detected root user; running fullscreen.'

  ./davegnukem -f
} else {

# if not, try su to root

  echo '-------------------------------------------------------------------'
  echo 'Full-screen mode requires access to /dev/mem, which normally means'
  echo 'being root, so this script will now attempt to "su" to root, which will'
  echo 'require your root password. If youre concerned about security/trojans'
  echo 'etc, Ctrl+C now and run plain "davegnukem" windowed. You can avoid this'
  echo 'message in future by doing "chmod 766 /dev/mem" while root and then'
  echo 'just running "davegnukem -f" in future , although I suspect that the'
  echo 'implication of that is potential Windows-style instability.'
  echo '-------------------------------------------------------------------'
  
  su -c "./davegnukem -f" root
} fi
