coffeesystem.sh 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #!/bin/bash
  2. #Item1 Common Command
  3. step1_t1=$(date +"%S")
  4. sudo apt-get install python3.8 -y
  5. sudo apt-get install python3-pip -y
  6. sudo pip3 install cryptography==3.3.2
  7. sudo -H pip3 install --upgrade pip
  8. sudo apt-get install grep -y
  9. sudo apt-get install git -y
  10. sudo pip3 install gitpython
  11. sudo apt-get install python3-tk -y
  12. sudo apt-get install wget -y
  13. sudo apt-get install python3-dev -y
  14. sudo apt-get install default-libmysqlclient-dev -y
  15. sudo apt-get install build-essential -y
  16. step1_t2=$(date +"%S")
  17. echo 'Item1 Common Command 安裝時間:' $((step1_t2-step1_t1)) '秒' >>/home/使用者/test.log
  18. #Item2 LAMP
  19. step2_t1=$(date +"%S")
  20. echo "start install LAMP"
  21. sudo apt-get install tasksel -y
  22. sudo DEBIAN_FRONTEND=noninteractive tasksel install lamp-server
  23. echo "install phpmyadmin"
  24. cd /tmp/;pwd;sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.tar.gz -q;tar -zxvf phpMyAdmin-5.1.0-all-languages.tar.gz;sudo rm phpMyAdmin-5.1.0-all-languages.tar.gz;sudo mv phpMyAdmin-5.1.0-all-languages /var/www/html/phpmyadmin
  25. cd /var/www/html/phpmyadmin;pwd;mkdir tmp;
  26. cd;pwd;
  27. echo "install phpmyadmin done"
  28. sudo apt-get install openssl -y
  29. sudo apt-get install php-common -y
  30. sudo apt-get install php-curl -y
  31. sudo apt-get install php-json -y
  32. sudo apt-get install php-mbstring -y
  33. sudo apt-get install php-mysql -y
  34. sudo apt-get install php-xml -y
  35. sudo apt-get install php-zip -y
  36. #php version
  37. sudo apt-get install php7.2-mbstring -y
  38. sudo apt-get install php7.2-xml -y
  39. sudo apt-get install php7.2-mysql -y
  40. sudo apt-get install php7.2-common -y
  41. sudo apt-get install php7.2-curl -y
  42. sudo apt-get install php7.2-json -y
  43. sudo apt-get install php7.2-zip -y
  44. echo "open apache2 "
  45. sudo service apache2 start
  46. echo "setting mysql pass"
  47. sudo mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Gold@53743001';"
  48. #user='root'
  49. #ip='localhost'
  50. #pwd='Gold@53743001'
  51. #sudo mysql -u root -e "ALTER USER $user@$ip IDENTIFIED WITH mysql_native_password BY $pwd;"
  52. step2_t2=$(date +"%S")
  53. echo 'Item2 LAMP 安裝時間:' $((step2_t2-step2_t1)) '秒' >>/home/使用者/test.log
  54. echo "setting mysql done"
  55. #Item3 MQTT
  56. # install&setting mqtt server
  57. step3_t1=$(date +"%S")
  58. sudo -H pip3 install paho-mqtt
  59. sudo apt-get install mosquitto -y
  60. sudo systemctl start mosquitto
  61. sudo ufw allow 1883/tcp
  62. sudo ufw allow 8080/tcp
  63. # get mqtt server file mosquitto.conf
  64. # get mqtt server file passwd.conf
  65. cd /home/使用者;pwd;sudo git clone -b mosquitto --single-branch http://60.250.156.230:3000/fatwolf/mqtt_server_setting.git /home/使用者/mosquitto/;sudo git clone -b passwd --single-branch http://60.250.156.230:3000/fatwolf/mqtt_server_setting.git /home/使用者/passwd/;sudo mv /home/使用者/mosquitto/mosquitto.conf /etc/mosquitto/;sudo mv /home/使用者/passwd/passwd /etc/mosquitto/;sudo rm -rf /home/使用者/mosquitto/;sudo rm -rf /home/使用者/passwd/;pwd
  66. sudo systemctl restart mosquitto
  67. step3_t2=$(date +"%S")
  68. echo 'Item3 MQTT 安裝時間:' $((step3_t2-step3_t1)) '秒' >>/home/使用者/test.log
  69. echo "mqtt server file done"
  70. # install&setting mqtt client
  71. # to be confirm packegs
  72. #cd /usr/sbin/
  73. # get mqtt client file aisky.mqttd
  74. #git clone http://60.250.156.230:3000/fatwolf/mqtt_server_setting.git
  75. #Item4 Watchdog
  76. # get watchdog file proc-wdtd.conf
  77. # get watchdog file proc-wdtd
  78. # get watchdog file rc.local
  79. step4_t1=$(date +"%S")
  80. cd /home/使用者;pwd;sudo git clone -b procwdtdconf --single-branch http://60.250.156.230:3000/fatwolf/proc.git /home/使用者/procwdtdconf/;sudo git clone -b procwdtd --single-branch http://60.250.156.230:3000/fatwolf/proc.git /home/使用者/procwdtd/;sudo git clone -b rclocal --single-branch http://60.250.156.230:3000/fatwolf/proc.git /home/使用者/rclocal/;sudo mv /home/使用者/procwdtdconf/proc-wdtd.conf /etc/;sudo mv /home/使用者/procwdtd/proc-wdtd /usr/sbin/;sudo mv /home/使用者/rclocal/rc.local /etc/;sudo rm -rf /home/使用者/procwdtdconf/;sudo rm -rf /home/使用者/procwdtd/;sudo rm -rf /home/使用者/rclocal/
  81. sudo chmod +x /usr/sbin/proc-wdtd
  82. sudo chmod +x /etc/rc.local
  83. sudo systemctl restart rc-local.service
  84. step4_t2=$(date +"%S")
  85. echo 'Item4 Watchdog 安裝時間:' $((step4_t2-step4_t1)) '秒' >>/home/使用者/test.log
  86. echo "watchdog file done"
  87. #Item5 Git Server
  88. step5_t1=$(date +"%S")
  89. sudo apt-get install golang -y
  90. cd /home/使用者;pwd;git clone http://60.250.156.230:3000/fatwolf/gogsfile.git /home/使用者/gogsfile;sudo mv /home/使用者/gogsfile/gogs_0.12.3_linux_amd64.tar.gz /home/使用者/;sudo rm -rf /home/使用者/gogsfile/;tar -C /home/使用者 -zxvf gogs_0.12.3_linux_amd64.tar.gz;sudo rm -rf /home/使用者/gogs_0.12.3_linux_amd64.tar.gz
  91. username=使用者;sudo echo 'gogs = "sudo /home/'$username'/gogs/./gogs web"'>>/etc/proc-wdtd.conf
  92. cd /home/使用者;pwd;sudo git clone http://60.250.156.230:3000/Automatic_build_system/git_mysql.git /home/使用者/gitsqlfile/
  93. mysql -u root -pGold@53743001 < "/home/使用者/gitsqlfile/git.sql";
  94. sudo rm -rf /home/使用者/gitsqlfile/
  95. cd /home/使用者;pwd;sudo git clone -b git_repo --single-branch http://60.250.156.230:3000/Automatic_build_system/git_mysql.git /home/使用者/gitmysql/
  96. cd /home/使用者/gitmysql/;pwd;sudo mv /home/使用者/gitmysql/gogs.tar.gz /home/使用者/;sudo mv /home/使用者/gitmysql/repo.tar.gz /home/使用者/
  97. cd /home/使用者;pwd;sudo tar -zxvf /home/使用者/gogs.tar.gz;sudo tar -zxvf /home/使用者/repo.tar.gz ;sudo mv /home/使用者/gitmysql/app.ini /home/使用者/gogs/custom/conf/
  98. sudo rm -rf /home/使用者/gitmysql;sudo rm -rf /home/使用者/gogs.tar.gz;sudo rm -rf /home/使用者/repo.tar.gz;sudo rm -rf /home/使用者/gitmysql
  99. cd /home/使用者/gogs/custom/conf/;pwd;sed -i "s/使_用_者/使用者/g" app.ini
  100. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/automatically_install_files.git
  101. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/bbend-test-jwt.git
  102. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/coffee_mysql.git
  103. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/coffeeproject.git
  104. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/git_mysql.git
  105. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/gogsfile.git
  106. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/mqtt_server_setting.git
  107. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/proc.git
  108. sudo git config --global --add safe.directory /home/使用者/gogs-repositories/admin1/sh.git
  109. step5_t2=$(date +"%S")
  110. echo 'Item5 Git Server 安裝時間:' $((step5_t2-step5_t1)) '秒' >>/home/使用者/test.log
  111. echo "Git Server done"
  112. #Item6 Python packegs Library
  113. step6_t1=$(date +"%S")
  114. cd /home/使用者;pwd;git clone -b package --single-branch http://60.250.156.230:3000/Automatic_build_system/Automatically_install_files.git;cd Automatically_install_files/;pwd;sudo pip3 install -r requirements.txt
  115. sudo rm -rf /home/使用者/Automatically_install_files/
  116. step6_t2=$(date +"%S")
  117. echo 'Item6 Python packegs Library 安裝時間:' $((step6_t2-step6_t1)) '秒' >>/home/使用者/test.log
  118. #Item7 AP(WebPage)
  119. step7_t1=$(date +"%S")
  120. cd /home/使用者;pwd;sudo git clone http://60.250.156.230:3000/rita/CoffeeProject.git /home/使用者/CoffeeProject/
  121. username=使用者;sudo echo 'coffee_manage.py = "sudo python3 /home/'$username'/CoffeeProject/coffee_manage.py"'>>/etc/proc-wdtd.conf
  122. cd /home/使用者;pwd;sudo git clone http://60.250.156.230:3000/rita/BBend-Test-JWT.git /home/使用者/BBend-Test-JWT/
  123. username=使用者;sudo echo 'BBend_manage.py = "sudo python3 /home/'$username'/BBend-Test-JWT/manage.py"'>>/etc/proc-wdtd.conf
  124. cd /home/使用者;pwd;sudo git clone http://60.250.156.230:3000/Automatic_build_system/Coffee_MySQL.git /home/使用者/Coffee_MySQL/
  125. mysql -u root -pGold@53743001 < "/home/使用者/Coffee_MySQL/Coffee_MySQL.sql";
  126. sudo rm -rf /home/使用者/Coffee_MySQL/
  127. step7_t2=$(date +"%S")
  128. echo 'Item7 AP(WebPage) 安裝時間:' $((step7_t2-step7_t1)) '秒' >>/home/使用者/test.log
  129. echo "AP done"
  130. #Item8 ROS ubuntu 18.04 melodic
  131. #ROS It should be install in user not install in root
  132. #install
  133. step8_t1=$(date +"%S")
  134. sudo apt-get install chrony -y
  135. sudo apt-get install ntpdate -y
  136. sudo ntpdate -q ntp.ubuntu.com
  137. #var="deb http://packages.ros.org/ros/ubuntu \$(lsb_release -sc) main"
  138. sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
  139. #sudo sh -c "echo $var > /etc/apt/sources.list.d/ros-latest.list"
  140. sudo apt-key adv --keyserver "hkp://keyserver.ubuntu.com:80" --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
  141. echo "deb ros packages and keyserver"
  142. sudo apt-get update -y
  143. #sudo apt-get upgrade -y
  144. sudo apt-get install ros-melodic-desktop-full -y
  145. sudo apt-get install ros-melodic-rqt* -y
  146. sudo apt-get install python-rosdep -y
  147. sudo rosdep init
  148. rosdep update
  149. sudo apt-get install python-rosinstall -y
  150. sudo apt-get install python-rosinstall-generator -y
  151. sudo apt-get install python-wstool -y
  152. #setup
  153. echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
  154. source ~/.bashrc
  155. #Create Ros Workspace
  156. mkdir -p /home/使用者/catkin_ws/src
  157. cd /home/使用者/catkin_ws/;pwd;source /opt/ros/melodic/setup.bash;/opt/ros/melodic/bin/catkin_make
  158. #Setup
  159. source /home/使用者/catkin_ws/devel/setup.bash
  160. echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
  161. source ~/.bashrc
  162. # need user name
  163. echo $ROS_PACKAGE_PATH /home/使用者/catkin_ws/src:/opt/ros/melodic/share
  164. source ~/.bashrc
  165. printenv | grep ROS
  166. step8_t2=$(date +"%S")
  167. echo 'Item8 ROS ubuntu 18.04 melodic 安裝時間:' $((step8_t2-step8_t1)) '秒' >>/home/使用者/test.log
  168. echo "ROS done"
  169. sudo reboot