From 87446d8a0dfdf49fde423efaa69c3558b9ff6532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Verstraeten?= Date: Wed, 2 Aug 2017 10:45:03 +0200 Subject: [PATCH 1/4] add auto-removal process --- 70_installation/3_Raspbian.md | 33 +++++++++++++++++++++++++++++++++ 70_installation/4_Armbian.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/70_installation/3_Raspbian.md b/70_installation/3_Raspbian.md index cfa1b00..6025d9e 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,35 @@ 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 continiously 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 + if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; + then + echo "Cleaning disk" + find /etc/opt/kerberosio/capture/ -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..56049f6 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,35 @@ 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 continiously 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 + if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; + then + echo "Cleaning disk" + find /etc/opt/kerberosio/capture/ -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 From f24d915bfaf176170552d91e356aaf122a068d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Verstraeten?= Date: Wed, 2 Aug 2017 10:47:22 +0200 Subject: [PATCH 2/4] add indent for code snippet --- 70_installation/3_Raspbian.md | 16 ++++++++-------- 70_installation/4_Armbian.md | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/70_installation/3_Raspbian.md b/70_installation/3_Raspbian.md index 6025d9e..f5596c7 100644 --- a/70_installation/3_Raspbian.md +++ b/70_installation/3_Raspbian.md @@ -138,25 +138,25 @@ To resolve this your should install a simple **bash script** and initiate **a cr Create a bash script and copy following script. - nano /home/pi/autoremoval.sh + 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 - if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; - then + partition=/dev/mmcblk0p1 + if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; + then echo "Cleaning disk" find /etc/opt/kerberosio/capture/ -type f | sort | head -n 100 | xargs -r rm -rf; - fi; + fi; Make the script executable. - chmod +x /home/pi/autoremoval.sh + chmod +x /home/pi/autoremoval.sh Initiate a cronjob, and select the **nano** editor. - crontab -e + crontab -e Append following line, to execute the **autoremoval.sh** script every 5min. - */5 * * * * /bin/bash /home/pi/autoremoval.sh + */5 * * * * /bin/bash /home/pi/autoremoval.sh diff --git a/70_installation/4_Armbian.md b/70_installation/4_Armbian.md index 56049f6..11d12a5 100644 --- a/70_installation/4_Armbian.md +++ b/70_installation/4_Armbian.md @@ -130,25 +130,25 @@ To resolve this your should install a simple **bash script** and initiate **a cr Create a bash script and copy following script. - nano /home/pi/autoremoval.sh + 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 - if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; - then + partition=/dev/mmcblk0p1 + if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]]; + then echo "Cleaning disk" find /etc/opt/kerberosio/capture/ -type f | sort | head -n 100 | xargs -r rm -rf; - fi; + fi; Make the script executable. - chmod +x /home/pi/autoremoval.sh + chmod +x /home/pi/autoremoval.sh Initiate a cronjob, and select the **nano** editor. - crontab -e + crontab -e Append following line, to execute the **autoremoval.sh** script every 5min. - */5 * * * * /bin/bash /home/pi/autoremoval.sh + */5 * * * * /bin/bash /home/pi/autoremoval.sh From df4c7b25047fe1abc84877aea2aed0ac8e5a4f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Verstraeten?= Date: Wed, 2 Aug 2017 10:48:30 +0200 Subject: [PATCH 3/4] replace var --- 70_installation/3_Raspbian.md | 3 ++- 70_installation/4_Armbian.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/70_installation/3_Raspbian.md b/70_installation/3_Raspbian.md index f5596c7..8f8ad6c 100644 --- a/70_installation/3_Raspbian.md +++ b/70_installation/3_Raspbian.md @@ -143,10 +143,11 @@ Create a bash script and copy following script. 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 /etc/opt/kerberosio/capture/ -type f | sort | head -n 100 | xargs -r rm -rf; + find $imagedir -type f | sort | head -n 100 | xargs -r rm -rf; fi; Make the script executable. diff --git a/70_installation/4_Armbian.md b/70_installation/4_Armbian.md index 11d12a5..40e974b 100644 --- a/70_installation/4_Armbian.md +++ b/70_installation/4_Armbian.md @@ -135,10 +135,11 @@ Create a bash script and copy following script. 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 /etc/opt/kerberosio/capture/ -type f | sort | head -n 100 | xargs -r rm -rf; + find $imagedir -type f | sort | head -n 100 | xargs -r rm -rf; fi; Make the script executable. From 54341f9865b6670bfb6704608c4395a592e2b5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Verstraeten?= Date: Wed, 2 Aug 2017 10:50:41 +0200 Subject: [PATCH 4/4] fix tyypo --- 70_installation/3_Raspbian.md | 2 +- 70_installation/4_Armbian.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/70_installation/3_Raspbian.md b/70_installation/3_Raspbian.md index 8f8ad6c..927de76 100644 --- a/70_installation/3_Raspbian.md +++ b/70_installation/3_Raspbian.md @@ -134,7 +134,7 @@ Reboot 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 continiously poll your filesystem, and start removing media when your disk is getting full. +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. diff --git a/70_installation/4_Armbian.md b/70_installation/4_Armbian.md index 40e974b..a6e789d 100644 --- a/70_installation/4_Armbian.md +++ b/70_installation/4_Armbian.md @@ -126,7 +126,7 @@ Reboot 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 continiously poll your filesystem, and start removing media when your disk is getting full. +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.