脚本_安装程序.sh

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了脚本_安装程序.sh相关的知识,希望对你有一定的参考价值。

This is a simple script which downloads the latest "LoRa Server" files from the repository of the user brocaar in GitHub.
Just make the file executable with a "chmod +x script_installer.sh" and run it, the program will give you the latest releases of the main files according to your OS.
  1. #!/bin/bash
  2. clear screen
  3. echo "Choose your Opertaing System:"
  4. echo "1) Linux 32-bit"
  5. echo "2) Linux 64-bit"
  6. echo "3) Linux ARM"
  7. echo "4) MS Windows 32-bit"
  8. echo "5) MS Windows 64-bit"
  9. echo "6) Darwin OS"
  10. read OS
  11.  
  12. case $OS in
  13.  
  14. 1) echo "Linux 32-bit is selected"
  15. OS2=$"_linux_386.tar.gz"
  16. OS_Linux="yes"
  17. ;;
  18.  
  19. 2) echo "Linux 64-bit is selected"
  20. OS2=$"_linux_amd64.tar.gz"
  21. OS_Linux="yes"
  22. ;;
  23.  
  24. 3) echo "Linux ARM is selected"
  25. OS2=$"_linux_arm.tar.gz"
  26. OS_Linux="yes"
  27. ;;
  28.  
  29. 4) echo "MS Windows 32-bit is selected"
  30. OS2=$"_windows_386.tar.gz"
  31. OS_Linux="no"
  32. ;;
  33.  
  34. 5) echo "MS Windows 64-bit is selected"
  35. OS2=$"_windows_amd64.tar.gz"
  36. OS_Linux="no"
  37. ;;
  38.  
  39. 6) echo "Darwin OS is selected"
  40. OS2=$"_darwin_amd64.tar.gz"
  41. OS_Linux="no"
  42. ;;
  43.  
  44. *) echo "invalid option"
  45. exit
  46. ;;
  47.  
  48. esac
  49.  
  50. Link1=$(wget https://github.com/brocaar/loraserver/releases/latest > /dev/null 2>&1; cat latest | grep $OS2 | grep href)
  51. Link2=$(echo $Link1 | awk -F'" rel=' '{print $1}' | awk -F '="' '{print $2}')
  52. echo https://github.com${Link2}
  53. rm latest
  54. wget https://github.com${Link2}
  55.  
  56. Link1=$(wget https://github.com/brocaar/lora-gateway-bridge/releases/latest > /dev/null 2>&1; cat latest | grep $OS2 | grep href)
  57. Link2=$(echo $Link1 | awk -F'" rel=' '{print $1}' | awk -F '="' '{print $2}')
  58. echo https://github.com${Link2}
  59. rm latest
  60. wget https://github.com${Link2}
  61.  
  62. Link1=$(wget https://github.com/brocaar/lora-app-server/releases/latest > /dev/null 2>&1; cat latest | grep $OS2 | grep href)
  63. Link2=$(echo $Link1 | awk -F'" rel=' '{print $1}' | awk -F '="' '{print $2}')
  64. echo https://github.com${Link2}
  65. rm latest
  66. wget https://github.com${Link2}
  67.  
  68. for a in *.tar.gz; do echo working on $a; tar zxvf $a; done
  69. for b in *.tar.gz; do rm -v $b; done
  70.  
  71. if [ "$OS_Linux" = 'yes' ]; then
  72. echo "Linux files detected. Attempting giving executable permission..."
  73. chmod +x loraserver lora-gateway-bridge lora-app-server
  74. echo "Done."
  75. fi

以上是关于脚本_安装程序.sh的主要内容,如果未能解决你的问题,请参考以下文章

sh 一个片段,可以帮助您在rc脚本中找到“source”的时间成本

Shell脚本的书写规范与优秀的开发习惯

sh IBM Dev Tools安装程序脚本

shell脚本检测当前用户是否为超级管理员===checkRoot.sh

sh Bash脚本在Linux上安装SiS Mirage 3+图形驱动程序

sh Bash的代码片段