Skip to content
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

🛠 be-BOP easy-to-use installation script #1428

Open
Tirodem opened this issue Sep 2, 2024 · 2 comments
Open

🛠 be-BOP easy-to-use installation script #1428

Tirodem opened this issue Sep 2, 2024 · 2 comments

Comments

@Tirodem
Copy link
Contributor

Tirodem commented Sep 2, 2024

TBD with me & coyote, description to come soon

@Tirodem
Copy link
Contributor Author

Tirodem commented Feb 4, 2025

Latest non-reviewed version (I think) :

#!/bin/bash
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Configuration de vos adresses de be-BOP $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "Quelle est l'adresse de votre be-BOP ? (sans https://)"
read websiteUrl
echo -e "Quelle est l'adresse (spécifique ou sous-domaine) de votre S3 local ? (sans https://)"
read minioUrl
echo -e "Quelle est la nsec du compte Nostr de la boutique ?"
read nsecNostr
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Initialisation des scripts be-bop-reboot, be-bop-update et be-bop-config $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo "cd beBOP" >> update.sh
echo "git pull" >> update.sh
echo "pnpm i" >> update.sh
echo "docker compose pull" >> update.sh
echo "docker compose --env-file .env.local up --build -d" >> update.sh
echo "cd .." >> update.sh
echo "cd beBOP" >> reboot.sh
echo "pm2 restart phoenixd" >> reboot.sh
echo "docker compose pull" >> reboot.sh
echo "docker compose --env-file .env.local up --build -d" >> reboot.sh
echo "cd .." >> reboot.sh
alias be-bop-update='source update.sh'
alias be-bop-config='nano beBOP/.env.local'
alias be-bop-reboot='source reboot.sh'
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Installation des dépendances logicielles $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
apt-get update
apt-get install openssh-server net-tools curl wget dnf bash unzip -y
apt-get install ufw -y
rm -rf /var/www/html/*
apt-get install git-all git-lfs -y
#apt-get install ca-certificates -y
#install -m 0755 -d /etc/apt/keyrings
#curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
#sleep 3
#chmod a+r /etc/apt/keyrings/docker.asc
#echo \
#  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
#  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
#  tee /etc/apt/sources.list.d/docker.list
#apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Installation des outils Docker $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Installation du reverse proxy $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
apt-get install nginx -y
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Installation de NodeJS $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
curl --silent https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
sleep 3
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 20
nvm alias default 20
#corepack enable #useless for docker-compose
#corepack use [email protected] #useless for docker-compose
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Configuration réseau (reverse-proxy) de votre be-BOP $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
systemctl stop apache2
systemctl disable apache2
npm install pm2 -g
rm -rf /etc/nginx/sites-enabled/default
rm -rf /etc/nginx/sites-enabled/node
rm -rf /etc/nginx/sites-available/node
echo \
"  server {
     server_name $websiteUrl;
     location / {
         proxy_set_header   X-Forwarded-For \$remote_addr;
         proxy_set_header   Host \$http_host;
         proxy_pass         \"http://127.0.0.1:3000\";
     }
  }
  server {
     server_name $minioUrl;
     # Allow special characters in headers
     ignore_invalid_headers off;
     # Allow any size file to be uploaded.
     # Set to a value such as 1000m; to restrict file size to a specific value
     client_max_body_size 0;
     # Disable buffering
     proxy_buffering off;
     proxy_request_buffering off;
      location / {
                proxy_set_header Host \$http_host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto \$scheme;
        proxy_connect_timeout 300;
        # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
        proxy_http_version 1.1;
        proxy_set_header Connection \"\";
          proxy_pass         \"http://127.0.0.1:9000\";
      }
  }" >> /etc/nginx/sites-available/node
ln -s /etc/nginx/sites-available/node /etc/nginx/sites-enabled/node
systemctl restart nginx
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Configuration du pare-feu $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
ufw allow 22
ufw allow 80
ufw allow 443
ufw allow from any to 172.17.0.1 port 9740
ufw default deny incoming
ufw --force enable
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Installation et configuration de Phoenix Server (by ACinq) $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
wget https://github.com/ACINQ/phoenixd/releases/download/v0.4.2/phoenix-0.4.2-linux-x64.zip
unzip -j phoenix-0.4.2-linux-x64.zip
pm2 start --name phoenixd ./phoenixd -- --http-bind-ip=172.17.0.1
sleep 3
echo -e "$(tput setaf 3)\nHere's your Phoenix Server seed. Note it, keep it safe, and don't use it elsewhere.$(tput sgr0)\n"
cat ~/.phoenix/seed.dat
while :
do
  echo -e "\n"
  read -p "$(tput setaf 6)Did you note your seed ? Confirm with \"yes\" : $(tput sgr0)" agreementSeed
  if [[ $agreementSeed == "yes" ]]
  then
    break;
  fi
done
echo -e "$(tput setaf 3)\nHere's your Phoenix Server HTTP Password. It'll be useful to cash-in with Lightning on your be-BOP. Note it and keep it for later.$(tput sgr0)\n"
cat ~/.phoenix/phoenix.conf
while :
do
  echo -e "\n"
  read -p "$(tput setaf 6)Did you note your password ? Confirm with \"yes\" : $(tput sgr0)" agreementHttpPwd
  if [[ $agreementHttpPwd = "yes" ]]
  then
    break;
  fi
done
pm2 save
pm2 startup
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Installation et lancement de be-BOP $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
git clone https://github.com/B2Bitcoin/beBOP.git
sleep 3
cd beBOP
echo "ORIGIN=https://$websiteUrl" >> .env.local
echo "ADDRESS_HEADER=X-Forwarded-For" >> .env.local*
echo "XFF_DEPTH=1" >> .env.local*
echo "S3_KEY_ID=$(openssl rand -base64 63 | tr -d '\n')" >> .env.local*
echo "S3_KEY_SECRET=$(openssl rand -base64 63 | tr -d '\n')" >> .env.local*
echo "PUBLIC_S3_ENDPOINT_URL=https://$minioUrl" >> .env.local*
echo "S3_PROXY_DOWNLOADS=true" >> .env.local*
echo "NOSTR_PRIVATE_KEY=$nsecNostr" >> .env.local*
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Lancement de be-BOP... $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
docker compose pull
docker compose --env-file .env.local up --build -d
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Configuration des certificats SSL (https) $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
apt install snapd -y
snap install core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
echo -e "$(tput setaf 3)\nFill a valid email, valid th Certbot terms of use, subscribe (or not) then generate the SSL certificate for the first site option$(tput sgr0)\n"
certbot --nginx
echo -e "$(tput setaf 3)\nGenerate the SSL certificate for the second site option$(tput sgr0)\n"
certbot --nginx
sleep 3
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 3)Redémarrage de la configuration réseau... ... ... ... ... ... ... $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
systemctl restart nginx
pm2 restart phoenixd
curlUrl="https://$websiteUrl/.well-known/version.txt"
echo "Waiting for be-BOP to be ready..."
while ! curl --fail $curlUrl; do   
  sleep 5 # wait for 1/10 of the second before check again
done
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
echo -e "$(tput setaf 2)Votre be-BOP est désormais accessible sur https://$websiteUrl $(tput sgr0)"
echo -e "$(tput setaf 5)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++$(tput sgr0)"
cd ..

Know issues :

  • unzip is not deployed (we need to install it manually then rerun the script) on some VM
  • some nginx unticketted issue (yet to come)
  • after these installations, a pull / docker compose reboot goes to freeze and need a VM restart

@Tirodem
Copy link
Contributor Author

Tirodem commented Feb 4, 2025

also, note :

  • we need 2 domains (one for be-BOP, one for be-BOP docker-composed minio)
  • I was never able to make it work without being logged as sudo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant