Support for music in addition to dashcam clip storage.

This commit is contained in:
cimryan
2018-10-13 18:18:00 -07:00
parent 9cfce11bd4
commit a03c322c01
4 changed files with 39 additions and 15 deletions

View File

@@ -126,16 +126,17 @@ Now that you have a shell on the Pi you can turn the Pi into a smart USB drive.
ping 192.168.0.41 ping 192.168.0.41
``` ```
1. If you can't ping the archive server by IP address from the Pi you should go do whatever you need to on your network to fix that. If you can't reach the archive server by name from the Pi but you can by IP address then use its IP address, below, in place of its name. 1. If you can't ping the archive server by IP address from the Pi you should go do whatever you need to on your network to fix that. If you can't reach the archive server by name from the Pi but you can by IP address then use its IP address, below, in place of its name.
1. Run these commands, subsituting your values: 1. Run these commands, subsituting your values. The last line is the percent of the drive you want to allocate for dashcam storage. The remaining percentage will be allocated for music.
``` ```
export archiveserver=Nautilus export archiveserver=Nautilus
export sharename=SailfishCam export sharename=SailfishCam
export shareuser=sailfish export shareuser=sailfish
export sharepassword=pa$$w0rd export sharepassword=pa$$w0rd
epxort campercent=100
``` ```
1. Run these commands: 1. Run these commands:
``` ```
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/setup-teslausb wget https://raw.githubusercontent.com/cimryan/teslausb/u/cimryan/music/windows_archive/setup-teslausb
chmod +x setup-teslausb chmod +x setup-teslausb
./setup-teslausb ./setup-teslausb
``` ```

View File

@@ -1 +0,0 @@
options g_mass_storage file=/piusb.bin removable=1 ro=0 stall=0 iSerialNumber=123456

View File

@@ -124,4 +124,4 @@ move_clips_to_archive
unmount_cam_drive unmount_cam_drive
connect_usb_to_host connect_usb_drives_to_host

View File

@@ -19,6 +19,7 @@ check_variable "archiveserver"
check_variable "sharename" check_variable "sharename"
check_variable "shareuser" check_variable "shareuser"
check_variable "sharepassword" check_variable "sharepassword"
check_variable "campercent"
serverunreachable=false serverunreachable=false
ping -c 1 -w 1 "$archiveserver" 1>/dev/null 2>&1 || serverunreachable=true ping -c 1 -w 1 "$archiveserver" 1>/dev/null 2>&1 || serverunreachable=true
@@ -31,26 +32,38 @@ fi
archiveserverip="$(getent hosts $archiveserver | cut -d' ' -f1)" archiveserverip="$(getent hosts $archiveserver | cut -d' ' -f1)"
size="$(($(df --output=avail / | tail -1) - 1000000))" available_space="$(($(df --output=avail / | tail -1) - 1000000))"
if [ "$size" -lt 0 ]
if [ "$available_space" -lt 0 ]
then then
echo "STOP: The MicroSD card is too small." echo "STOP: The MicroSD card is too small."
exit 1 exit 1
fi fi
function add_drive () {
local name="$1"
local label="$2"
local size="$3"
local filename="$4"
fallocate -l "$size"K "$filename"
mkfs.vfat "$filename" -F 32 -n "$label"
local mountpoint=/mnt/"$name"
mkdir "$mountpoint"
echo "$filename $mountpoint vfat noauto,users,umask=000 0 0" >> /etc/fstab
}
pushd ~ pushd ~
cp /boot/cmdline.txt ~ cp /boot/cmdline.txt ~
cat ~/cmdline.txt | sed 's/[[:space:]]\+modules-load=[^ [:space:]]\+//' | sed 's/rootwait/rootwait modules-load=dwc2/' > /boot/cmdline.txt cat ~/cmdline.txt | sed 's/[[:space:]]\+modules-load=[^ [:space:]]\+//' | sed 's/rootwait/rootwait modules-load=dwc2/' > /boot/cmdline.txt
rm ~/cmdline.txt rm ~/cmdline.txt
fallocate -l "$size"K /piusb.bin
mkfs.vfat /piusb.bin -F 32 -n CAM
mkdir /mnt/cam
mkdir /mnt/archive mkdir /mnt/archive
echo "" >> /etc/fstab echo "" >> /etc/fstab
echo "/piusb.bin /mnt/cam vfat noauto,users,umask=000,debug 0 0" >> /etc/fstab
echo "//$archiveserverip/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab echo "//$archiveserverip/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab
echo "username=$shareuser" > /root/.teslaCamArchiveCredentials echo "username=$shareuser" > /root/.teslaCamArchiveCredentials
@@ -58,13 +71,13 @@ echo "password=$sharepassword" >> /root/.teslaCamArchiveCredentials
mkdir /root/bin mkdir /root/bin
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/archiveloop wget https://raw.githubusercontent.com/cimryan/teslausb/u/cimryan/music/windows_archive/archiveloop
sed s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/ ~/archiveloop > /root/bin/archiveloop sed s/ARCHIVE_HOST_NAME=archiveserver/ARCHIVE_HOST_NAME=$archiveserver/ ~/archiveloop > /root/bin/archiveloop
rm ~/archiveloop rm ~/archiveloop
chmod +x /root/bin/archiveloop chmod +x /root/bin/archiveloop
pushd /root/bin pushd /root/bin
wget https://raw.githubusercontent.com/cimryan/teslausb/master/windows_archive/archive-teslacam-clips wget https://raw.githubusercontent.com/cimryan/teslausb/u/cimryan/music/windows_archive/archive-teslacam-clips
chmod +x archive-teslacam-clips chmod +x archive-teslacam-clips
popd popd
@@ -87,9 +100,20 @@ EOF
cat ~/rc.local > /etc/rc.local cat ~/rc.local > /etc/rc.local
rm ~/rc.local rm ~/rc.local
pushd /etc/modprobe.d cam_disk_size="$(( $available_space * $campercent / 100 ))"
wget https://raw.githubusercontent.com/cimryan/teslausb/master/g_mass_storage.conf cam_disk_file_name="/cam_disk.bin"
popd add_drive "cam" "CAM" "$cam_disk_size" "$cam_disk_file_name"
if [ "$campercent" -lt 100 ]
then
musicpercent=$$(( 100 - $campercent ))
music_disk_size="$(( $available_space * $musicpercent / 100 ))"
music_disk_file_name="/music_disk.bin"
add_drive "music" "MUSIC" "$music_disk_size" "$music_disk_file_name"
echo "options g_mass_storage file=$cam_disk_file_name,$music_disk_file_name removable=1,1 ro=0,0 stall=0 iSerialNumber=123456" > /etc/modprobe.d/g_mass_storage.conf
else
echo "options g_mass_storage file=$cam_disk_file_name removable=1 ro=0 stall=0 iSerialNumber=123456" > /etc/modprobe.d/g_mass_storage.conf
fi
cp /etc/hosts ~ cp /etc/hosts ~
sed s/raspberrypi/teslausb/g ~/hosts > /etc/hosts sed s/raspberrypi/teslausb/g ~/hosts > /etc/hosts