update.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #version: 2024.03.16
  2. import os
  3. import time
  4. time.sleep(1)
  5. #关闭全部应用
  6. print("Close app!")
  7. os.system("touch /tmp/disable")
  8. #获取/root/下所有文件最高操作权限
  9. print("Get root authority!")
  10. os.system("sync")
  11. os.system("chmod 777 /root/")
  12. try:
  13. print("Start remove /root/CocoPi_intro_manual.pdf!")
  14. os.system("rm /root/CocoPi_intro_manual.pdf")
  15. print("remove /root/CocoPi_intro_manual.pdf successful!")
  16. except:
  17. print("remove /root/CocoPi_intro_manual.pdf failed!")
  18. try:
  19. print("Start remove /root/CocoPi_intro_manual.html!")
  20. os.system("rm /root/CocoPi_intro_manual.html")
  21. print("remove /root/CocoPi_intro_manual.html successful!")
  22. except:
  23. print("remove /root/CocoPi_intro_manual.html failed!")
  24. try:
  25. print("Start remove /root/main.py!")
  26. os.system("rm /root/main.py")
  27. print("remove /root/main.py successful!")
  28. except:
  29. print("remove /root/main.py failed!")
  30. try:
  31. print("Start remove /root/CocoPi.py!")
  32. os.system("rm /root/CocoPi.py")
  33. print("remove /root/CocoPi.py successful!")
  34. except:
  35. print("remove /root/CocoPi.py failed!")
  36. try:
  37. print("Start remove /home/backup/CocoPi.py!")
  38. os.system("rm /home/backup/CocoPi.py")
  39. print("remove /home/backup/CocoPi.py successful!")
  40. except:
  41. print("remove /home/backup/CocoPi.py failed!")
  42. try:
  43. print("Start remove /home/backup/main.py!")
  44. os.system("rm /home/backup/main.py")
  45. print("remove /home/backup/main.py successful!")
  46. except:
  47. print("remove /home/backup/main.py failed!")
  48. try:
  49. print("Start remove /home/backup/CocoPi_intro_manual.html!")
  50. os.system("rm /home/backup/CocoPi_intro_manual.html")
  51. print("remove /home/backup/CocoPi_intro_manual.html successful!")
  52. except:
  53. print("remove /home/backup/CocoPi_intro_manual.html failed!")
  54. try:
  55. print("Start remove /home/backup/CocoPi_intro_manual.pdf!")
  56. os.system("rm /home/backup/CocoPi_intro_manual.pdf")
  57. print("remove /home/backup/CocoPi_intro_manual.pdf successful!")
  58. except:
  59. print("remove /home/backup/CocoPi_intro_manual.pdf failed!")
  60. try:
  61. print("Start remove /home/backup/readme.txt!")
  62. os.system("rm /home/backup/readme.txt")
  63. print("remove /home/backup/readme.txt successful!")
  64. except:
  65. print("remove /home/backup/readme.txt failed!")
  66. try:
  67. print("Start remove /home/backup/user_latest_code.png!")
  68. os.system("rm /home/backup/user_latest_code.png")
  69. print("remove /home/backup/user_latest_code.png successful!")
  70. except:
  71. print("remove /home/backup/user_latest_code.png failed!")
  72. try:
  73. print("Start remove /home/backup/user_latest_code.xml!")
  74. os.system("rm /home/backup/user_latest_code.xml")
  75. print("remove /home/backup/user_latest_code.xml successful!")
  76. except:
  77. print("remove /home/backup/user_latest_code.xml failed!")
  78. try:
  79. print("Start remove /home/backup/user_latest_code.py!")
  80. os.system("rm /home/backup/user_latest_code.py")
  81. print("remove /home/backup/user_latest_code.py successful!")
  82. except:
  83. print("remove /home/backup/user_latest_code.py failed!")
  84. try:
  85. print("Start remove /home/backup/preset/!")
  86. os.system("rm -r /home/backup/preset/")
  87. print("remove /home/backup/preset/ successful!")
  88. except:
  89. print("remove /home/backup/preset/ failed!")
  90. try:
  91. print("Start remove /home/backup/user/!")
  92. os.system("rm -r /home/backup/user/")
  93. print("remove /home/backup/user/ successful!")
  94. except:
  95. print("remove /home/backup/user/ failed!")
  96. try:
  97. print("Start remove /etc/banner!")
  98. os.system("rm /etc/banner")
  99. print("remove /etc/banner successful!")
  100. except:
  101. print("remove /etc/banner failed!")
  102. try:
  103. print("Start copy /root/CocoPi.pyc /home/backup/CocoPi.pyc!")
  104. os.system("cp /root/CocoPi.pyc /home/backup/CocoPi.pyc")
  105. print("copy /root/CocoPi.pyc /home/backup/CocoPi.pyc successful!")
  106. except:
  107. print("copy /root/CocoPi.pyc /home/backup/CocoPi.pyc failed!")
  108. try:
  109. print("Start move /root/main1.py /root/main.py!")
  110. os.system("mv /root/main1.py /root/main.py")
  111. print("move /root/main1.py /root/main.py successful!")
  112. except:
  113. print("move /root/main1.py /root/main.py failed!")
  114. try:
  115. print("Start copy /root/main.py /home/backup/main.py!")
  116. os.system("cp /root/main.py /home/backup/main.py")
  117. print("copy /root/main.py /home/backup/main.py successful!")
  118. except:
  119. print("copy /root/main.py /home/backup/main.py failed!")
  120. try:
  121. print("Start move /root/banner /etc/banner!")
  122. os.system("mv /root/banner /etc/banner")
  123. print("move /root/banner /etc/banner successful!")
  124. except:
  125. print("move /root/banner /etc/banner failed!")
  126. #升级摄像头固件
  127. try:
  128. print("Start update camera fireware!")
  129. os.system("update_dtb /dev/mmcblk0 /root/CR5205.dtb")
  130. print("Update camera fireware successfully!")
  131. except:
  132. print("Update camera fireware failed!")
  133. pass
  134. print("Update camera fireware completed!")
  135. #更新摄像头配置
  136. try:
  137. print("Start update camera cfg!")
  138. os.system("mv /root/libisp_ini.so /usr/lib/eyesee-mpp/libisp_ini.so")
  139. print("Update camera cfg successfully!")
  140. except:
  141. print("Update camera cfg failed!")
  142. pass
  143. print("Update camera cfg completed!")
  144. #删除摄像头升级文件
  145. try:
  146. print("Start remove camera fireware!")
  147. os.system("rm /root/CR5205.dtb")
  148. print("Remove update files successfully!")
  149. except:
  150. print("Remove update files failed!")
  151. pass
  152. print("Remove update files completed!")
  153. #创建摄像头型号文件
  154. try:
  155. print("Start touch camera cfg!")
  156. os.system("touch /etc/cameraSize.cfg")
  157. print("Touch camera cfg successfully!")
  158. except:
  159. print("touch camera cfg failed!")
  160. pass
  161. print("Touch camera cfg completed!")
  162. print("update completed! !")
  163. os.system("sync && reboot")