diff --git a/70_installation/3_Raspbian.md b/70_installation/3_Raspbian.md index cfa1b00..927de76 100644 --- a/70_installation/3_Raspbian.md +++ b/70_installation/3_Raspbian.md @@ -8,6 +8,7 @@ * [Web](#web) * [Install webserver + PHP (optional)](#web-installation-webserver) * [Install source](#web-installation-source) +* [Auto removal](#auto-removal) @@ -127,3 +128,36 @@ Change write permission on the storage directory. Reboot sudo reboot + + +## Auto removal + +By default images or videos **aren't removed automatically**. This means that Kerberos.io will keep writing to disk, even if there is no more space available on your SD card. When your **SD card is full** you'll be **experiencing strange errors**: a corrupt web interface, blank images or corrupt videos. + +To resolve this your should install a simple **bash script** and initiate **a cronjob** which continuously poll your filesystem, and start removing media when your disk is getting full. + +Create a bash script and copy following script. + + nano /home/pi/autoremoval.sh + +Copy following script (make sure the partition is correct, this is the default one for a Raspberry Pi). + + partition=/dev/mmcblk0p1 + imagedir=/etc/opt/kerberosio/capture/ + if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; + then + echo "Cleaning disk" + find $imagedir -type f | sort | head -n 100 | xargs -r rm -rf; + fi; + +Make the script executable. + + chmod +x /home/pi/autoremoval.sh + +Initiate a cronjob, and select the **nano** editor. + + crontab -e + +Append following line, to execute the **autoremoval.sh** script every 5min. + + */5 * * * * /bin/bash /home/pi/autoremoval.sh diff --git a/70_installation/4_Armbian.md b/70_installation/4_Armbian.md index e33d7de..a6e789d 100644 --- a/70_installation/4_Armbian.md +++ b/70_installation/4_Armbian.md @@ -8,6 +8,7 @@ * [Web](#web) * [Install webserver + PHP (optional)](#web-installation-webserver) * [Install source](#web-installation-source) +* [Auto removal](#auto-removal) @@ -119,3 +120,36 @@ Change write permission on the storage directory. Reboot sudo reboot + + +## Auto removal + +By default images or videos **aren't removed automatically**. This means that Kerberos.io will keep writing to disk, even if there is no more space available on your SD card. When your **SD card is full** you'll be **experiencing strange errors**: a corrupt web interface, blank images or corrupt videos. + +To resolve this your should install a simple **bash script** and initiate **a cronjob** which continuously poll your filesystem, and start removing media when your disk is getting full. + +Create a bash script and copy following script. + + nano /home/pi/autoremoval.sh + +Copy following script (make sure the partition is correct, this is the default one for a Raspberry Pi). + + partition=/dev/mmcblk0p1 + imagedir=/etc/opt/kerberosio/capture/ + if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; + then + echo "Cleaning disk" + find $imagedir -type f | sort | head -n 100 | xargs -r rm -rf; + fi; + +Make the script executable. + + chmod +x /home/pi/autoremoval.sh + +Initiate a cronjob, and select the **nano** editor. + + crontab -e + +Append following line, to execute the **autoremoval.sh** script every 5min. + + */5 * * * * /bin/bash /home/pi/autoremoval.sh