2016-09-11 23:52:31 +00:00
#!/bin/bash
2017-03-16 13:35:41 +00:00
__dirname = $( cd $( dirname " $0 " ) ; pwd -P)
cd ${ __dirname }
2016-12-01 15:39:42 +00:00
2016-12-29 21:15:59 +00:00
echo -e "\033[92m"
2016-12-01 15:39:42 +00:00
echo " _ __ __ ____ ____ __ ___"
echo "| | / /__ / /_ / __ \/ __ \/ |/ /"
echo "| | /| / / _ \/ __ \/ / / / / / / /|_/ / "
echo "| |/ |/ / __/ /_/ / /_/ / /_/ / / / / "
echo "|__/|__/\___/_.___/\____/_____/_/ /_/ "
echo
2016-12-29 21:15:59 +00:00
echo -e "\033[39m"
2016-12-01 15:39:42 +00:00
2016-12-12 19:09:25 +00:00
almost_there( ) {
2016-12-01 15:39:42 +00:00
echo
echo "===================="
echo "You're almost there!"
echo "===================="
2016-12-12 19:09:25 +00:00
}
# Check python version
python -c "import sys;ret = 1 if sys.version_info <= (3, 0) else 0;print('Checking python version... ' + ('3.x, good!' if ret == 0 else '2.x'));sys.exit(ret);"
2016-12-14 14:06:04 +00:00
if [ $? -ne 0 ] ; then
2016-12-12 19:09:25 +00:00
almost_there
2016-12-29 21:15:59 +00:00
echo -e "\033[33mYour system is currently using Python 2.x. You need to install or configure your system to use Python 3.x. Check out http://docs.python-guide.org/en/latest/dev/virtualenvs/ for information on how to setup Python 3.x alongside your Python 2.x install.\033[39m"
2016-12-01 15:39:42 +00:00
echo
exit
fi
2016-12-12 19:09:25 +00:00
# Check GDAL version
2020-01-22 18:39:22 +00:00
python -c "import sys;import re;import subprocess;version = subprocess.Popen([\"gdalinfo\", \"--version\"], stdout=subprocess.PIPE).communicate()[0].decode().rstrip();ret = 0 if re.compile('^GDAL [2-9]\.[0-9]+').match(version) else 1; print('Checking GDAL version... ' + ('{}, excellent!'.format(version) if ret == 0 else version));sys.exit(ret);"
2016-12-14 14:06:04 +00:00
if [ $? -ne 0 ] ; then
2016-12-12 19:09:25 +00:00
almost_there
2016-12-29 21:15:59 +00:00
echo -e "\033[33mYour system is currently using a version of GDAL that is too old, or GDAL is not installed. You need to install or configure your system to use GDAL 2.1 or higher. If you have installed multiple versions of GDAL, make sure the newer one takes priority in your PATH environment variable.\033[39m"
2016-12-12 19:09:25 +00:00
echo
exit
fi
2017-05-19 20:39:43 +00:00
if [ " $1 " = "--setup-devenv" ] || [ " $2 " = "--setup-devenv" ] ; then
2017-03-15 16:25:02 +00:00
echo Setup git modules...
2017-03-16 13:35:41 +00:00
git submodule update --init
2017-03-15 16:25:02 +00:00
echo Setup npm dependencies...
npm install
2022-01-28 18:41:18 +00:00
2018-12-04 15:02:13 +00:00
cd nodeodm/external/NodeODM
2017-03-15 16:25:02 +00:00
npm install
2022-01-28 18:41:18 +00:00
2017-03-15 16:25:02 +00:00
cd /webodm
2018-12-07 20:13:49 +00:00
echo Setup pip requirements...
pip install -r requirements.txt
2021-01-12 15:06:02 +00:00
echo Build translations...
2021-05-26 20:01:52 +00:00
python manage.py translate build --safe
2021-01-12 15:06:02 +00:00
2017-03-15 16:25:02 +00:00
echo Setup webpack watch...
webpack --watch &
fi
2016-10-11 17:42:17 +00:00
2016-09-27 21:11:02 +00:00
echo Running migrations
python manage.py migrate
2016-09-11 23:52:31 +00:00
2019-08-14 16:24:07 +00:00
if [ [ " $WO_DEFAULT_NODES " > 0 ] ] ; then
2021-05-27 20:13:37 +00:00
i = 0
while [ $i -ne " $WO_DEFAULT_NODES " ]
do
i = $(( $i + 1 ))
2021-10-12 19:54:53 +00:00
NODE_HOST = $( python manage.py getnodehostname webodm_node-odm_$i )
python manage.py addnode $NODE_HOST 3000 --label node-odm-$i
2021-05-27 20:13:37 +00:00
done
2016-12-01 15:39:42 +00:00
fi
2019-05-26 16:35:52 +00:00
if [ [ " $WO_CREATE_MICMAC_PNODE " = "YES" ] ] ; then
2021-05-27 20:13:37 +00:00
python manage.py addnode node-micmac-1 3000
2019-05-10 00:24:27 +00:00
fi
2017-11-17 19:43:06 +00:00
export WO_HOST = " ${ WO_HOST : =localhost } "
export WO_PORT = " ${ WO_PORT : =8000 } "
2017-11-17 00:27:55 +00:00
2017-11-17 18:42:34 +00:00
# Dump environment to .cronenv
printenv > .cronenv
2017-11-17 20:18:17 +00:00
proto = "http"
if [ " $WO_SSL " = "YES" ] ; then
proto = "https"
fi
2018-04-08 20:21:09 +00:00
cat app/scripts/unlock_all_tasks.py | python manage.py shell
2018-02-19 20:50:26 +00:00
./worker.sh scheduler start
2017-11-17 21:41:41 +00:00
congrats( ) {
( sleep 5; echo
2018-08-11 20:55:24 +00:00
echo "Trying to establish communication..."
status = $( curl --max-time 300 -L -s -o /dev/null -w "%{http_code}" " $proto ://localhost:8000 " )
if [ [ " $status " = "200" ] ] ; then
echo -e "\033[92m"
echo "Congratulations! └@(・◡・)@┐"
echo = = = = = = = = = = = = = = = = = = = = = = = = = =
echo -e "\033[39m"
echo "If there are no errors, WebODM should be up and running!"
else
echo -e "\033[93m"
echo "Something doesn't look right! ¯\_(ツ)_/¯"
echo " The server returned a status code of $status when we tried to reach it. "
echo = = = = = = = = = = = = = = = = = = = = = = = = = =
echo -e "\033[39m"
echo "Check if WebODM is running, maybe we tried to reach it too soon."
fi
2017-11-17 21:41:41 +00:00
echo -e "\033[93m"
echo Open a web browser and navigate to $proto ://$WO_HOST :$WO_PORT
2023-03-30 20:31:38 +00:00
echo -e "\033[39m" ) &
2017-11-17 21:41:41 +00:00
}
2017-01-21 16:44:10 +00:00
2017-05-21 19:08:19 +00:00
if [ " $1 " = "--setup-devenv" ] || [ " $2 " = "--setup-devenv" ] || [ " $1 " = "--no-gunicorn" ] ; then
2017-11-17 21:41:41 +00:00
congrats
2017-05-19 20:15:26 +00:00
python manage.py runserver 0.0.0.0:8000
else
2017-09-03 15:07:19 +00:00
if [ -e /webodm ] && [ ! -e /webodm/build/static ] ; then
2017-06-05 22:32:26 +00:00
echo -e "\033[91mWARN:\033[39m /webodm/build/static does not exist, CSS, JS and other files might not be available."
2017-11-17 00:19:19 +00:00
fi
echo "Generating nginx configurations from templates..."
for templ in nginx/*.template
do
2017-11-17 19:43:06 +00:00
echo " - ${ templ %.* } "
envsubst '\$WO_PORT \$WO_HOST' < $templ > ${ templ %.* }
2017-11-17 00:19:19 +00:00
done
2017-11-17 18:42:34 +00:00
# Check if we need to auto-generate SSL certs via letsencrypt
2017-11-17 19:43:06 +00:00
if [ " $WO_SSL " = "YES" ] && [ -z " $WO_SSL_KEY " ] ; then
2017-11-17 21:29:45 +00:00
echo "Launching letsencrypt-autogen.sh"
./nginx/letsencrypt-autogen.sh
2017-11-17 18:42:34 +00:00
fi
# Check if SSL key/certs are available
conf = "nginx.conf"
2017-11-17 19:22:48 +00:00
if [ -e nginx/ssl ] ; then
2017-11-17 18:42:34 +00:00
echo "Using nginx SSL configuration"
conf = "nginx-ssl.conf"
fi
2017-11-17 21:41:41 +00:00
congrats
2017-11-17 18:42:34 +00:00
nginx -c $( pwd ) /nginx/$conf
2022-07-08 21:02:37 +00:00
gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 300000 --max-requests 500 --workers $(( 2 * $( grep -c '^processor' /proc/cpuinfo) + 1 )) --preload
2017-05-19 20:15:26 +00:00
fi
2017-01-21 16:44:10 +00:00
# If this is executed, it means the previous command failed, don't display the congratulations message
kill %1