github.com/grupokindynos/coins-explorer@v0.0.0-20210507172551-fa8983d19250/install.sh (about)

     1  #!/bin/bash
     2  color=`tput setaf 2`
     3  
     4  reset=`tput sgr0`
     5  
     6  echo "${color}Kindynos Blockbook Installer${reset}"
     7  
     8  sleep 1
     9  
    10  read -p "${color}Please insert the coin ticker you want to build:${reset} " ticker
    11  
    12  read -p "${color}please insert the domain name:${reset} " domain
    13  
    14  echo "${color}Adding some swap space..${reset}"
    15  
    16  sleep 1
    17  
    18  fallocate -l 2G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
    19  
    20  sleep 1
    21  
    22  echo "${color}Building system dependencies........${reset}"
    23  
    24  sleep 1
    25  
    26  add-apt-repository ppa:bitcoin/bitcoin -y && apt-get update && apt-get install git apt-transport-https ca-certificates curl gnupg-agent software-properties-common build-essential libtool autotools-dev autoconf pkg-config libssl-dev libevent-dev automake libminiupnpc-dev libdb4.8-dev libdb4.8++-dev nginx -y
    27  
    28  sleep 1
    29  
    30  echo "${color}Installing Docker......${reset}"
    31  
    32  sleep 1
    33  
    34  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - 
    35  
    36  add-apt-repository -y \
    37     "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    38     $(lsb_release -cs) \
    39     stable"
    40  
    41  apt-get update && apt-get install docker-ce docker-ce-cli containerd.io -y
    42  
    43  sleep 1
    44  
    45  echo "${color}Building Blockbook....${reset}"
    46  
    47  sleep 1
    48  
    49  git clone https://github.com/grupokindynos/coins-explorer.git && cd coins-explorer && make all-${ticker}
    50  
    51  apt install /root/coins-explorer/build/*.deb -y
    52  
    53  sleep 1
    54  
    55  echo "${color}Installing certbot.....${reset}"
    56  
    57  sleep 1
    58  
    59  add-apt-repository ppa:certbot/certbot -y && apt install python-certbot-nginx -y && ufw allow 'Nginx Full' && certbot --nginx -d ${domain}
    60  
    61  echo "${color}Updating NGINX conf file...${reset}"
    62  
    63  sleep 1
    64  
    65  :> /etc/nginx/sites-enabled/default
    66  
    67  tee -a /etc/nginx/sites-enabled/default << END
    68  
    69  server {
    70          server_name ${domain};
    71          location / {
    72          proxy_pass https://localhost:9130;
    73          proxy_http_version 1.1;
    74          proxy_set_header Upgrade $http_upgrade;
    75          proxy_set_header Connection 'upgrade';
    76          proxy_set_header Host $host;
    77          proxy_cache_bypass $http_upgrade;
    78      }
    79  
    80  
    81      listen 443 ssl; # managed by Certbot
    82      ssl_certificate /etc/letsencrypt/live/${domain}/fullchain.pem; # managed by Certbot
    83      ssl_certificate_key /etc/letsencrypt/live/${domain}/privkey.pem; # managed by Certbot
    84      include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    85      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    86  
    87  }
    88  server {
    89      if ($host = ${domain}) {
    90          return 301 https://$host$request_uri;
    91      } # managed by Certbot
    92  
    93  
    94          server_name ${domain};
    95      listen 80;
    96      return 404; # managed by Certbot
    97  
    98  
    99  }
   100  
   101  END
   102  
   103  service nginx restart
   104  
   105  sleep 1
   106  
   107  echo "${color}Installation completed, you can now start backend and blockbook services${reset}"