v3_init.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. ###
  3. ###DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING
  4. ###
  5. echo '
  6. __ ________ __ __ _____ _ _ _____
  7. \ \ / |___ / | \/ |_ _| \ | |_ _|
  8. \ \ /\ / / / / | \ / | | | | \| | | |
  9. \ \/ \/ / / / | |\/| | | | | . ` | | |
  10. \ /\ / / /__ | | | |_| |_| |\ |_| |_
  11. \/ \/ /_____| |_| |_|_____|_| \_|_____|
  12. ______
  13. |______|
  14. '
  15. set -x
  16. echo "mounting tempfs for workspace"
  17. mount -t tmpfs /tmp
  18. mount -t tmpfs /run
  19. echo "create workspace directory"
  20. mkdir /run/.storage
  21. if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_ENABLED\=") == "RTSP_ENABLED\=\"true\"" ]]; then
  22. cp /etc/init.d/rcS /run/.storage/rcS
  23. sed -i '/^".*/aset -x' /run/.storage/rcS
  24. sed -i '/^# Mount configs.*/i cp /system/bin/iCamera /run/.storage/\nmount -o ro,bind /opt/wz_mini/usr/bin/iCamera /system/bin/iCamera\n tail -f /system/bin/iCamera > /dev/null 2>&1 &' /run/.storage/rcS
  25. sed -i '/sbin:/s/$/:\/opt\/wz_mini\/bin/' /run/.storage/rcS
  26. sed -i '/system\/\lib/s/$/:\/opt\/wz_mini\/lib/' /run/.storage/rcS
  27. mount --bind /run/.storage/rcS /etc/init.d/rcS
  28. echo "load video loopback driver at video1"
  29. insmod /opt/wz_mini/lib/modules/v4l2loopback.ko video_nr=1
  30. fi
  31. if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "DEBUG_ENABLED\=") == "DEBUG_ENABLED\=\"true\"" ]]; then
  32. cp /etc/init.d/rcS /run/.storage/rcS
  33. sed -i '/app_init.sh/,+2d' /run/.storage/rcS
  34. sed -i '/^# Run init/i/bin/sh /etc/profile' /run/.storage/rcS
  35. mount --bind /run/.storage/rcS /etc/init.d/rcS
  36. fi
  37. echo "replace stock password"
  38. cp /opt/wz_mini/etc/shadow /run/.storage/shadow
  39. mount --bind /run/.storage/shadow /etc/shadow
  40. chmod 400 /etc/shadow
  41. echo "bind /etc/profile for local/ssh shells"
  42. mount --bind /opt/wz_mini/etc/profile /etc/profile
  43. if [[ -f /opt/wz_mini/swap.gz ]]; then
  44. echo "swap archive present, extracting"
  45. gzip -d /opt/wz_mini/swap.gz
  46. mkswap /opt/wz_mini/swap
  47. sync;echo 3 > /proc/sys/vm/drop_caches;free
  48. else
  49. echo "swap archive not present, not extracting"
  50. fi
  51. echo "mount configs partition for dropbear"
  52. mount -t jffs2 /dev/mtdblock6 /configs
  53. if [[ -d /opt/wz_mini/usr/share/terminfo ]]; then
  54. echo "terminfo already present"
  55. else
  56. echo "terminfo not present, extract"
  57. tar xf /opt/wz_mini/usr/share/terminfo.tar -C /opt/wz_mini/usr/share/
  58. fi
  59. if [[ -d /configs/.ssh ]]; then
  60. echo "dropbear ssh config dir present"
  61. umount /configs
  62. else
  63. echo "dropbear ssh config dir not present, creating"
  64. mkdir /configs/.ssh
  65. umount /configs
  66. fi
  67. echo "Run dropbear ssh server"
  68. /opt/wz_mini/bin/dropbearmulti dropbear -R -m
  69. { sleep 30; /media/mmc/wz_mini/run_mmc.sh 2> /media/mmc/wz_mini/log/wz_mini_hacks.log; } &
  70. /linuxrc