mod-deploy.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. set -e
  3. cd $(dirname ${0})
  4. if ping -c 1 -W 0.05 192.168.51.1 > /dev/null; then
  5. TARGET=root@192.168.51.1
  6. elif ping -c 1 -W 0.2 moddwarf.local > /dev/null; then
  7. TARGET=root@moddwarf.local
  8. elif ping -c 1 -W 0.2 modduox.local > /dev/null; then
  9. TARGET=root@modduox.local
  10. elif ping -c 1 -W 0.2 modduo.local > /dev/null; then
  11. TARGET=root@modduo.local
  12. else
  13. echo "not connected"
  14. exit 1
  15. fi
  16. # needed since ssh rsa deprecation/breakage
  17. SSH_OPTIONS="-o PubkeyAcceptedAlgorithms=+ssh-rsa"
  18. SCP_OPTIONS="${SSH_OPTIONS} -O"
  19. ssh ${SSH_OPTIONS} ${TARGET} mount / -o remount,rw
  20. ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/share/mod/html/css
  21. ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/share/mod/html/js
  22. ssh ${SSH_OPTIONS} ${TARGET} mkdir -p /usr/share/mod/html/css/fontello/{css,font} /usr/share/mod/html/js/{lib/slick/fonts,utils}
  23. ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.*/site-packages/mod/*.py*
  24. ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.*/site-packages/mod/communication/*.py*
  25. ssh ${SSH_OPTIONS} ${TARGET} rm -f /usr/lib/python3.*/site-packages/modtools/*.py*
  26. scp ${SCP_OPTIONS} html/*.html ${TARGET}:/usr/share/mod/html/
  27. scp ${SCP_OPTIONS} html/include/*.html ${TARGET}:/usr/share/mod/html/include/
  28. scp ${SCP_OPTIONS} html/resources/*.html ${TARGET}:/usr/share/mod/html/resources/
  29. scp ${SCP_OPTIONS} html/css/*.css ${TARGET}:/usr/share/mod/html/css/
  30. scp ${SCP_OPTIONS} html/css/fontello/css/*.css ${TARGET}:/usr/share/mod/html/css/fontello/css/
  31. scp ${SCP_OPTIONS} html/css/fontello/font/*.* ${TARGET}:/usr/share/mod/html/css/fontello/font/
  32. scp ${SCP_OPTIONS} html/js/*.js ${TARGET}:/usr/share/mod/html/js/
  33. scp ${SCP_OPTIONS} html/js/lib/*.js ${TARGET}:/usr/share/mod/html/js/lib/
  34. scp ${SCP_OPTIONS} html/js/lib/slick/*.{css,gif} ${TARGET}:/usr/share/mod/html/js/lib/slick/
  35. scp ${SCP_OPTIONS} html/js/lib/slick/*min.js ${TARGET}:/usr/share/mod/html/js/lib/slick/
  36. scp ${SCP_OPTIONS} html/js/lib/slick/fonts/*.* ${TARGET}:/usr/share/mod/html/js/lib/slick/fonts/
  37. scp ${SCP_OPTIONS} html/js/utils/*.js ${TARGET}:/usr/share/mod/html/js/utils/
  38. scp ${SCP_OPTIONS} html/img/*.png ${TARGET}:/usr/share/mod/html/img/
  39. scp ${SCP_OPTIONS} html/img/*.svg ${TARGET}:/usr/share/mod/html/img/
  40. scp ${SCP_OPTIONS} mod/*.py ${TARGET}:/usr/lib/python3.*/site-packages/mod/
  41. scp ${SCP_OPTIONS} mod/communication/*.py ${TARGET}:/usr/lib/python3.*/site-packages/mod/communication/
  42. scp ${SCP_OPTIONS} modtools/*.py ${TARGET}:/usr/lib/python3.*/site-packages/modtools/
  43. ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.*/site-packages/mod/__pycache__
  44. ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.*/site-packages/mod/communication/__pycache__
  45. ssh ${SSH_OPTIONS} ${TARGET} rm -rf /usr/lib/python3.*/site-packages/modtools/__pycache__
  46. echo "all ok"