#!/bin/sh

if [ -z "$PLAN9" ]; then
  echo "PLAN9 not set;"
  echo "Please set it to the location of your plan9port installation."
  exit 1
fi

if [ $(whoami) != "root" ]; then
  mkdir -p ~/bin/9
  cp ryudo ~/bin/9/ryudo
  echo "ryudo has been installed to '${HOME}/bin/9/';"
  echo "You may want to add it to your PATH."
  echo "The manual pages were not installed."
else
  cp ryudo ${PLAN9}/bin/ryudo
  cp ryudo.desktop /usr/share/xsessions/ryudo.desktop
  cp startryudo /usr/bin/startryudo
  cp ryudo.1 $PLAN9/man/man1/ryudo.1

  chmod a+x /usr/bin/startryudo
  chmod a+x ${PLAN9}/bin/ryudo

  echo "ryudo has been installed to '${PLAN9}/bin/';"
  echo "xsession has been installed to '/usr/share/xsessions';"
  echo "startryudo script has been installed to '/usr/bin/';"
  echo "The manual pages have been installed to '${PLAN9}/man/'"
fi
