preinst 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh
  2. set -e
  3. SCOREFILES="
  4. /var/games/bsdgames/atc_score
  5. /var/games/bsdgames/battlestar.log
  6. /var/games/bsdgames/cfscores
  7. /var/games/bsdgames/criblog
  8. /var/games/bsdgames/saillog
  9. /var/games/bsdgames/snake.log
  10. /var/games/bsdgames/snakerawscores
  11. /var/games/bsdgames/tetris-bsd.scores
  12. /var/games/bsdgames/phantasia/characs
  13. /var/games/bsdgames/phantasia/gold
  14. /var/games/bsdgames/phantasia/lastdead
  15. /var/games/bsdgames/phantasia/mess
  16. /var/games/bsdgames/phantasia/motd
  17. /var/games/bsdgames/phantasia/scoreboard
  18. /var/games/bsdgames/phantasia/void
  19. /var/games/bsdgames/phantasia/monsters"
  20. # We used to keep score files in /var/lib/games, and if files are there,
  21. # move them into the new location.
  22. if [ -d /var/lib/games ]; then
  23. # Have to set up directory hierarchy, since this is running as a
  24. # preinst.
  25. mkdir -p /var/games/bsdgames/phantasia
  26. chown root:games /var/games/bsdgames \
  27. /var/games/bsdgames/phantasia
  28. chmod g+rws /var/games/bsdgames \
  29. /var/games/bsdgames/phantasia
  30. for file in $SCOREFILES; do
  31. oldfile=`echo $file | sed s:/var/games/:/var/lib/games/:`
  32. if [ -e $oldfile ]; then
  33. if [ ! -e $file ]; then
  34. mv -f $oldfile $file
  35. else
  36. rm -f $oldfile
  37. fi
  38. fi
  39. done
  40. # Delete the old directory hierarchy.
  41. rm -rf /var/lib/games/bsdgames
  42. fi
  43. # I didn't move robots_roll above, because the version used by old bsdgames has
  44. # a different file format. Make sure that if I'm ugrading from pre 2.8 days,
  45. # the old file is deleted.
  46. if [ "$1" = "upgrade" ] && dpkg --compare-versions "$2" lt 2.8; then
  47. rm -rf /var/games/bsdgames/robots_roll
  48. fi
  49. #DEBHELPER#