You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

on-target 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/sh
  2. . gconfig
  3. TUSER=${DISTRO:-ubuntu}
  4. usage() {
  5. echo "Usage: ${0##*/} [OPTION]... <command>"
  6. echo "Run command on build target."
  7. echo
  8. cat << EOF
  9. --help display this help and exit
  10. --user|-u <username> run as <username> instead of ubuntu
  11. --env|-e "NAME=VALUE ..." modify the environment
  12. EOF
  13. }
  14. if [ $# != 0 ] ; then
  15. while true ; do
  16. case "$1" in
  17. --help|-h)
  18. usage
  19. exit 0
  20. ;;
  21. --user|-u)
  22. TUSER="$2"
  23. shift 2
  24. ;;
  25. --env|-e)
  26. ENV="$2"
  27. shift 2
  28. ;;
  29. --workdir|-w)
  30. if [ -n "$USE_DOCKER" ]; then
  31. if docker exec -u root -w /root gitian-target true > /dev/null 2>&1; then
  32. # newer docker version is strict about non-default-user working dir
  33. TWORKDIR="-w $2"
  34. fi
  35. shift 2
  36. else
  37. echo "unrecognized option $1"
  38. exit 1
  39. fi
  40. ;;
  41. --*)
  42. echo "unrecognized option $1"
  43. exit 1
  44. ;;
  45. *)
  46. break
  47. ;;
  48. esac
  49. done
  50. fi
  51. #if [ $# = 0 ] ; then
  52. # usage
  53. # exit 1
  54. #fi
  55. if [ -n "$USE_DOCKER" ]; then
  56. docker exec -u $TUSER $TWORKDIR -i gitian-target $*
  57. elif [ -z "$USE_LXC" ]; then
  58. ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT $TUSER@localhost $*
  59. else
  60. config-lxc
  61. sudo $LXC_EXECUTE -n gitian -f var/lxc.config -- sudo -u $TUSER $ENV -i -- $*
  62. fi