-
Notifications
You must be signed in to change notification settings - Fork 0
feat(install): Add arch-specific install scripts and docs for systemd setup #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f28c961
feat(install): Add arch-specific install scripts with systemd unit
PDJ107 ce1c4e6
docs(install): Document install and env
PDJ107 3bf5757
docs(readme): Add verify, delete agent
PDJ107 2bd571e
feat(install): Verify release checksum and secure env file permissions
PDJ107 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| : "${MORPHER_CONTROLLER_IP:?set MORPHER_CONTROLLER_IP (e.g. 192.168.54.3)}" | ||
|
|
||
| REPO="${REPO:-morpher-vm/morpher-agent}" | ||
| VERSION="${VERSION:-v0.0.1}" # e.g. v0.1.0 or latest | ||
| SERVICE_NAME="${SERVICE_NAME:-morpher-agent}" | ||
| INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" | ||
| CONFIG_DIR="/etc/${SERVICE_NAME}" | ||
|
|
||
| ASSET_FILE="${ASSET_FILE:-${SERVICE_NAME}_Linux_x86_64.tar.gz}" | ||
| BASE_URL="https://github.com/${REPO}/releases" | ||
| DL_URL="${BASE_URL}/download/${VERSION}/${ASSET_FILE}" | ||
| [[ "${VERSION}" == "latest" ]] && DL_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_FILE}" | ||
|
|
||
| tmpdir="$(mktemp -d)"; trap 'rm -rf "$tmpdir"' EXIT | ||
| echo "[*] Download ${DL_URL}" | ||
| curl -fsSL -o "${tmpdir}/asset.tgz" "${DL_URL}" | ||
|
|
||
| # Download and verify checksum | ||
| cs_url="${BASE_URL}/download/${VERSION}/checksums.txt" | ||
| [[ "${VERSION}" == "latest" ]] && cs_url="https://github.com/${REPO}/releases/latest/download/checksums.txt" | ||
|
|
||
| curl -fsSL -o "${tmpdir}/checksums.txt" "${cs_url}" | ||
|
|
||
| line="$(grep -E " ${ASSET_FILE}\$" "${tmpdir}/checksums.txt" || true)" | ||
| if [[ -z "${line}" ]]; then | ||
| echo "[X] ${ASSET_FILE} entry not found in checksums.txt (${cs_url})" | ||
| exit 1 | ||
| fi | ||
|
|
||
| hash="$(echo "${line}" | awk '{print $1}')" | ||
| echo "[*] Verifying checksum for ${ASSET_FILE}" | ||
| echo "${hash} asset.tgz" | (cd "${tmpdir}" && sha256sum -c -) | ||
|
|
||
| echo "[*] Extract" | ||
| tar -xzf "${tmpdir}/asset.tgz" -C "${tmpdir}" | ||
|
|
||
| bin_path="$(find "${tmpdir}" -type f -executable -name "${SERVICE_NAME}" | head -n1)" | ||
| [[ -z "${bin_path}" ]] && { echo "binary not found: ${SERVICE_NAME}"; exit 1; } | ||
|
|
||
| echo "[*] Install -> ${INSTALL_DIR}" | ||
| install -d "${INSTALL_DIR}" | ||
| install -m 0755 "${bin_path}" "${INSTALL_DIR}/${SERVICE_NAME}" | ||
|
|
||
| echo "[*] Config -> ${CONFIG_DIR}" | ||
| install -d "${CONFIG_DIR}" | ||
| cat > "${CONFIG_DIR}/${SERVICE_NAME}.env" <<EOF | ||
| MORPHER_AGENT_BASE_URL=http://${MORPHER_CONTROLLER_IP}:9000 | ||
| EOF | ||
| chmod 600 "${CONFIG_DIR}/${SERVICE_NAME}.env" | ||
|
|
||
| unit="/etc/systemd/system/${SERVICE_NAME}.service" | ||
| echo "[*] systemd unit -> ${unit}" | ||
| cat > "${unit}" <<EOF | ||
| [Unit] | ||
| Description=${SERVICE_NAME} | ||
| After=network-online.target | ||
| Wants=network-online.target | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| EnvironmentFile=-${CONFIG_DIR}/${SERVICE_NAME}.env | ||
PDJ107 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ExecStart=${INSTALL_DIR}/${SERVICE_NAME} start | ||
| Restart=on-failure | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
|
|
||
| systemctl daemon-reload | ||
| systemctl enable --now "${SERVICE_NAME}.service" | ||
| systemctl --no-pager --full status "${SERVICE_NAME}.service" || true | ||
|
|
||
| echo "✅ Done" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| : "${MORPHER_CONTROLLER_IP:?set MORPHER_CONTROLLER_IP (e.g. 192.168.54.3)}" | ||
|
|
||
| REPO="${REPO:-morpher-vm/morpher-agent}" | ||
| VERSION="${VERSION:-v0.0.1}" # e.g. v0.1.0 or latest | ||
| SERVICE_NAME="${SERVICE_NAME:-morpher-agent}" | ||
| INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}" | ||
| CONFIG_DIR="/etc/${SERVICE_NAME}" | ||
|
|
||
| ASSET_FILE="${ASSET_FILE:-${SERVICE_NAME}_Linux_arm64.tar.gz}" | ||
| BASE_URL="https://github.com/${REPO}/releases" | ||
| DL_URL="${BASE_URL}/download/${VERSION}/${ASSET_FILE}" | ||
| [[ "${VERSION}" == "latest" ]] && DL_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_FILE}" | ||
|
|
||
| tmpdir="$(mktemp -d)"; trap 'rm -rf "$tmpdir"' EXIT | ||
| echo "[*] Download ${DL_URL}" | ||
| curl -fsSL -o "${tmpdir}/asset.tgz" "${DL_URL}" | ||
|
|
||
PDJ107 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Download and verify checksum | ||
| cs_url="${BASE_URL}/download/${VERSION}/checksums.txt" | ||
| [[ "${VERSION}" == "latest" ]] && cs_url="https://github.com/${REPO}/releases/latest/download/checksums.txt" | ||
|
|
||
| curl -fsSL -o "${tmpdir}/checksums.txt" "${cs_url}" | ||
|
|
||
| line="$(grep -E " ${ASSET_FILE}\$" "${tmpdir}/checksums.txt" || true)" | ||
| if [[ -z "${line}" ]]; then | ||
| echo "[X] ${ASSET_FILE} entry not found in checksums.txt (${cs_url})" | ||
| exit 1 | ||
| fi | ||
|
|
||
| hash="$(echo "${line}" | awk '{print $1}')" | ||
| echo "[*] Verifying checksum for ${ASSET_FILE}" | ||
| echo "${hash} asset.tgz" | (cd "${tmpdir}" && sha256sum -c -) | ||
|
|
||
| echo "[*] Extract" | ||
| tar -xzf "${tmpdir}/asset.tgz" -C "${tmpdir}" | ||
|
|
||
| bin_path="$(find "${tmpdir}" -type f -executable -name "${SERVICE_NAME}" | head -n1)" | ||
| [[ -z "${bin_path}" ]] && { echo "binary not found: ${SERVICE_NAME}"; exit 1; } | ||
|
|
||
| echo "[*] Install -> ${INSTALL_DIR}" | ||
| install -d "${INSTALL_DIR}" | ||
| install -m 0755 "${bin_path}" "${INSTALL_DIR}/${SERVICE_NAME}" | ||
|
|
||
| echo "[*] Config -> ${CONFIG_DIR}" | ||
| install -d "${CONFIG_DIR}" | ||
| cat > "${CONFIG_DIR}/${SERVICE_NAME}.env" <<EOF | ||
| MORPHER_AGENT_BASE_URL=http://${MORPHER_CONTROLLER_IP}:9000 | ||
| EOF | ||
| chmod 600 "${CONFIG_DIR}/${SERVICE_NAME}.env" | ||
|
|
||
| unit="/etc/systemd/system/${SERVICE_NAME}.service" | ||
| echo "[*] systemd unit -> ${unit}" | ||
| cat > "${unit}" <<EOF | ||
| [Unit] | ||
| Description=${SERVICE_NAME} | ||
| After=network-online.target | ||
| Wants=network-online.target | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| EnvironmentFile=-${CONFIG_DIR}/${SERVICE_NAME}.env | ||
PDJ107 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ExecStart=${INSTALL_DIR}/${SERVICE_NAME} start | ||
| Restart=on-failure | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| EOF | ||
|
|
||
| systemctl daemon-reload | ||
| systemctl enable --now "${SERVICE_NAME}.service" | ||
| systemctl --no-pager --full status "${SERVICE_NAME}.service" || true | ||
|
|
||
| echo "✅ Done" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.