ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Solved VitalPBX setup script on Vultr

    IT Discussion
    vitalpbx vultr linux shell bash scripting
    2
    5
    781
    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.
    • JaredBuschJ
      JaredBusch
      last edited by JaredBusch

      Setting up a boot script on Vultr to install Vital PBX is a snap.

      @scottalanmiller posted a guide on it a year ago.

      But I want to take a few more actions and, unfortunately, the VitalPBX script ends with this.

      # Enable the http access:
      firewall-cmd --add-service=http
      firewall-cmd --reload
      
      # Reboot System to Make Selinux Change Permanently
      echo "Rebooting System"
      reboot
      

      So you cannot do anything after the ./vps.sh in the Vultr Boot Script.

      I have a file hosted do-stuff.sh that I want to pull down and execute right before that reboot.
      Pulling it down is easy. add the wget to the Vultr Boot script prior to calling the ./vps.sh

      But how can I insert it after the filewall statement above?

      Should I trim the last 3 lines from the file, concatenate my file and then add the reboot back?

      M 1 Reply Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch
        last edited by

        ok the head command will do what I want.

        Here is what my Vultr Setup script now looks like. Spinning up an instance to test.

        #!/bin/sh
        
        export FIRST_USER='jbusch'
        
        yum update -y
        yum install wget htop glances sngrep -y
        wget https://raw.githubusercontent.com/VitalPBX/VPS/vitalpbx-3/vps.sh
        wget https://gitlab.com/sorvani/vitalpbx/-/raw/master/bundy_setup.txt
        
        head -n -3 vps.sh > setup_vps.sh
        cat bundy_setup.txt >> setup_vps.sh
        chmod +x setup_vps.sh
        ./setup_vps.sh
        
        1 Reply Last reply Reply Quote 0
        • M
          manxam @JaredBusch
          last edited by manxam

          @JaredBusch : If I'm understanding you correctly, you want to insert something between the last "firewall-cmd" and the "reboot".

          How about using sed to insert the text you want added?
          Something like :

          sed -i -e "/^firewall-cmd --reload$/a"$'\\\n'"sh ./do-stuff.sh"$'\n' vps.sh
          

          This should result in :

          # Enable the http access:
          firewall-cmd --add-service=http
          firewall-cmd --reload
          sh ./do-stuff.sh
          
          # Reboot System to Make Selinux Change Permanently
          echo "Rebooting System"
          reboot
          
          1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by

            ok the head command will do what I want.

            Here is what my Vultr Setup script now looks like. Spinning up an instance to test.

            #!/bin/sh
            
            export FIRST_USER='jbusch'
            
            yum update -y
            yum install wget htop glances sngrep -y
            wget https://raw.githubusercontent.com/VitalPBX/VPS/vitalpbx-3/vps.sh
            wget https://gitlab.com/sorvani/vitalpbx/-/raw/master/bundy_setup.txt
            
            head -n -3 vps.sh > setup_vps.sh
            cat bundy_setup.txt >> setup_vps.sh
            chmod +x setup_vps.sh
            ./setup_vps.sh
            
            1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch
              last edited by

              That worked.

              f46294c7-34f4-4fae-8ddf-ddb58ceaa7c0-image.png

              7c779935-9a4f-4952-9c5e-570646772bd7-image.png

              1 Reply Last reply Reply Quote 0
              • JaredBuschJ
                JaredBusch
                last edited by

                e0defcac-7cf0-4601-8e04-178a60ea74ed-image.png

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post