entrypoint.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. {% macro entrypoint(values) -%}
  2. #!/bin/sh
  3. set -e
  4. LWS_DIR_PATH="{{ values.consts.monero_lws_path }}/light_wallet_server"
  5. ACCOUNTS_FILE_PATH="{{ values.consts.monero_lws_path }}/.accounts.txt"
  6. mkdir -p "$LWS_DIR_PATH"
  7. touch "$ACCOUNTS_FILE_PATH"
  8. {% for account in values.lws.accounts %}
  9. address="{{ account.address }}"
  10. view_key="{{ account.view_key }}"
  11. restore_height={{ account.restore_height or 0 }}
  12. account_id="$address:$restore_height"
  13. if grep -q "$address" "$ACCOUNTS_FILE_PATH"; then
  14. if ! grep -q "$account_id" "$ACCOUNTS_FILE_PATH"; then
  15. echo "Rescanning account $address from block $restore_height"
  16. monero-lws-admin rescan "$restore_height" "$address"
  17. sed -i "/$address/d" "$ACCOUNTS_FILE_PATH"
  18. echo "$account_id" >> "$ACCOUNTS_FILE_PATH"
  19. fi
  20. else
  21. echo "Adding account $address"
  22. monero-lws-admin add_account "$address" "$view_key"
  23. monero-lws-admin rescan "$restore_height" "$address"
  24. sed -i '/{{ account.address }}/d' "$ACCOUNTS_FILE_PATH"
  25. echo "$account_id" >> "$ACCOUNTS_FILE_PATH"
  26. fi
  27. {% endfor %}
  28. echo "Starting monero-lws-daemon"
  29. monero-lws-daemon \
  30. --db-path "{{ values.consts.monero_lws_path }}/light_wallet_server" \
  31. "$@"
  32. {%- endmacro %}