install_to_venv.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. #
  3. # Create a new Python virtualenv and install pwman into it.
  4. #
  5. # By default the virtualenv is created in the directory 'pwman-venv'.
  6. # Another directory may be selected as an argument to this script.
  7. #
  8. basedir="$(realpath "$0" | xargs dirname)"
  9. default_venvdir="$basedir/pwman-venv"
  10. die()
  11. {
  12. echo "ERROR: $*" >&2
  13. exit 1
  14. }
  15. usage()
  16. {
  17. echo "Usage: install_to_venv.sh [OPTS] [VENV_PATH]"
  18. echo
  19. echo "VENV_PATH: Path to the venv to create. Default: $default_venvdir"
  20. echo
  21. echo "Opts:"
  22. echo " -i|--no-install Only create the venv. Do not install pwman into it."
  23. }
  24. venvdir="$default_venvdir"
  25. opt_install=1
  26. while [ $# -ge 1 ]; do
  27. case "$1" in
  28. -h|--help)
  29. usage
  30. exit 0
  31. ;;
  32. -i|--no-install)
  33. opt_install=0
  34. ;;
  35. *)
  36. venvdir="$1"
  37. shift
  38. break
  39. ;;
  40. esac
  41. shift
  42. done
  43. if [ $# -ne 0 ]; then
  44. usage
  45. die "Invalid options"
  46. fi
  47. [ "$(id -u)" != "0" ] || die "Don't run this script as root."
  48. cd "$basedir" || die "Failed to cd to basedir."
  49. rm -rf "$venvdir" || die "Failed to rm."
  50. python3 -m venv --clear --system-site-packages "$venvdir" || die "python3 -m venv failed."
  51. . "$venvdir"/bin/activate || die "venv activate failed."
  52. pip3 install pycryptodomex || die "pip install pycryptodomex failed."
  53. pip3 install pyaes || die "pip install pyaes failed."
  54. pip3 install argon2-cffi || die "pip install argon2-cffi failed."
  55. pip3 install argon2pure || die "pip install argon2pure failed."
  56. if [ $opt_install -ne 0 ]; then
  57. ./setup.py install || die "Failed to install pwman."
  58. fi