From 6d377c29a8cbfa24531d8b3b7605723ead9b7165 Mon Sep 17 00:00:00 2001 From: dirandad Date: Sun, 1 Jan 2023 21:27:10 +0100 Subject: [PATCH 1/3] Create sdcardautoconfig.md --- en/sdcardautoconfig.md | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 en/sdcardautoconfig.md diff --git a/en/sdcardautoconfig.md b/en/sdcardautoconfig.md new file mode 100644 index 0000000..a04345d --- /dev/null +++ b/en/sdcardautoconfig.md @@ -0,0 +1,66 @@ +# SP Card - Autoconfig +[Table of Content](../index.md) + +OpenIPC can be autoconfigured throw an SD Card. This is particularly usefull for IPC with Wifi Only where UART is not acessible. +This mecanism is managed by ```automount.sh```. + +The camera need a SD Card slot for this porpose. + +## Preparing the SD Card + +The SD Card must be formatted in FAT/FAT32/vFAT with at least one partition. +This is the commands on Windows (all data will be deleted) : + +``` +diskpart + +list disk +select disk +clean +create partition primary +format quick fs=FAT32 +list partition +active +assign letter= +``` + +## Inserting files to be replaced on the ipc + +Corresponding code of ```automount.sh``` +``` + # copy files from autoconfig folder + [ -d "${destdir}/$1/autoconfig" ] && cp -afv ${destdir}/$1/autoconfig/* / | logger -s -p daemon.info -t autoconfig +``` +Create a folder ```autoconfig``` and insert the file at the destination path to be copied in OpenIPC. + +```/autoconfig//file``` will be copied to ```//file``` + +### example : +``` +/autoconfig/etc/init.d/interfaces +``` +will be copied to +``` +/etc/init.d/interfaces +``` + +## Inserting a script to be run only once + +Corresponding code of ```automount.sh``` +``` + # execution of the specified commands one time + [ -f "${destdir}/$1/autoconfig.sh" ] && (sh ${destdir}/$1/autoconfig.sh ; rm -f ${destdir}/$1/autoconfig.sh) | logger -s -p daemon.info -t autoconfig +``` +Create a shell script at root of the SD Card named ```autoconfig.sh```. +The content of this script will be run, then the file removed. + +## Inserting a script to be run each startup +Corresponding code of ```automount.sh``` +``` + # execution of the specified commands + [ -f "${destdir}/$1/autostart.sh" ] && sh ${destdir}/$1/autostart.sh | logger -s -p daemon.info -t autostart +``` +Create a shell script at root of the SD Card named ```autostart.sh```. +The content of this script will be runned at each startup. + + From bffb1830bf1b3843574178b23598f9546f2a7749 Mon Sep 17 00:00:00 2001 From: dirandad Date: Fri, 6 Jan 2023 21:42:41 +0100 Subject: [PATCH 2/3] Update sdcardautoconfig.md --- en/sdcardautoconfig.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/sdcardautoconfig.md b/en/sdcardautoconfig.md index a04345d..8cbc93d 100644 --- a/en/sdcardautoconfig.md +++ b/en/sdcardautoconfig.md @@ -1,4 +1,4 @@ -# SP Card - Autoconfig +# SD Card - Autoconfig [Table of Content](../index.md) OpenIPC can be autoconfigured throw an SD Card. This is particularly usefull for IPC with Wifi Only where UART is not acessible. From f4b16ae218da7960922dd450840e45ac71522ee6 Mon Sep 17 00:00:00 2001 From: Paul Philippov Date: Fri, 6 Jan 2023 18:40:12 -0500 Subject: [PATCH 3/3] Suggested changes --- en/sdcardautoconfig.md | 102 +++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/en/sdcardautoconfig.md b/en/sdcardautoconfig.md index 8cbc93d..a98b2d0 100644 --- a/en/sdcardautoconfig.md +++ b/en/sdcardautoconfig.md @@ -1,21 +1,22 @@ -# SD Card - Autoconfig +# OpenIPC Wiki [Table of Content](../index.md) -OpenIPC can be autoconfigured throw an SD Card. This is particularly usefull for IPC with Wifi Only where UART is not acessible. -This mecanism is managed by ```automount.sh```. +SD Card Autoconfig +------------------ -The camera need a SD Card slot for this porpose. +OpenIPC can be configured automatically from an SD card. This method is particularly useful for WiFi-only +IP cameras equipped with and SD card slot and where UART is not acessible. -## Preparing the SD Card +### Format an SD card with at least one FAT/FAT32/vFAT partition. -The SD Card must be formatted in FAT/FAT32/vFAT with at least one partition. -This is the commands on Windows (all data will be deleted) : +Attention! All existing data on the SD card will be deleted! +On Windows: ``` diskpart list disk -select disk +select disk clean create partition primary format quick fs=FAT32 @@ -24,43 +25,64 @@ active assign letter= ``` -## Inserting files to be replaced on the ipc +### Create `automount.sh` file in the root directory of the card. -Corresponding code of ```automount.sh``` ``` - # copy files from autoconfig folder - [ -d "${destdir}/$1/autoconfig" ] && cp -afv ${destdir}/$1/autoconfig/* / | logger -s -p daemon.info -t autoconfig -``` -Create a folder ```autoconfig``` and insert the file at the destination path to be copied in OpenIPC. - -```/autoconfig//file``` will be copied to ```//file``` - -### example : -``` -/autoconfig/etc/init.d/interfaces -``` -will be copied to -``` -/etc/init.d/interfaces +echo "#!/bin/sh" > /automount.sh ``` -## Inserting a script to be run only once +### Add files to inject into firmware. -Corresponding code of ```automount.sh``` -``` - # execution of the specified commands one time - [ -f "${destdir}/$1/autoconfig.sh" ] && (sh ${destdir}/$1/autoconfig.sh ; rm -f ${destdir}/$1/autoconfig.sh) | logger -s -p daemon.info -t autoconfig -``` -Create a shell script at root of the SD Card named ```autoconfig.sh```. -The content of this script will be run, then the file removed. +Create a folder named `autoconfig` at the root of your SD card and place there files that should +be copied inside OpenIPC firmware with their paths following this pattern: +`/autoconfig//file` => `//file`. -## Inserting a script to be run each startup -Corresponding code of ```automount.sh``` -``` - # execution of the specified commands - [ -f "${destdir}/$1/autostart.sh" ] && sh ${destdir}/$1/autostart.sh | logger -s -p daemon.info -t autostart -``` -Create a shell script at root of the SD Card named ```autostart.sh```. -The content of this script will be runned at each startup. +E.g. `/autoconfig/etc/init.d/interfaces` will be copied to `/etc/init.d/interfaces`. +Add this code to `automount.sh` to handle the copying: +``` +if [ -d "${destdir}/$1/autoconfig" ]; then + cp -afv ${destdir}/$1/autoconfig/* / | logger -s -p daemon.info -t autoconfig +fi +``` +### Add a one-time configuration script. + +Create `autoconfig.sh` file at the root of the SD card. This script will be run once, then removed. + +Add this code to `automount.sh` to handle the one-time execution: +``` +if [ -f "${destdir}/$1/autoconfig.sh" ]; then + (sh ${destdir}/$1/autoconfig.sh; rm -f ${destdir}/$1/autoconfig.sh) | logger -s -p daemon.info -t autoconfig +fi +``` + +### Add a permanent script to run on every start + +Create `autostart.sh` file at the root of the SD card. This script will run on every start. + +Add this code to `automount.sh` to hande the execution on every start: +``` +if [ -f "${destdir}/$1/autostart.sh" ]; then + sh ${destdir}/$1/autostart.sh | logger -s -p daemon.info -t autostart +fi +``` + +Your resulting `automount.sh` file should look like this: +``` +#!/bin/sh + +if [ -d "${destdir}/$1/autoconfig" ]; then + cp -afv ${destdir}/$1/autoconfig/* / | logger -s -p daemon.info -t autoconfig +fi + +if [ -f "${destdir}/$1/autoconfig.sh" ]; then + (sh ${destdir}/$1/autoconfig.sh; rm -f ${destdir}/$1/autoconfig.sh) | logger -s -p daemon.info -t autoconfig +fi + +if [ -f "${destdir}/$1/autostart.sh" ]; then + sh ${destdir}/$1/autostart.sh | logger -s -p daemon.info -t autostart +fi +``` + +Unmount the card, eject if from PC and insert it into the IPC camera. Reboot the camera.