mirror of
https://github.com/unifi-utilities/unifios-utilities.git
synced 2024-08-30 18:32:21 +00:00
UDM / UDMPro Boot Script
Features
- Allows you to run a shell script at S95 anytime your UDM starts / reboots
- Persists through reboot
- Must be re-done after firmware updates
Compatibility
- Should work on any UDM/UDMPro after 1.6.3
- Tested and confirmed on 1.6.6, 1.7.0, 1.7.2rc4, 1.7.3rc1
Steps
Automated Setup
- Copy install.sh to your UDM and execute it
- 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)
Examples:
- Start a DNS Container 10-dns.sh
- Start wpa_supplicant on_boot.d/10-wpa_supplicant.sh
Manual Setup
-
Copy on_boot.sh and make on_boot.d and add scripts to on_boot.d
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
-
Enter the container shell
unifi-os shell
-
make a script that sshs to the udm and runs on our boot script. 127.0.1.1 always points to the UDM
echo "#!/bin/sh ssh -o StrictHostKeyChecking=no root@127.0.1.1 '/mnt/data/on_boot.sh'" > /etc/init.d/udm.sh chmod u+x /etc/init.d/udm.sh
Example: udm.sh
-
make a service that runs on startup, after we have networking
echo "[Unit] Description=Run On Startup UDM After=network.target [Service] ExecStart=/etc/init.d/udm.sh [Install] WantedBy=multi-user.target" > /etc/systemd/system/udmboot.service
Example: udmboot.service
-
enable it and test
systemctl enable udmboot systemctl start udmboot
-
back to the udm
exit
-
reboot your udm/udmpro and make sure it worked
reboot exit