Last active
July 18, 2017 06:24
-
-
Save gautam678/8e6e2ec0ebff6b7001786b7c79f44f11 to your computer and use it in GitHub Desktop.
Setting up docker with solr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| option="${1}" | |
| container=$2 | |
| name=$3 | |
| sample=$4 | |
| case ${option} in | |
| -f) FILE=${name} | |
| echo "Pulling solr 6.4 from dockerhub"$'\n' | |
| docker pull solr:6.4 | |
| echo "Connecting and transferring files to docker image"$'\n' | |
| docker run --name $container -d -p 8983:8983 -t -v $HOME/Documents/Github/solr/data/ $sample:/opt/solr/mydata/$sample solr:6.4 | |
| docker exec -it --user=solr $container solr create_core -c $FILE | |
| docker exec -it --user=solr $container post -c $FILE mydata/$sample | |
| ;; | |
| -ls) | |
| a=$(docker container ls | wc -l) | |
| if [ $a -eq 1 ]; | |
| then | |
| echo "No Containers to list" | |
| else | |
| echo "List of docker images"$'\n' | |
| docker image ls | |
| echo $'\n' | |
| echo "List of docker containers"$'\n' | |
| docker container ls | |
| fi | |
| ;; | |
| -rm) | |
| echo "Removing and stopping all Containers"$'\n' | |
| a=$(docker container ls | wc -l) | |
| if [ $a -eq 1 ]; | |
| then | |
| echo "No Containers in docker" | |
| else | |
| docker stop $(docker ps -a -q) | |
| docker rm $(docker ps -a -q) | |
| fi | |
| ;; | |
| *) | |
| echo "`basename ${0}`:usage: [-f corename file ] | [-ls list of directories] | [-rm Remove all containers and images] " | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment