coffeesystem.sh 7.3 KB

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