emissary-firmware/install/emissary-files.mk

49 lines
2.8 KiB
Makefile

install-emissary-files: tools/yq/bin/yq tools/upx/bin/upx
mkdir -p "$(INSTALL_DIR)/etc/config"
cp -r misc/emissary/config/* "$(INSTALL_DIR)/etc/config/"
mkdir -p "$(INSTALL_DIR)/etc/init.d"
cp -r misc/emissary/init.d/* "$(INSTALL_DIR)/etc/init.d/"
mkdir -p "$(INSTALL_DIR)/etc/uci-defaults"
cp -r misc/emissary/uci-defaults/* "$(INSTALL_DIR)/etc/uci-defaults/"
# Copy keep.d files
mkdir -p "$(INSTALL_DIR)/lib/upgrade/keep.d"
cp -r misc/emissary/keep.d/* "$(INSTALL_DIR)/lib/upgrade/keep.d/"
# Copy profile.d files
mkdir -p "$(INSTALL_DIR)/etc/profile.d"
cp -r misc/emissary/profile.d/* "$(INSTALL_DIR)/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 "$(INSTALL_DIR)/etc/emissary"
cp gitea-dl/emissary-agent_linux_$(EMISSARY_ARCH)/misc/packaging/common/config-agent.yml "$(INSTALL_DIR)/etc/emissary/agent.yml"
# Patch agent config
tools/yq/bin/yq -i '.agent.serverUrl = "$${EMISSARY_SERVER_URL}"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.agent.reconciliationInterval = "$${EMISSARY_RECONCILIATION_INTERVAL}"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.agent.privateKeyPath = "/data/emissary/agent-key.json"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.agent.controllers.persistence.stateFile = "/data/emissary/agent-state.json"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.agent.controllers.sysupgrade.firmwareVersionCommand = ["sh", "-c", "source /etc/emissary_firmware && echo \"$$FIRMWARE_VERSION\""]' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.agent.controllers.app.dataDir = "/data/emissary/apps/data"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.agent.controllers.app.downloadDir = "/data/emissary/apps/bundles"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.sentry.dsn = "$${EMISSARY_SENTRY_DSN}"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
tools/yq/bin/yq -i '.sentry.environment = "$${EMISSARY_SENTRY_ENVIRONMENT}"' "$(INSTALL_DIR)/etc/emissary/agent.yml"
# Copy emissary binary
mkdir -p "$(INSTALL_DIR)/usr/local/bin"
cp gitea-dl/emissary-agent_linux_$(EMISSARY_ARCH)/emissary "$(INSTALL_DIR)/usr/local/bin/emissary"
chmod +x "$(INSTALL_DIR)/usr/local/bin/emissary"
# Set defaults
mkdir -p "$(INSTALL_DIR)/data/emissary"
rm -rf "$(INSTALL_DIR)/data/emissary/default.conf"
echo "EMISSARY_RECONCILIATION_INTERVAL='$(EMISSARY_RECONCILIATION_INTERVAL)'" > "$(INSTALL_DIR)/data/emissary/default.conf"
echo "EMISSARY_SERVER_URL='$(EMISSARY_SERVER_URL)'" >> "$(INSTALL_DIR)/data/emissary/default.conf"
# Compress emissary binary
tools/upx/bin/upx -9 "$(INSTALL_DIR)/usr/local/bin/emissary"