install-rhel.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. #
  3. # Install a VLMCSD service for CentOS/RedHat
  4. #
  5. # Author: Wind4 (puxiaping@gmail.com)
  6. # Date: November 30, 2015
  7. #
  8. check_result() {
  9. if [ $1 -ne 0 ]; then
  10. echo "Error: $2" >&2
  11. exit $1
  12. fi
  13. }
  14. if [ "x$(id -u)" != 'x0' ]; then
  15. echo 'Error: This script can only be executed by root'
  16. exit 1
  17. fi
  18. if [ -f '/etc/init.d/vlmcsd' ]; then
  19. echo 'VLMCSD service has been installed.'
  20. exit 1
  21. fi
  22. if [ ! -f '/bin/tar' ]; then
  23. echo 'Installing tar ...'
  24. yum -q -y install tar
  25. check_result $? "Can't install tar."
  26. echo 'Install tar succeed.'
  27. fi
  28. if [ ! -f '/usr/bin/wget' ]; then
  29. echo 'Installing wget ...'
  30. yum -q -y install wget
  31. check_result $? "Can't install wget."
  32. echo 'Install wget succeed.'
  33. fi
  34. if [ ! -f '/sbin/service' ]; then
  35. echo 'Installing initscripts ...'
  36. yum -q -y install initscripts
  37. check_result $? "Can't install initscripts."
  38. echo 'Install initscripts succeed.'
  39. fi
  40. TMP_DIR=`mktemp -d`
  41. GIT_TAG=svn1112
  42. cd ${TMP_DIR}
  43. echo 'Downloading vlmcsd ...'
  44. wget -q https://github.com/Wind4/vlmcsd/releases/download/${GIT_TAG}/binaries.tar.gz -O binaries.tar.gz
  45. check_result $? 'Download vlmcsd failed.'
  46. echo 'Downloading startup script ...'
  47. wget -q https://wind4.github.io/vlmcsd/scripts/init.d/vlmcsd-rhel -O vlmcsd.init
  48. check_result $? 'Download startup script failed.'
  49. echo 'Extract vlmcsd ...'
  50. tar zxf binaries.tar.gz
  51. cp binaries/Linux/intel/static/vlmcsd-x86-musl-static /usr/bin/vlmcsd
  52. cp vlmcsd.init /etc/init.d/vlmcsd
  53. echo 'Fix Permissions ...'
  54. chmod 755 /usr/bin/vlmcsd
  55. chown root.root /usr/bin/vlmcsd
  56. chmod 755 /etc/init.d/vlmcsd
  57. chown root.root /etc/init.d/vlmcsd
  58. echo 'Configuring deamon ...'
  59. chkconfig --add vlmcsd
  60. chkconfig vlmcsd on
  61. service vlmcsd start
  62. check_result $? 'Installation failed.'
  63. echo 'Cleaning ...'
  64. rm -rf ${TMP_DIR}
  65. echo 'Installed successfully.'