From adb29076aef7325590a0458fa47426dc56cb246e Mon Sep 17 00:00:00 2001 From: Denis Gorodnov Date: Mon, 1 May 2023 13:16:00 +0000 Subject: [PATCH] Update setup_macvlan.sh.j2 `/data/on_boot.d` might not exist when this script is ran (e.g. on an unmodded Ubiquiti device). No having this directory present will result in following error (output redirect creates a target file, but not the directory tree for the file) ```shell -bash: /data/on_boot.d/01-load-macvlan-module.sh: No such file or directory ``` Make sure script handles this case correctly and creates the dir before heredoc file creation. --- ci/templates/setup_macvlan.sh.j2 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/templates/setup_macvlan.sh.j2 b/ci/templates/setup_macvlan.sh.j2 index 0c93a87..a3425f1 100644 --- a/ci/templates/setup_macvlan.sh.j2 +++ b/ci/templates/setup_macvlan.sh.j2 @@ -31,7 +31,12 @@ curl -Lo "${MODULE_DIR}/${MODULE_FILE_NAME}" "${RELEASE_DOWNLOAD_URL}" || { exit 1 } -cat <<'EOF' >/data/on_boot.d/01-load-macvlan-module.sh +ONBOOT_DIR="${DATA_DIR}/on_boot.d" +ONBOOT_FILE_NAME="${ONBOOT_DIR}/01-load-macvlan-module.sh" + +mkdir -p "${ONBOOT_DIR}" + +cat <<'EOF' >"${ONBOOT_FILE_NAME}" #!/usr/bin/env bash set -euo pipefail DEVICE="$(ubnt-device-info model_short)" @@ -48,4 +53,4 @@ fi insmod "${MODULE_FILE_PATH}" EOF -chmod +x /data/on_boot.d/01-load-macvlan-module.sh +chmod +x "${ONBOOT_FILE_NAME}"