#!/bin/bash

#DESC Disable RTI realtime.

# stop services.
systemctl stop rti
systemctl stop bbj
systemctl stop bls

# prevent from starting on reboot.
systemctl disable rti
systemctl disable bbj
systemctl disable bls

# check to see if already disabled via this process.
[ -f /usr2/bbx/config/.rtoff ] && echo Real time already disabled. && exit 1

# comment out rti background jobs.
sed -i 's/^/#/g' /usr2/bbx/config/rtiBackgr

# comment out system cron jobs.
for file in `ls /etc/cron.d`
do 
[ "$file" != "nightly-backup" ] && sed -i 's/^/#/g' /etc/cron.d/$file
done

# commenting out users cron jobs.
for file in `ls /var/spool/cron`
do
sed -i 's/^/#/g' /var/spool/cron/$file
done

# disable dove login.
sed -i 's/^/#/g' /usr2/bbx/config/dove.ini

# move off doveserver.pl
mv /usr2/bbx/bin/doveserver.pl /usr2/bbx/bin/doveserver.pl.rtoff

# move off tcc links.
mv /usr2/bbx/bin/tcc /tmp
mv /usr2/bbx/bin/tcc_tws /tmp

# tell this process status.
touch /usr2/bbx/config/.rtoff
rm -f /usr2/bbx/config/.rton

echo "Real time disabled."

exit 0
