Advertisement
Sourgin

Arduino_Installerv0.2

Mar 28th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. #!/bin/bash
  2. # This script will install ARDUINO
  3. ### ###
  4.  
  5. # Install Arduino IDE #
  6. #####################################################################################
  7. function fun_install()
  8. {
  9. #Variables
  10. download="$1"
  11. directory="$2"
  12.  
  13. mkdir $directory/Arduino
  14. cd $directory/Arduino
  15. wget https://downloads.arduino.cc/arduino-${download}.tar.xz
  16. tar xvJf arduino-${download}.tar.xz
  17. cd arduino*/
  18. ./install.sh
  19. rm ../arduino-${download}.tar.xz
  20.  
  21. exit
  22. }
  23. ### ###
  24.  
  25. # Arduino IDE version #
  26. #####################################################################################
  27. function fun_version()
  28. {
  29. correct_platform=0
  30. plataform
  31. while [ $correct_platform -eq 0 ];
  32. do
  33. clear
  34. cat << HELP_ARDUINO_VERSION
  35. #####################################################################################
  36. What version would you like to install? First select the platform, then the version.
  37.  
  38. Example:
  39. $ Which plataform are you using? [1] 32 [2] 64 [3] ARM
  40. ~ 1
  41. $ Introduce the version number X.X.X or 0 for nightly
  42. ~ 1.8.0
  43. #####################################################################################
  44. HELP_ARDUINO_VERSION
  45.  
  46. cat << ARDUINO_PLATFORM
  47. 1/2##################################################################################
  48. Which plataform are you using?
  49. [1] ARM
  50. [2] 32
  51. [3] 64
  52. ##################################################################################1/2
  53. ARDUINO_PLATFORM
  54. read platformid
  55.  
  56. case $platformid in
  57. 1 ) platform=arm
  58. correct_platform=1
  59. ;;
  60. 2 ) arduino=32
  61. correct_platform=1
  62. ;;
  63. 3 ) arduino=64
  64. correct_platform=1
  65. ;;
  66. * ) echo "Please, select a valid platform"
  67. exit
  68. esac
  69.  
  70.  
  71. cat << ARDUINO_VERSION
  72. 2/2##################################################################################
  73. Introduce the version number X.X.X or 0 for nightly
  74. ##################################################################################2/2
  75. ARDUINO_VERSION
  76. read version
  77.  
  78. version_string="${version}-linux${platform}"
  79.  
  80. done
  81.  
  82. export "$version_string"
  83. }
  84. ### ###
  85.  
  86. # Arduino IDE directory #
  87. #####################################################################################
  88. function fun_directory()
  89. {
  90. clear
  91. echo "#####################################################################################"
  92. echo "Select directory to install arduino"
  93. echo "#####################################################################################"
  94. read directory
  95. export "$directory"
  96. }
  97. ### ###
  98.  
  99. # Display usage #
  100. #####################################################################################
  101. function fun_usage () {
  102. clear
  103. cat << HELP_USAGE
  104. START################################################################################
  105. # Program writed for 85 characters lenght #
  106. #####################################################################################
  107. # Usage: $0 [-v platform version] [-d directory] [-c platform version directory] #
  108. # #
  109. # -v : If you know what version you want to install EX i.sh -v arm 1.8.2 #
  110. # -d : If you know where to install EX i.sh -d . #
  111. # -c : If you know version and where EX i.sh -c arm 1.8.2 . #
  112. # #
  113. # If no parameter is chosen, the program will ask for them. #
  114. # #
  115. # Currently only -c is working, I will try to fix it for Thuersday #
  116. # (V)(;,,;)(V) #
  117. ##################################################################################END
  118. HELP_USAGE
  119. exit
  120. }
  121. ### ###
  122. # MAIN #
  123. #####################################################################################
  124. #Variables
  125. arduino=0
  126. platform=""
  127. version=""
  128. director=""
  129. download=""
  130.  
  131. if [ -n $1 ]
  132. then
  133. case $1 in
  134. -v ) arduino=1
  135. shift
  136. platform="$1"
  137. shift
  138. version="$1"
  139. download="${version}\-linux${platform}"
  140. ;;
  141. -w ) arduino=2
  142. shift
  143. directory="$1"
  144. ;;
  145. -c ) arduino=3
  146. shift
  147. platform="$1"
  148. shift
  149. version="$1"
  150. shift
  151. directory="$1"
  152. download="${version}\-linux${platform}"
  153. ;;
  154. * ) ;;
  155. esac
  156. fi
  157.  
  158. if [ $arduino != 3 ]
  159. then
  160. case arduino in
  161. 0 ) download=$(fun_version)
  162. directory=$(fun_directory)
  163. ;;
  164. 1 ) directory="$(fun_directory)"
  165. ;;
  166. 2 ) download="$(fun_version)"
  167. ;;
  168. esac
  169. fi
  170. fun_install $download $directory
  171. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement