diff --git a/cli b/cli index 7da2a8e626306faae8e8b1440a8dcfa3fcf374c8..46f409f650a5953542bee9bf8bb5ca7c12421e77 100755 --- a/cli +++ b/cli @@ -1,14 +1,5 @@ #!/bin/bash -is_docker() { - if [ ! -z "$(which docker-compose 2>/dev/null)" ]; - then - echo "1" - else - echo "0" - fi -} - usage() { echo -e "Usage $0 <command> [args]\n" echo -e "COMMANDS\n" @@ -22,30 +13,25 @@ usage() { echo -e "update-submodule : Need to be run after installation or when updating Mirador or the plugin" } - cmdup="docker-compose up" cmddown="docker-compose down" +cmdinitsubmodule="git submodule init" +cmdupdatetsubmodule="git submodule update" +cmdbuildmirador="docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c 'cd /opt && npm install && npm run build:es'" +cmdbuildmiradorplugin="docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c 'cd /opt && npm install && npm run build'" MIRADOR_FOLDER=mirador-video-annotation MIRADOR_ANNOTATION_FOLDER=annotations-plugin -user=$(awk -F '=' '/DB_USERNAME/{print $2}' .env) -db=$(awk -F '=' '/DB_DATABASE/{print $2}' .env) -pass=$(awk -F '=' '/DB_PASSWORD/{print $2}' .env) -mysql="mysql -u $user $db -p$pass" - -DIR="$(dirname $0)" -SCRIPTS_DIR="$DIR/public/scripts" - action=$1 shift # Keep actions sorted case $action in "build-mirador") - cd $MIRADOR_FOLDER && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c "cd /opt && npm install && npm run build:es" + cd $MIRADOR_FOLDER && ;; "build-mirador-plugin") - cd $MIRADOR_ANNOTATION_FOLDER && docker run --rm -v $PWD:/opt -it node:12 /bin/sh -c "cd /opt && npm install && npm run build" + cd $MIRADOR_ANNOTATION_FOLDER && $cmdbuildmiradorplugin ;; "clean-mirador") cd $MIRADOR_FOLDER && rm -R -f node_modules package-lock.json @@ -66,16 +52,32 @@ case $action in usage ;; "install") - echo "TODO" + echo "** Start install ..." + FILE=.env + if [ ! -f "$FILE" ]; then + echo "** $FILE does not exist. Please copy .env template cp .env.template .env and set COMPOSE_FILE to suit your needs" + exit 0 + fi + + echo "** Submodule initialisation ..." + $cmdinitsubmodule + $cmdupdatesubmodule + echo "** Submodule initialized" + echo "** Building Mirador ..." + $cmdbuildmirador + echo "** Mirador build." + echo "** Building Mirador plugin ..." + $cmdbuildmiradorplugin + echo "** Mirador plugin build." ;; "up") $cmdup $@ ;; "init-submodules") - git submodule init + $cmdinitsubmodule ;; "update-submodules") - git submodule update + $cmdupdatesubmodule ;; *) echo "ERROR: No command given"