Set the Data Dir based on unifi-os version in boot script (#437)

This commit is contained in:
Laurence Laforest 2022-11-26 20:30:06 -05:00 committed by GitHub
parent 937a719462
commit 7ea55e2747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 25 deletions

View File

@ -1,12 +1,30 @@
#!/bin/sh
# Get DataDir location
DATA_DIR="/mnt/data"
case "$(ubnt-device-info firmware || true)" in
1*)
DATA_DIR="/mnt/data"
;;
2*)
DATA_DIR="/data"
;;
3*)
DATA_DIR="/data"
;;
*)
echo "ERROR: No persistent storage found." 1>&2
exit 1
;;
esac
## Set the version of cni plugin to use. It will revert to latest if an invalid version is given, and the installer will use the last installed version if that fails.
# Examples of valid version code would be "latest", "v0.9.1" and "v0.9.0".
CNI_PLUGIN_VER=latest
# location of the CNI Plugin cached tar files
CNI_CACHE="/mnt/data/.cache/cni-plugins"
CNI_CACHE="$DATA_DIR/.cache/cni-plugins"
# location of the conf files to go in the net.d folder of the cni-plugin directory
CNI_NETD="/mnt/data/podman/cni"
CNI_NETD="$DATA_DIR/podman/cni"
# The checksum to use. For CNI Plugin sha1, sha256 and sha512 are available.
CNI_CHECKSUM="sha256"
# Maximum number of loops to attempt to download the plugin if required - setting a 0 or negative value will reinstalled the currently installed version (if in cache)

View File

@ -1,5 +1,23 @@
#!/usr/bin/env sh
# Get DataDir location
DATA_DIR="/mnt/data"
case "$(ubnt-device-info firmware || true)" in
1*)
DATA_DIR="/mnt/data"
;;
2*)
DATA_DIR="/data"
;;
3*)
DATA_DIR="/data"
;;
*)
echo "ERROR: No persistent storage found." 1>&2
exit 1
;;
esac
# A change in the name udm-boot would need to be reflected as well in systemctl calls.
SYSTEMCTL_PATH="/etc/systemd/system/udm-boot.service"
SYMLINK_SYSTEMCTL="/etc/systemd/system/multi-user.target.wants/udm-boot.service"
@ -57,27 +75,6 @@ udm_model() {
esac
}
get_persistent_path() {
IFS_COPY="$IFS"
IFS="/"
if [ -d "/mnt/data" ]; then
DATA_DIR="/mnt/data${*:+/$*}"
elif [ -d "/data" ]; then
DATA_DIR="/data${*:+/$*}"
else
echo "ERROR: No persistent storage found." 1>&2
exit 1
fi
mkdir -p "$DATA_DIR"
echo "$DATA_DIR"
IFS="$IFS_COPY"
unset IFS_COPY DATA_DIR
}
get_latest_download_url() {
depends_on awk
@ -128,7 +125,7 @@ After=network-online.target
[Service]
Type=forking
ExecStart=bash -c 'mkdir -p /mnt/data/on_boot.d && find -L /mnt/data/on_boot.d -mindepth 1 -maxdepth 1 -type f -print0 | sort -z | xargs -0 -r -n 1 -- bash -c \'if test -x "\$0"; then echo "%n: running \$0"; "\$0"; else case "\$0" in *.sh) echo "%n: sourcing \$0"; . "\$0";; *) echo "%n: ignoring \$0";; esac; fi\''
ExecStart=bash -c 'mkdir -p $DATA_DIR/on_boot.d && find -L $DATA_DIR/on_boot.d -mindepth 1 -maxdepth 1 -type f -print0 | sort -z | xargs -0 -r -n 1 -- bash -c \'if test -x "\$0"; then echo "%n: running \$0"; "\$0"; else case "\$0" in *.sh) echo "%n: sourcing \$0"; . "\$0";; *) echo "%n: ignoring \$0";; esac; fi\''
[Install]
WantedBy=multi-user.target
@ -160,7 +157,7 @@ header
depends_on ubnt-device-info
depends_on curl
ON_BOOT_D_PATH="$(get_persistent_path "on_boot.d")"
ON_BOOT_D_PATH="$DATA_DIR/on_boot.d"
case "$(udm_model)" in
udm|udmpro)