ITS-Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    NodeBB Docker Update Script

    Scheduled Pinned Locked Moved IT-Stuff
    1 Posts 1 Posters 406 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      admin
      last edited by admin

      Hi,

      I made it easier to Update NodeBB in Docker Container for peaople who Build themself.

      Nodebb has to be in Folder nodebb, otherwise it wont find the installation.

      #!/bin/bash
      
      nodebb_path="/root"
      nodebb_compose="docker-compose-orgi.yml"
      
      plugins_ol="nodebb-plugin-embed \
      nodebb-plugin-math-captcha \
      nodebb-plugin-embed \
      nodebb-plugin-emoji-android \
      nodebb-plugin-google-analytics \
      nodebb-plugin-sso-google \
      nodebb-plugin-tenor-gif \
      nodebb-plugin-sso-github"
      
      if [ ! -f "$nodebb_compose" ]; then
         echo "Compose does not exist, aborting"
         exit 1
      fi
      
      if [ ! -d "$nodebb_path/nodebb" ]; then
         echo "Path not exist, aborting"
         exit 1
      fi
      
      # Backup current Data
      
      if [ -d "$nodebb_path/nodebb-backup" ]; then
        echo "nodebb-backup exist"
        read -p "Delete old backup? (Y/N): " confirm
        if [[ $confirm == [Yy] ]]; then
        echo "Deleting backup"
        rm -rf $nodebb_path/nodebb-backup
      else
        echo "Do not Update without current backup"
        exit 1
      fi
      fi
      
      echo "Backup NodeBB Folder"
      cp -r "$nodebb_path/nodebb/" "$nodebb_path/nodebb-backup"
      echo "Backup NodeBB Image"
      docker save nodebb-nodebb:latest | gzip > "$nodebb_path/nodebb-backup/nodebb-nodebb_latest.tar.gz"
      
      echo -e "\nFetch NodeBB Repository\n"
      git fetch
      
      echo -e "\nReset NodeBB Base\n"
      git reset --hard origin/v4.x
      
      echo -e "\nChange NodeBB User and Group\n"
      chown -R 1001:1001 .docker public
      
      echo -e "\nModify Dockerfile with Plugins\n"
      if [[ $(grep -c "npm install" Dockerfile) -lt 2 ]]; then
      sed -i "/EXPOSE 4567/a RUN npm install $plugins_ol" Dockerfile
      fi
      #echo "NPM Install count $(grep -c "npm install" Dockerfile)"
      
      echo -e "\nBuilding NodeBB Image\n"
      docker compose -f $nodebb_compose build
      
      echo -e "\nDeploy NodeBB Image\n"
      docker compose -f $nodebb_compose up -d
      
      counter=0
      while [ $(docker logs nodebb-nodebb-1 | grep -c "NodeBB is now listening") -lt 1 ]; do
         docker logs --tail 20 nodebb-nodebb-1
         sleep 10
         counter=$((counter+1))
         if [[ "$counter" -ge "30" ]]; then
            echo -e "\nNodeBB not Coming up, please investigate\n"
            exit 1
         fi
      done
      
      docker logs --tail 20 nodebb-nodebb-1
      
      echo -e "\nChecking Plugins\n"
      
      docker exec -i nodebb-nodebb-1  npm list | grep nodebb > /tmp/nodebb-plugins.txt
      
      for i in $plugins_ol; do
          if [[ $(grep -c $i /tmp/nodebb-plugins.txt) == 1 ]]; then
             echo "Plugin Installed $i"
          else
               echo "Plugin Not Installed $i"
          fi
      done
      

      Greetings

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post
      Powered by NodeBB | Contributors