News:

Forum Rules can be found here

Main Menu

How to setup Groestlcoin Ordinals Server for testnet

Started by jackielove4u, June 12, 2023, 09:32:08 PM

Previous topic - Next topic

jackielove4u

The following were tested in Ubuntu 16.04 and Ubuntu 18.04, some dependencies can be different in other distros.
    • aptitude update -y && aptitude upgrade -y && apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
    • dd if=/dev/zero of=/swapfile bs=1M count=4096
    • mkswap /swapfile
    • swapon /swapfile
    • echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
    • sudo apt-get install build-essential libssl-dev libboost-all-dev libdb5.3 libdb5.3-dev libdb5.3++-dev libtool automake libevent-dev bsdmainutils -y
    • sudo apt-get install git ntp make g++ gcc autoconf cpp ngrep iftop sysstat autotools-dev pkg-config libminiupnpc-dev libzmq3-dev -y
    • sudo apt-get install libgmp-dev libsqlite3-dev python python3 net-tools zlib1g-dev gettext jq -y
    • git clone https://github.com/groestlcoin/groestlcoin
    • cd groestlcoin
    • ./autogen.sh
    • ./configure
    • make
    • strip src/groestlcoind src/groestlcoin-cli src/groestlcoin-tx src/groestlcoin-wallet src/groestlcoin-util
    • sudo mv src/groestlcoind src/groestlcoin-cli src/groestlcoin-tx src/groestlcoin-wallet src/groestlcoin-util /usr/bin
    • mkdir ~/.groestlcoin
    • nano ~/.groestlcoin/groestlcoin.conf
    • write:
      listen=1
      server=1
      maxconnections=863
      daemon=1
      txindex=1
      blockfilterindex=1
      coinstatsindex=1
      whitelist=127.0.0.1
    • Crtl+o enter, ctrl X
    • groestlcoind -testnet
    • Let it sync (can take up to 2 hours), verify with groestlcoin-cli -getinfo
    • curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    • sudo apt install clang cmake -y
    • apt install cargo -y
    • git clone https://github.com/Groestlcoin/ord-groestlcoin.git
    • cd ord-groestlcoin
    • cargo build --release
    • cp target/release/ord /usr/local/bin/ord
    • cp deploy/ord.service /etc/systemd/system/
    • ord --data-dir /var/lib/ord --config-dir /var/lib/ord --chain testnet index run
    • cp /var/lib/ord/testnet3/index.redb /var/lib/ord/testnet3/index.redb.backup
    • nano /etc/systemd/system/ord.service
    • delete all and paste:
      [Unit]
      After=network.target
      Description=Ord server
      StartLimitBurst=120
      StartLimitIntervalSec=10m

      [Service]
      AmbientCapabilities=CAP_NET_BIND_SERVICE
      Environment=RUST_BACKTRACE=1
      Environment=RUST_LOG=info
      ExecStart=/usr/local/bin/ord \
        --data-dir /var/lib/ord \
        --config-dir /var/lib/ord \
        --chain testnet \
        --index-sats \
        server \
        --http-port 3002
      Group=root
      LimitNOFILE=65536
      MemoryDenyWriteExecute=true
      NoNewPrivileges=true
      PrivateDevices=true
      PrivateTmp=true
      ProtectHome=false
      ProtectSystem=full
      Restart=on-failure
      RestartSec=5s
      StateDirectory=ord
      StateDirectoryMode=0700
      TimeoutStopSec=10m
      Type=simple
      User=root
      WorkingDirectory=/var/lib/ord

      [Install]
      WantedBy=multi-user.target
    • systemctl daemon-reload
    • systemctl enable ord
    • systemctl restart ord
    • cd ~
    • nano backup.sh
    • write:
      #!/bin/bash

      # Check if the website contains the text 'OK'
      if curl -s http://localhost:3002/status | grep -q OK; then

        # Stop the service called ord-groestlcoind
        systemctl stop ord

        # Make a backup of the index file
        cp /var/lib/ord/testnet3/index.redb /var/lib/ord/testnet3/index.redb.backup

        # Start the service again
        systemctl start ord

        # Log the event to a cron log
        logger "Index OK: ord service stopped, index file copied, and service started again"
      fi
    • Crtl+o enter, ctrl X
    • chmod +x backup.sh
    • nano restore.sh
    • write:
      #!/bin/bash

      # Check if the website contains the text 'reorg detected'
      if curl -s http://localhost:3002/status | grep -q 'reorg detected'; then

        # Stop the service called ord-groestlcoind
        systemctl stop ord

        # Copy backup of the index file back
        cp /var/lib/ord/testnet3/index.redb.backup /var/lib/ord/testnet3/index.redb

        # Start the service again
        systemctl start ord

        # Log the event to a cron log
        logger "Reorg detected: ord service stopped, index file backup copied, and service started again"
      fi
    • Crtl+o enter, ctrl X
    • chmod +x restore.sh
    • sudo apt-get install certbot
    • certbot certonly --standalone -d ordinals-test.groestlcoin.org
    • crontab -e
    • Add end of file:
      */10 * * * * /root/restore.sh
      */30 * * * * /root/backup.sh
      14 3 * * * /usr/sbin/service nginx stop
      15 3 * * * /usr/bin/certbot renew --quiet
      16 3 * * * /usr/sbin/service nginx start
    • Crtl+o enter, ctrl X
    • apt-get install nginx
    • nano /etc/nginx/sites-available/default
    • delete all and paste:
      server {
          listen 80;
          listen 443 ssl;
          ssl_certificate /etc/letsencrypt/live/ordinals-test.groestlcoin.org/fullchain.pem;
          ssl_certificate_key /etc/letsencrypt/live/ordinals-test.groestlcoin.org/privkey.pem;

          server_name ordinals-test.groestlcoin.org;

          # force https-redirects
          if ($scheme = http) {
              return 301 https://ordinals-test.groestlcoin.org$request_uri;
          }

          location / {
              proxy_pass http://localhost:3002;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $http_host;
              proxy_set_header X-NginX-Proxy true;

              # Enables WS support
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_redirect off;
          }
      }
    • service nginx restart