Repeater hangs with script

I am somewhat new to allstar and Linux so sorry for the basic questions. I wrote a script that works but at the end if it, the repeater hangs until you key up one extra time.

Basically after the script runs you have to wait about a second and then kurchunk the repeater.

I am sure it something to do with me rebooting the server and the repeaters PTT line being inverted, now how to fix it?

Script below:
sudo sed -i ‘s/unlinkedct=ct1/unlinkedct=ct5/g’ /etc/asterisk/rpt.conf
sudo sed -i ‘s/2700001/180001/g’ /etc/asterisk/rpt.conf
sudo sed -i ‘s+tailmessagelist=/etc/asterisk/sounds/T07,/etc/asterisk/sounds/lark,/etc/asterisk/sounds/T03,/etc/asterisk/sounds/T04,/etc/asterisk/sounds/T05,/etc/asterisk/sounds/T08+tailmessagelist=/etc/asterisk/sounds/wx+g’ /etc/asterisk/rpt.conf
sudo asterisk -rx “rpt reload”
sleep 5
sudo asterisk -rx “rpt localplay 50165 /etc/asterisk/sounds/wx”

the script is called from a touch tone macro and replaces the rotating tail messages with skywarn message and a SW tone to tell users there is a net going on.

Figure out which statement is causing the hang by commenting out each statement one at a time. I’d start with the last asterisk -rx and work up the script until the culprit is uncovered.

One other thing to try is rather than doing asterisk -rx "reload rpt", restart asterisk with