Maurizio4pastebin

git_clone_trueos_src.sh

Oct 9th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.72 KB | None | 0 0
  1. #!/bin/sh
  2. set -xu
  3. src_dir="/usr/src"
  4.  
  5. if test "$(id -u)" != "0"
  6. then
  7.     echo "Error: this script must be run as root."
  8.     exit 1
  9. fi
  10.  
  11. git_revision=$(uname -v | cut -d'#' -f2 | cut -d' ' -f2 | cut -d'(' -f1)
  12. if test -z "$git_revision"
  13. then
  14.     echo "Error: unable to detect TrueOS git revision."
  15.     exit 1
  16. fi
  17.  
  18. git_branch=$(uname -v | cut -d'#' -f2 | cut -d' ' -f2 | cut -d'(' -f2 | cut -d')' -f1)
  19. if test -z "$git_branch"
  20. then
  21.     echo "Error: unable to detect TrueOS git branch."
  22.     exit 1
  23. fi
  24.  
  25. if test -z "$(ls -A /usr/src)"
  26. then
  27.     mkdir -p "$src_dir"
  28.     if ! git clone -b "$git_branch" https://github.com/trueos/freebsd "$src_dir"
  29.     then
  30.         exit 1
  31.     fi
  32. fi
  33.  
  34. if cd "$src_dir"
  35. then
  36.     git checkout "$git_revision"
  37. fi
  38. set +xu
Advertisement
Add Comment
Please, Sign In to add comment