v3_init.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 /configs/.ssh ]]; then
  54. echo "dropbear ssh config dir present"
  55. umount /configs
  56. else
  57. echo "dropbear ssh config dir not present, creating"
  58. mkdir /configs/.ssh
  59. umount /configs
  60. fi
  61. echo "Run dropbear ssh server"
  62. /opt/wz_mini/bin/dropbearmulti dropbear -R -m
  63. { sleep 30; /media/mmc/wz_mini/run_mmc.sh 2> /media/mmc/wz_mini/log/wz_mini_hacks.log; } &
  64. /linuxrc