funcs.sh 632 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. check_util() {
  3. util_name="$1"
  4. check=`whereis $util_name`
  5. if [ "$check" = "" ]; then
  6. echo "Error: '$util_name' is not found... Fix error and try again!"
  7. exit
  8. fi
  9. }
  10. get_util() {
  11. util_name="$1"
  12. IS_MAC_OS=`uname -a | grep Darwin`
  13. if [ "$IS_MAC_OS" != "" ]; then
  14. # Mac OS X
  15. resp=`whereis $util_name | awk {'print $1'}`
  16. eval "$2='$resp'"
  17. return
  18. else
  19. # Linux
  20. resp=`whereis $util_name | awk {'print $2'}`
  21. eval "$2='$resp'"
  22. return
  23. fi
  24. eval "$2=''"
  25. return
  26. }
  27. is_pid_runned() {
  28. resp=`ps aux | grep ".sh start" | grep $1`
  29. if [ "$resp" != "" ]; then
  30. eval "$2='1'"
  31. else
  32. eval "$2='0'"
  33. fi
  34. return
  35. }