Once or twice a day, when the service I'm building is in production I'll have to read a database that sits behind a VPN.
Now, in the development phase I've been doing as follows. As
root user I run:
openfortivpn -c /etc/openfortivpn/config
web user I run:
sh manage.sh sync_master
. /web/.env;. /web/bin/activate;/web/bin/python /web/src/manage.py $1 $2 $3
After the synchronisation happens, I go back to
root user and on the
screen I left the VPN connection open, I stop it using
Now I need to run this from crontab. So my question is twofold: Is this a good way of doing this? How can I put all this logic in a bash script?
PS: Running on Ubuntu 18.04.1 LTS