Skip to content

Instantly share code, notes, and snippets.

@akerl
Created April 5, 2020 17:29
Show Gist options
  • Save akerl/1047427e35d2d6e7f3741c406d1947a3 to your computer and use it in GitHub Desktop.
Save akerl/1047427e35d2d6e7f3741c406d1947a3 to your computer and use it in GitHub Desktop.
TeslaCam setup

Stage 0

  1. Create file "ssh" to enable SSH server
  2. Add "dtoverlay=dwc2" to end of /boot/config.txt
  3. Remove resize_init from cmdline.txt
  4. Create "wpa_supplicant.conf" with the following config:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
    ssid=""
    psk=""
    key_mgmt=WPA-PSK
}
country=US

Stage 1

  1. apt update
  2. apt upgrade -y
  3. apt install -y xfsprogs
  4. apt autoremove
  5. apt clean
  6. hostnamectl set-hostname dashcam
  7. timedatectl set-timezone UTC
  8. localectl set-locale en_US.UTF-8
  9. swapoff /var/swap
  10. rm /var/swap
  11. sed -i 's/$/ noswap fastboot/' /boot/cmdline.txt
  12. START="$(parted /dev/mmcblk0 unit s print free | awk '/Free Space/ { print $1 }' | tail -1)"
  13. parted -- /dev/mmcblk0 mkpart primary xfs "$START" -1s
  14. mkdir /mnt/storage
  15. echo "/dev/mmcblk0p3 /mnt/storage xfs defaults 0 2" >> /etc/fstab
  16. mkfs.xfs /dev/mmcblk0p3
  17. fallocate -l 10G /mnt/storage/cam
  18. losetup -fP /mnt/storage/cam
  19. echo "type=c" | sfdisk /dev/loop0
  20. mkfs.vfat /dev/loop0p1 -F 32 -n CAM
  21. mkdir /mnt/cam
  22. mount /dev/loop0p1 /mnt/cam
  23. mkdir -p /mnt/cam/TeslaCam
  24. touch /mnt/cam/.metadata_never_index
  25. umount /mnt/cam
  26. losetup -d /dev/loop0
  27. echo "options g_mass_storage file=/mnt/storage/cam removable=1 ro=0 stall=0 iSerialNumber=123456" > /etc/modprobe.d/g_mass_storage.conf
  28. Create /etc/systemd/system/export.service as shown below:
[Unit]
Description=Setup foo
After=mnt-storage.mount

[Service]
Type=oneshot
ExecStart=modprobe g_mass_storage
RemainAfterExit=true
ExecStop=modprobe -r g_mass_storage
StandardOutput=journal

[Install]
WantedBy=multi-user.target

Stage X

  1. Enable auto-updates/upgrades for packages
  2. Slack notifications for health alerts
  3. Slack notifications for saved clips
  4. Remove unneeded packages
  5. Make rootfs read-only
  6. Upload clips
  7. Update password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment