2016-12-07 23:57:07 +00:00
#!/bin/bash
2016-12-14 14:06:04 +00:00
set -eo pipefail
2016-12-07 23:57:07 +00:00
platform = "Linux" # Assumed
2016-12-14 14:06:04 +00:00
uname = $( uname)
case $uname in
"Darwin" )
platform = "MacOS / OSX"
; ;
MINGW*)
platform = "Windows"
; ;
esac
2016-12-07 23:57:07 +00:00
usage( ) {
2016-12-08 19:02:37 +00:00
echo " Usage: $0 <command> [options] "
2016-12-07 23:57:07 +00:00
echo
echo "This program helps to manage the setup/teardown of the docker containers for running WebODM. We recommend that you read the full documentation of docker at https://docs.docker.com if you want to customize your setup."
echo
echo "Command list:"
echo " start Start WebODM"
echo " stop Stop WebODM"
echo " update Update WebODM to the latest release"
echo " rebuild Rebuild all docker containers and perform cleanups"
exit
}
check_command( ) {
2016-12-29 21:15:59 +00:00
check_msg = "\033[92m\033[1m OK\033[0m\033[39m"
2016-12-07 23:57:07 +00:00
hash $1 2>/dev/null || not_found = true
if [ [ $not_found ] ] ; then
2016-12-29 21:15:59 +00:00
check_msg = " \033[91m can't find $1 ! Check that the program is installed before launching WebODM. $2 \033[39m "
2016-12-07 23:57:07 +00:00
fi
echo -e " Checking for $1 ... $check_msg "
2016-12-15 22:13:50 +00:00
if [ [ $not_found ] ] ; then
return 1
fi
2016-12-07 23:57:07 +00:00
}
environment_check( ) {
check_command "docker" "https://www.docker.com/"
check_command "git" "https://git-scm.com/downloads"
check_command "python" "https://www.python.org/downloads/"
2016-12-29 21:15:59 +00:00
check_command "pip" "Run \033[1msudo easy_install pip\033[0m"
check_command "docker-compose" "Run \033[1mpip install docker-compose\033[0m"
2016-12-07 23:57:07 +00:00
}
run( ) {
echo $1
$1
}
start( ) {
run "docker-compose -f docker-compose.yml -f docker-compose.nodeodm.yml up"
}
rebuild( ) {
run "docker-compose down"
2017-01-23 16:33:24 +00:00
run "rm -fr node_modules/ || sudo rm -fr node_modules/"
run "rm -fr nodeodm/external/node-OpenDroneMap || sudo rm -fr nodeodm/external/node-OpenDroneMap"
2016-12-07 23:57:07 +00:00
run "docker-compose build --no-cache"
2016-12-29 21:15:59 +00:00
echo -e " \033[1mDone!\033[0m You can now start WebODM by running ./ $0 start "
2016-12-07 23:57:07 +00:00
}
if [ [ $1 = "start" ] ] ; then
environment_check
echo "Starting WebODM..."
start
elif [ [ $1 = "stop" ] ] ; then
environment_check
echo "Stopping WebODM..."
docker-compose down
elif [ [ $1 = "rebuild" ] ] ; then
environment_check
echo "Rebuilding WebODM..."
rebuild
elif [ [ $1 = "update" ] ] ; then
echo "Updating WebODM..."
git pull origin master
2017-01-24 14:08:19 +00:00
run "docker pull pierotofy/nodeodm"
2016-12-07 23:57:07 +00:00
rebuild
else
usage
fi