mirror of
https://github.com/unifi-utilities/unifios-utilities.git
synced 2024-08-30 18:32:21 +00:00
on-boot now persists through firmware updates
This commit is contained in:
parent
555ce00201
commit
e1f1238764
@ -4,6 +4,7 @@ A collection of things to enhance the capabilities of your Unifi Dream Machine o
|
||||
## General Tools
|
||||
### on-boot-script
|
||||
Enables init.d style scripts to run on every boot of your UDM. Includes a wpa-supplicant/eap-proxy example
|
||||
**Persists through Firmware upgrades!!!**
|
||||
|
||||
### python
|
||||
If you need python3 on your UDM, generally not recommended, can always use it in unifi-os container
|
||||
|
@ -72,7 +72,7 @@ fi
|
||||
if podman container exists ${CONTAINER}; then
|
||||
podman start ${CONTAINER}
|
||||
else
|
||||
echo "Container $CONTAINER not found, make sure you set the proper name, if you have you can ignore this error"
|
||||
logger Container $CONTAINER not found, make sure you set the proper name, if you have you can ignore this error
|
||||
fi
|
||||
|
||||
# (optional) IPv4 force DNS (TCP/UDP 53) through DNS container
|
||||
|
58
on-boot-script/README-MANUALmd
Normal file
58
on-boot-script/README-MANUALmd
Normal file
@ -0,0 +1,58 @@
|
||||
* NB! THESE WILL NOT PERSIST THROUGH FIRMWARE. They still work however
|
||||
### Automated Setup
|
||||
|
||||
1. Copy [install.sh](install.sh) to your UDM and execute it
|
||||
1. 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](../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-start-containers.sh)
|
||||
|
||||
### Manual Setup
|
||||
|
||||
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)
|
||||
|
||||
1. Enter the container shell
|
||||
```shell script
|
||||
unifi-os shell
|
||||
```
|
||||
1. make a script that sshs to the udm and runs on our boot script. 127.0.1.1 always points to the UDM
|
||||
```shell script
|
||||
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](examples/unifi-os-files/udm.sh)
|
||||
1. make a service that runs on startup, after we have networking
|
||||
```shell script
|
||||
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](examples/unifi-os-files/udmboot.service)
|
||||
|
||||
1. enable it and test
|
||||
```shell script
|
||||
systemctl enable udmboot
|
||||
systemctl start udmboot
|
||||
```
|
||||
1. back to the udm
|
||||
```shell script
|
||||
exit
|
||||
```
|
||||
1. reboot your udm/udmpro and make sure it worked
|
||||
```shell script
|
||||
reboot
|
||||
exit
|
||||
```
|
@ -1,69 +1,37 @@
|
||||
# UDM / UDMPro Boot Script
|
||||
### Features
|
||||
1. Allows you to run a shell script at S95 anytime your UDM starts / reboots
|
||||
1. Persists through reboot
|
||||
1. Must be re-done after firmware updates
|
||||
1. Persists through reboot and **firmware updates**! It is able to do this because Ubiquiti caches all debian package installs on the UDM in /mnt/data, then re-installs them on every boot
|
||||
|
||||
|
||||
### Compatibility
|
||||
1. Should work on any UDM/UDMPro after 1.6.3
|
||||
2. Tested and confirmed on 1.6.6, 1.7.0, 1.7.2rc4, 1.7.3rc1
|
||||
|
||||
### Upgrade from earlier way
|
||||
* As long as you didn't change the filenames, installing the deb package is all you need to do. If you want to clean up beforehand anyways....
|
||||
```
|
||||
rm /etc/init.d/udm.sh
|
||||
systemctl disable udmboot
|
||||
rm /etc/systemd/system/udmboot.service
|
||||
```
|
||||
* The new package is exactly the old steps packaged in a debian package
|
||||
* [dpkg-build-files](dpkg-build-files) contains the scripts that build the package (using dh_make and debuild) if you want to build it yourself / change it
|
||||
* Built on Ubuntu-20.04 on Windows 10/WSL2
|
||||
|
||||
## Steps
|
||||
|
||||
### Automated Setup
|
||||
|
||||
1. Copy [install.sh](install.sh) to your UDM and execute it
|
||||
1. 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)
|
||||
1. Get into the unifios shell on your udm
|
||||
```shell script
|
||||
unifi-os shell
|
||||
```
|
||||
2. 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
|
||||
```shell script
|
||||
wget https://raw.githubusercontent.com/boostchicken/udm-utilities/master/on-boot-script/packages/udm-boot_1.0.0-1_all.deb
|
||||
dpkg -i udm-boot_1.0.0-1_all.deb
|
||||
exit
|
||||
```
|
||||
3. 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](../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)
|
||||
|
||||
### Manual Setup
|
||||
|
||||
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)
|
||||
|
||||
1. Enter the container shell
|
||||
```shell script
|
||||
unifi-os shell
|
||||
```
|
||||
1. make a script that sshs to the udm and runs on our boot script. 127.0.1.1 always points to the UDM
|
||||
```shell script
|
||||
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](examples/unifi-os-files/udm.sh)
|
||||
1. make a service that runs on startup, after we have networking
|
||||
```shell script
|
||||
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](examples/unifi-os-files/udmboot.service)
|
||||
|
||||
1. enable it and test
|
||||
```shell script
|
||||
systemctl enable udmboot
|
||||
systemctl start udmboot
|
||||
```
|
||||
1. back to the udm
|
||||
```shell script
|
||||
exit
|
||||
```
|
||||
1. reboot your udm/udmpro and make sure it worked
|
||||
```shell script
|
||||
reboot
|
||||
exit
|
||||
```
|
||||
* Start wpa_supplicant [on_boot.d/10-wpa_supplicant.sh](examples/udm-files/on_boot.d/10-start-containers.sh)
|
||||
|
5
on-boot-script/dpkg-build-files/debian/changelog
Normal file
5
on-boot-script/dpkg-build-files/debian/changelog
Normal file
@ -0,0 +1,5 @@
|
||||
udm-boot (1.0.0-1) unstable; urgency=medium
|
||||
|
||||
* Initial release, happy firmware persisting!
|
||||
|
||||
-- Boostchicken <dorman@ataxia.cloud> Sun, 05 Jul 2020 18:46:14 -0700
|
14
on-boot-script/dpkg-build-files/debian/control
Normal file
14
on-boot-script/dpkg-build-files/debian/control
Normal file
@ -0,0 +1,14 @@
|
||||
Source: udm-boot
|
||||
Section: unknown
|
||||
Priority: optional
|
||||
Maintainer: Boostchicken <dorman@ataxia.cloud>
|
||||
Build-Depends: debhelper-compat (= 12)
|
||||
Standards-Version: 4.4.1
|
||||
Homepage: https://github.com/boostchicken/udm-utilities
|
||||
#Vcs-Browser: https://salsa.debian.org/debian/udmboot
|
||||
#Vcs-Git: https://salsa.debian.org/debian/udmboot.git
|
||||
|
||||
Package: udm-boot
|
||||
Architecture: all
|
||||
Description: Run things on boot on UDM
|
||||
Run things on boot!
|
9
on-boot-script/dpkg-build-files/debian/copyright
Normal file
9
on-boot-script/dpkg-build-files/debian/copyright
Normal file
@ -0,0 +1,9 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: udm-boot
|
||||
Upstream-Contact: John Dorman / Boostchicken
|
||||
Source: https://github.com/boostchicken/udm-utilities
|
||||
|
||||
Files: *
|
||||
Copyright: 2020 dorman@ataxia.cloud
|
||||
License: GPLv3
|
||||
https://github.com/boostchicken/udm-utilities/blob/master/LICENSE
|
2
on-boot-script/dpkg-build-files/debian/files
Normal file
2
on-boot-script/dpkg-build-files/debian/files
Normal file
@ -0,0 +1,2 @@
|
||||
udm-boot_1.0.0-1_all.deb unknown optional
|
||||
udm-boot_1.0.0-1_amd64.buildinfo unknown optional
|
1
on-boot-script/dpkg-build-files/debian/install
Normal file
1
on-boot-script/dpkg-build-files/debian/install
Normal file
@ -0,0 +1 @@
|
||||
udm.sh etc/init.d
|
31
on-boot-script/dpkg-build-files/debian/postinst
Normal file
31
on-boot-script/dpkg-build-files/debian/postinst
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
chmod +x /etc/init.d/udm.sh
|
||||
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
|
||||
systemctl enable udmboot
|
||||
systemctl start udmboot
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
24
on-boot-script/dpkg-build-files/debian/rules
Normal file
24
on-boot-script/dpkg-build-files/debian/rules
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/make -f
|
||||
# See debhelper(7) (uncomment to enable)
|
||||
# output every command that modifies files on the build system.
|
||||
#export DH_VERBOSE = 1
|
||||
|
||||
|
||||
# see FEATURE AREAS in dpkg-buildflags(1)
|
||||
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
|
||||
# see ENVIRONMENT in dpkg-buildflags(1)
|
||||
# package maintainers to append CFLAGS
|
||||
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
|
||||
# package maintainers to append LDFLAGS
|
||||
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
|
||||
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
|
||||
# dh_make generated override targets
|
||||
# This is example for Cmake (See https://bugs.debian.org/641051 )
|
||||
#override_dh_auto_configure:
|
||||
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
|
1
on-boot-script/dpkg-build-files/debian/source/format
Normal file
1
on-boot-script/dpkg-build-files/debian/source/format
Normal file
@ -0,0 +1 @@
|
||||
3.0 (quilt)
|
4
on-boot-script/dpkg-build-files/udm.sh
Normal file
4
on-boot-script/dpkg-build-files/udm.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
ssh -o StrictHostKeyChecking=no root@127.0.1.1 '/mnt/data/on_boot.sh'
|
||||
|
BIN
on-boot-script/packages/udm-boot_1.0.0-1_all.deb
Normal file
BIN
on-boot-script/packages/udm-boot_1.0.0-1_all.deb
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user