I have use ur script and my own modified, ithink problem on my raspi or my os.
i use e173, e488, and vodafone zte, all being not responding after 1 hour.
i check from shell with
$ lsusb
modem detected
but if i check with
$ dmesg | grep tty
usb not shown
then i try to reload with command
$ sudo usb_modeswitch -c /etc/usb_modeswitch.conf
its back work again.
so i have modificate on startup.sh homegenie with thats command
now with your original script, or my own its work perfectly. 1 day i use it, not hang and stay respond all my command. so the problem is mine but i dont know coz the os or my hardware, or my raspi-config.
the problem is every i restart my homegenie or my raspi, GPIO status before restart is ON, after reset it to OFF, i dont know why, try to serach the problem.