diff --git a/on-boot-script/README.md b/on-boot-script/README.md index ba1cf00..7720dba 100644 --- a/on-boot-script/README.md +++ b/on-boot-script/README.md @@ -20,25 +20,17 @@ rm /etc/systemd/system/udmboot.service * Built on Ubuntu-20.04 on Windows 10/WSL2 ## Steps -1. Copy on_boot.sh and make on_boot.d and add scripts to on_boot.d - ```shell script - mkdir -p /mnt/data/on_boot.d - vi /mnt/data/on_boot.sh - chmod u+x /mnt/data/on_boot.sh - ``` - Example: [on_boot.sh](examples/udm-files/on_boot.sh) - -2. Get into the unifios shell on your udm +1. Get into the unifios shell on your udm ```shell script unifi-os shell ``` -3. Download the [udm-boot_1.0.0-1_all.deb](packages/udm-boot_1.0.0-1_all.deb) and install it and go back to the UDM +2. Download [udm-boot_1.0.1-1_all.deb](packages/udm-boot_1.0.0-1_all.deb) and install it and go back to the UDM ```shell script -curl -L https://raw.githubusercontent.com/boostchicken/udm-utilities/master/on-boot-script/packages/udm-boot_1.0.0-1_all.deb -o udm-boot_1.0.0-1_all.deb -dpkg -i udm-boot_1.0.0-1_all.deb +curl -L https://raw.githubusercontent.com/boostchicken/udm-utilities/master/on-boot-script/packages/udm-boot_1.0.1-1_all.deb -o udm-boot_1.0.1-1_all.deb +dpkg -i udm-boot_1.0.1-1_all.deb exit ``` -4. Copy any shell scripts you want to run to /mnt/data/on_boot.d and make sure they are executable and have the correct shebang (#!/bin/sh) +3. Copy any shell scripts you want to run to /mnt/data/on_boot.d on your UDM (not the unifi-os shell)and make sure they are executable and have the correct shebang (#!/bin/sh) Examples: * Start a DNS Container [10-dns.sh](../dns-common/on_boot.d/10-dns.sh) * Start wpa_supplicant [on_boot.d/10-wpa_supplicant.sh](examples/udm-files/on_boot.d/10-wpa_supplicant.sh) diff --git a/on-boot-script/dpkg-build-files/debian/postinst b/on-boot-script/dpkg-build-files/debian/postinst index d0c33c6..3941a14 100644 --- a/on-boot-script/dpkg-build-files/debian/postinst +++ b/on-boot-script/dpkg-build-files/debian/postinst @@ -1,10 +1,24 @@ #!/bin/sh - set -e - case "$1" in configure) + echo '#!/bin/sh + + if [ -d /mnt/data/on_boot.d ]; then + for i in /mnt/data/on_boot.d/*.sh; do + if [ -r $i ]; then + . $i + fi + done + fi + ' > /tmp/on_boot.sh + scp -o StrictHostKeyChecking=no /tmp/on_boot.sh root@127.0.1.1:/mnt/data/on_boot.sh + ssh -o StrictHostKeyChecking=no root@127.0.1.1 'chmod +x /mnt/data/on_boot.sh' + ssh -o StrictHostKeyChecking=no root@127.0.1.1 'mkdir -p /mnt/data/on_boot.d' + + rm /tmp/on_boot.sh + echo "#!/bin/sh ssh -o StrictHostKeyChecking=no root@127.0.1.1 '/mnt/data/on_boot.sh'" > /etc/init.d/udm.sh chmod +x /etc/init.d/udm.sh diff --git a/on-boot-script/packages/udm-boot_1.0.1-1_all.deb b/on-boot-script/packages/udm-boot_1.0.1-1_all.deb new file mode 100644 index 0000000..4d92c4c Binary files /dev/null and b/on-boot-script/packages/udm-boot_1.0.1-1_all.deb differ