emissary-firmware/install/emissary-files.mk

51 lines
2.7 KiB
Makefile

install-emissary-files: tools/yq/bin/yq tools/upx/bin/upx
mkdir -p files/etc/config
cp -r misc/emissary/config/* files/etc/config/
mkdir -p files/etc/init.d
cp -r misc/emissary/init.d/* files/etc/init.d/
mkdir -p files/etc/uci-defaults
cp -r misc/emissary/uci-defaults/* files/etc/uci-defaults/
# Copy keep.d files
mkdir -p files/lib/upgrade/keep.d
cp -r misc/emissary/keep.d/* files/lib/upgrade/keep.d/
# Copy profile.d files
mkdir -p files/etc/profile.d
cp -r misc/emissary/profile.d/* files/etc/profile.d/
mkdir -p gitea-dl/emissary-agent_linux_$(EMISSARY_ARCH)
cd gitea-dl && tar -xzf emissary-agent_*_linux_$(EMISSARY_ARCH).tar.gz -C emissary-agent_linux_$(EMISSARY_ARCH)
# Copy agent config
mkdir -p files/etc/emissary
cp gitea-dl/emissary-agent_linux_$(EMISSARY_ARCH)/misc/packaging/common/config-agent.yml files/etc/emissary/agent.yml
# 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 = "/data/emissary/agent-key.json"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.controllers.persistence.stateFile = "/data/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
tools/yq/bin/yq -i '.agent.controllers.app.dataDir = "/data/emissary/apps/data"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.controllers.app.downloadDir = "/data/emissary/apps/bundles"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.sentry.dsn = "$${EMISSARY_SENTRY_DSN}"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.sentry.environment = "$${EMISSARY_SENTRY_ENVIRONMENT}"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.controllers.status.claimURL = "$${EMISSARY_CONTROLLERS_STATUS_CLAIM_URL}"' files/etc/emissary/agent.yml
tools/yq/bin/yq -i '.agent.controllers.status.agentURL = "$${EMISSARY_CONTROLLERS_STATUS_AGENT_URL}"' files/etc/emissary/agent.yml
# Copy emissary binary
mkdir -p files/usr/local/bin
cp gitea-dl/emissary-agent_linux_$(EMISSARY_ARCH)/emissary files/usr/local/bin/emissary
chmod +x files/usr/local/bin/emissary
# Set defaults
mkdir -p files/data/emissary
rm -rf files/data/emissary/default.conf
echo "EMISSARY_RECONCILIATION_INTERVAL='$(EMISSARY_RECONCILIATION_INTERVAL)'" > files/data/emissary/default.conf
echo "EMISSARY_SERVER_URL='$(EMISSARY_SERVER_URL)'" >> files/data/emissary/default.conf
# Compress emissary binary
tools/upx/bin/upx -9 files/usr/local/bin/emissary