From ba40b3afc3453f975dd4a48f593788c960474f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 7 Dec 2022 15:57:41 +0100 Subject: [PATCH] sync: add sync script for resyncing from ERA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- tasks/build.yml | 8 -------- tasks/config.yml | 10 ++++++++++ templates/scripts/sync.sh.j2 | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 templates/scripts/sync.sh.j2 diff --git a/tasks/build.yml b/tasks/build.yml index d5f34d7..0d5c78d 100644 --- a/tasks/build.yml +++ b/tasks/build.yml @@ -8,14 +8,6 @@ update: true become_user: '{{ beacon_node_user }}' -- name: Create build script - template: - src: 'scipts/build.sh.j2' - dest: '{{ beacon_node_build_script_path }}' - owner: '{{ beacon_node_user }}' - group: '{{ beacon_node_group }}' - mode: 0775 - - name: Create launchd config file for scheduled builds template: src: launchd-build.plist.j2 diff --git a/tasks/config.yml b/tasks/config.yml index d78f40b..ef05486 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -28,3 +28,13 @@ dest: '{{ beacon_node_web3_jwt_secret_path }}' content: '{{ beacon_node_web3_jwt_secret }}' group: '{{ beacon_node_group }}' + +- name: Create helper scripts + template: + src: '{{ item }}' + dest: '{{ beacon_node_service_path }}/{{ item|basename|replace(".j2", "") }}' + owner: '{{ beacon_node_user }}' + group: '{{ beacon_node_group }}' + mode: 0775 + with_fileglob: + - 'templates/scripts/*' diff --git a/templates/scripts/sync.sh.j2 b/templates/scripts/sync.sh.j2 new file mode 100644 index 0000000..f685c92 --- /dev/null +++ b/templates/scripts/sync.sh.j2 @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# vim: ft=sh +set -e + +SERVICE_USER='{{ beacon_node_user | mandatory }}' +SERVICE_NAME='{{ beacon_node_service_name | mandatory }}' +SERVICE_PATH='{{ beacon_node_service_path | mandatory }}' +SERVICE_DATA='{{ beacon_node_data_path | mandatory }}' +NETWORK_NAME='{{ beacon_node_network | mandatory }}' + +TRUSTED_NODE_API_URL=$1 +if [[ -z "${TRUSTED_NODE_API_URL}" ]]; then + echo "Usage: sync.sh " >&2 + exit 2 +fi + +sudo -u "${SERVICE_USER}" "${SERVICE_PATH}/repo/build/nimbus_beacon_node" \ + trustedNodeSync \ + --backfill=false \ + --network="${NETWORK_NAME}" \ + --data-dir="${SERVICE_DATA}" \ + --trusted-node-url="${TRUSTED_NODE_API_URL}"