install-debian.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. #
  3. # Install a VLMCSD service for Debian/Ubuntu
  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 '/usr/bin/wget' ]; then
  23. echo 'Installing wget ...'
  24. apt-get -qq update
  25. apt-get -qq install -y wget
  26. check_result $? "Can't install wget."
  27. echo 'Install wget succeed.'
  28. fi
  29. TMP_DIR=`mktemp -d`
  30. cd ${TMP_DIR}
  31. echo 'Downloading vlmcsd binaries ...'
  32. wget -q https://github.com/Wind4/vlmcsd/releases/download/svn1107/binaries.tar.gz -O binaries.tar.gz
  33. check_result $? 'Download vlmcsd failed.'
  34. echo 'Downloading startup script ...'
  35. wget -q https://wind4.github.io/vlmcsd/scripts/init.d/vlmcsd-debian -O vlmcsd.init
  36. check_result $? 'Download startup script failed.'
  37. echo 'Extract vlmcsd ...'
  38. tar zxf binaries.tar.gz
  39. cp binaries/Linux/intel/static/vlmcsd-x86-musl-static /usr/bin/vlmcsd
  40. cp vlmcsd.init /etc/init.d/vlmcsd
  41. echo 'Fix Permissions ...'
  42. chmod 755 /usr/bin/vlmcsd
  43. chown root.root /usr/bin/vlmcsd
  44. chmod 755 /etc/init.d/vlmcsd
  45. chown root.root /etc/init.d/vlmcsd
  46. echo 'Configuring deamon ...'
  47. update-rc.d vlmcsd defaults
  48. service vlmcsd start
  49. check_result $? 'Installation failed.'
  50. echo 'Cleaning ...'
  51. rm -rf ${TMP_DIR}
  52. echo 'Installed successfully.'