feat: multiples fix

This commit is contained in:
wpetit 2023-03-27 19:28:58 +02:00
parent b4d6c75d52
commit b03e00fe5b
8 changed files with 38 additions and 51 deletions

View File

@ -77,9 +77,8 @@ $(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH):
rm -rf "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)"
mkdir -p "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc"
echo "# Firmware built with https://forge.cadoles.com/Cadoles/emissary-firmware" > "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
echo "BUILD_DATE=$(shell date --iso-8601=seconds)" >> "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
echo "GIT_VERSION=$(GIT_VERSION)" >> "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
echo "# Firmware built with https://forge.cadoles.com/arcad/emissary-firmware" > "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
echo "FIRMWARE_VERSION=$(FULL_VERSION)" >> "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
echo "OPENWRT_PROFILE=$(OPENWRT_PROFILE)" >> "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
rm -rf files/*

View File

@ -1,4 +1,4 @@
install-emissary-files:
install-emissary-files: tools/yq/bin/yq tools/upx/bin/upx
mkdir -p files/etc/config
cp -r misc/emissary/config/* files/etc/config/
@ -22,6 +22,9 @@ install-emissary-files:
# Patch agent config
tools/yq/bin/yq -i '.agent.serverUrl = "$${EMISSARY_SERVER_URL}"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.reconciliationInterval = "$${EMISSARY_RECONCILIATION_INTERVAL}"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.privateKeyPath = "/etc/emissary/agent-key.json"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.controllers.persistence.stateFile = "/etc/emissary/agent-state.json"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.controllers.sysupgrade.firmwareVersionCommand = ["sh", "-c", "source /etc/emissary_firmware && echo \"$$FIRMWARE_VERSION\""]' files/etc/emissary/agent.yml
# Copy emissary binary
mkdir -p files/usr/local/bin

View File

@ -1,3 +1,3 @@
/etc/machine-id
/var/lib/emissary/agent-key.json
/var/lib/emissary/state.json
/etc/emissary/agent-key.json
/etc/emissary/agent-state.json

View File

@ -6,24 +6,13 @@ ssh-copy-id root@${OPENWRT_DEVICE}
TARGET_ARCH=$(ssh root@${OPENWRT_DEVICE} source /etc/os-release \&\& echo \${OPENWRT_BOARD:-\$LEDE_BOARD})
FIRMWARE_FILE=bin/${OPENWRT_VERSION}/${TARGET_ARCH}/${OPENWRT_PROFILE}/openwrt-*-squashfs-factory.img
FIRMWARE_FILE=bin/${OPENWRT_VERSION}/${TARGET_ARCH}/${OPENWRT_PROFILE}/openwrt-*-sysupgrade.img*
FIRMWARE_FILE=${CUSTOM_FIRMWARE_FILE:-$FIRMWARE_FILE}
NOW=$(date +%Y-%m-%d)
BACKUP_FILENAME="backup_${OPENWRT_DEVICE}_${NOW}.tar.gz"
ssh root@${OPENWRT_DEVICE} \
rm -f "/tmp/${BACKUP_FILENAME}" \
\&\& sysupgrade -b "/tmp/${BACKUP_FILENAME}"
mkdir -p tmp/backups
scp "root@${OPENWRT_DEVICE}:/tmp/${BACKUP_FILENAME}" ./tmp/backups/
ssh root@${OPENWRT_DEVICE} \
mkdir -p /tmp/firmwares \
\&\& rm /tmp/firmwares/* \|\| exit 0;
scp $FIRMWARE_FILE root@${OPENWRT_DEVICE}:/tmp/firmwares/
ssh root@${OPENWRT_DEVICE} sysupgrade --force -p -v -n "/tmp/firmwares/$(basename $FIRMWARE_FILE)"
ssh root@${OPENWRT_DEVICE} sysupgrade --force -v -u "/tmp/firmwares/$(basename $FIRMWARE_FILE)"

View File

@ -1,18 +0,0 @@
#!/bin/bash
set -o pipefail
NOW=$(date +%Y-%m-%d)
BACKUP_DATE=${BACKUP_DATE:-${NOW}}
BACKUP_FILENAME="backup_${OPENWRT_DEVICE}_${NOW}.tar.gz"
printf "%s" "Waiting for ${OPENWRT_DEVICE} ..."
while ! ping -c 1 -n -w 1 ${OPENWRT_DEVICE} &> /dev/null
do
printf "%c" "."
done
printf "\n%s\n" "Server is back online"
scp "./tmp/backups/${BACKUP_FILENAME}" root@${OPENWRT_DEVICE}:/tmp/
ssh root@${OPENWRT_DEVICE} sysupgrade -r "/tmp/${BACKUP_FILENAME}"

24
targets/linksys-wrt.mk Normal file
View File

@ -0,0 +1,24 @@
all: linksys-wrtXXXXac
linksys-wrtXXXXac: linksys-wrt1200ac linksys-wrt1900ac linksys-wrt3200acm
linksys-wrt1200ac:
$(MAKE) \
OPENWRT_TARGET="mvebu/cortexa9" \
EMISSARY_ARCH="armv6" \
OPENWRT_PROFILE="linksys_wrt1200ac" \
build
linksys-wrt1900ac:
$(MAKE) \
OPENWRT_TARGET="mvebu/cortexa9" \
EMISSARY_ARCH="armv7" \
OPENWRT_PROFILE="linksys_wrt1900ac-v2" \
build
linksys-wrt3200acm:
$(MAKE) \
OPENWRT_TARGET="mvebu/cortexa9" \
EMISSARY_ARCH="armv7" \
OPENWRT_PROFILE="linksys_wrt3200acm" \
build

View File

@ -1,12 +0,0 @@
all: linksys-wrtXXXXac
linksys-wrtXXXXac: linksys-wrt1200ac linksys-wrt1900ac linksys-wrt3200acm
linksys-wrt1200ac:
$(MAKE) OPENWRT_TARGET="mvebu/cortexa9" EMISSARY_ARCH="armv6" OPENWRT_PROFILE="linksys_wrt1200ac" build
linksys-wrt1900ac:
$(MAKE) OPENWRT_TARGET="mvebu/cortexa9" EMISSARY_ARCH="armv6" OPENWRT_PROFILE="linksys_wrt1900ac-v2" build
linksys-wrt3200acm:
$(MAKE) OPENWRT_TARGET="mvebu/cortexa9" EMISSARY_ARCH="armv6" OPENWRT_PROFILE="linksys_wrt3200acm" build

View File

@ -1,9 +1,11 @@
all: omnia
all: turris
turris: omnia
omnia:
$(MAKE) \
ADDITIONAL_INSTALL="" \
OPENWRT_TARGET="mvebu/cortexa9" \
EMISSARY_ARCH="arm64" \
EMISSARY_ARCH="armv6" \
OPENWRT_PROFILE="cznic_turris-omnia" \
build