install.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. #source var/function
  3. . ./function.sh
  4. #read -p "WARNING: This script is experimental. Press Ctrl+C to cancel or Enter to continue." readEnterKey
  5. # NOTE: This requires GNU getopt. On Mac OS X and FreeBSD, you have to install this
  6. # separately; see below.
  7. TEMP=$(getopt -o d: -l destdir: -- "$@")
  8. if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  9. # Note the quotes around `$TEMP': they are essential!
  10. eval set -- "${TEMP}"
  11. eval set -- "${TEMP}"
  12. while [ $# -gt 0 ]
  13. do
  14. case "$1" in
  15. (-d | --destdir) PKG_PATH="$2"; shift;;
  16. esac
  17. shift
  18. done
  19. echo "destdir = ${PKG_PATH} "
  20. check_inst_right
  21. check_files
  22. mkdir -p "${PKG_PATH}/bin/"
  23. mkdir -p "${PKG_PATH}/etc/${PKG}/"
  24. mkdir -p "${PKG_PATH}/usr/${PKG}/"
  25. mkdir -p "${PKG_PATH}/var/${PKG}/log"
  26. #we copy all file into opt/ dir and treat dir like normal unix arborescence
  27. cp -r db/ "${PKG_PATH}/var/${PKG}/db"
  28. if [ -d log ]; then cp -r log/* "${PKG_PATH}/var/${PKG}/log/"; fi
  29. cp -r conf/ "${PKG_PATH}/etc/${PKG}/conf"
  30. cp -r npc/ "${PKG_PATH}/usr/${PKG}/npc"
  31. cp athena-start "${PKG_PATH}/"
  32. cp *-server* "${PKG_PATH}/bin/"
  33. ln -fs "${PKG_PATH}/var/${PKG}/db/" "${PKG_PATH}/db"
  34. ln -fs "${PKG_PATH}/var/${PKG}/log/" "${PKG_PATH}/log"
  35. ln -fs "${PKG_PATH}/etc/${PKG}/conf/" "${PKG_PATH}/conf"
  36. ln -fs "${PKG_PATH}/usr/${PKG}/npc/" "${PKG_PATH}/npc"
  37. ln -fs "${PKG_PATH}/athena-start" "/usr/bin/${PKG}"
  38. for f in $(ls "${PKG_PATH}/bin/") ; do ln -fs "${PKG_PATH}/bin/${f}" "${PKG_PATH}/${f}"; done
  39. echo "Installation is done. You can now control the server with '${PKG} start'"