Solved VitalPBX setup script on Vultr
-
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?
-
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
-
@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
-
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
-
That worked.
-