common.sh 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. shopt -s expand_aliases
  2. RELEASE_VERSION_TAG_NAME="release"
  3. kernel=$(uname -s)
  4. echo "[INFO] kernel: ${kernel}"
  5. case "${kernel}" in
  6. "Darwin")
  7. OS=MacOS
  8. alias fate_sed_cmd="sed -i ''"
  9. ;;
  10. "Linux")
  11. system=$(sed -e '/"/s/"//g' /etc/os-release | awk -F= '/^NAME/{print $2}')
  12. echo "[INFO] linux system: ${system}"
  13. case "${system}" in
  14. "CentOS Linux")
  15. OS=CentOS
  16. ;;
  17. "Ubuntu")
  18. OS=Ubuntu
  19. ;;
  20. *)
  21. echo "Not support this system."
  22. exit -1
  23. ;;
  24. esac
  25. alias fate_sed_cmd="sed -i"
  26. ;;
  27. *)
  28. echo "Not support this kernel."
  29. exit -1
  30. ;;
  31. esac
  32. echo "[INFO] os: ${OS}"
  33. if [[ $(id -u) -eq 0 ]]; then
  34. is_root=1
  35. echo "[INFO] is root user"
  36. else
  37. is_root=0
  38. echo "[INFO] not root user"
  39. fi