First version of docker launch script

pull/66/head
Piero Toffanin 2016-12-07 18:57:07 -05:00
rodzic d9a56eb4ae
commit 49a8b1bf8e
1 zmienionych plików z 87 dodań i 0 usunięć

87
webodm.sh 100755
Wyświetl plik

@ -0,0 +1,87 @@
#!/bin/bash
platform="Linux" # Assumed
uname=`uname`
if [[ $uname == "Darwin" ]]; then
platform = "MacOS / OSX"
elif [[ $uname == MINGW* ]]; then
platform = "Windows"
fi
echo "Using platform: $platform"
usage(){
echo "Usage: $0 <command>"
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(){
check_msg="\e[92m\e[1m OK\e[0m\e[39m"
hash $1 2>/dev/null || not_found=true
if [[ $not_found ]]; then
check_msg="\e[91m can't find $1! Check that the program is installed before launching WebODM. $2\e[39m"
fi
echo -e "Checking for $1... $check_msg"
if [[ $not_found ]]; then
exit 1
fi
}
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/"
check_command "pip" "Run \e[1msudo easy_setup pip\e[0m"
check_command "docker-compose" "Run \e[1mpip install docker-compose\e[0m"
}
run(){
echo $1
$1
if [[ ! $? -eq 0 ]]; then
echo
echo "Doh! The last command returned an error. This might be an issue. Would you be so kind as to report it here? https://github.com/OpenDroneMap/WebODM/issues"
exit
fi
}
start(){
run "docker-compose -f docker-compose.yml -f docker-compose.nodeodm.yml up"
}
rebuild(){
run "docker-compose down"
run "rm -r node_modules/"
run "rm -r nodeodm/external/node-OpenDroneMap"
run "docker-compose build --no-cache"
echo "\e[1mDone!\e[0m You can now start WebODM by running ./$0 start"
}
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
rebuild
else
usage
fi