dubdiff/startup
2015-02-15 15:15:48 -05:00

98 lines
2.8 KiB
Bash
Executable File

#! /bin/bash
echo "* this script must be run as super user"
# Start a data container, an ssh server, a mongodb instance and a samba server
echo
# test if the data-db container has been created
if docker inspect -f {{.Name}} data-db
then
echo "* data-db exists"
else
echo "* creating data-db"
# The data container has a volume at /data/db, is named 'data' and is based on busybox
docker create -v /data/db --name data-db busybox echo "Data container - database"
fi
echo
# test if the mongo db server has been created
if docker inspect -f {{.Name}} mongodb
then
# make sure the server is running
if docker inspect -f {{.State.Running}} mongodb
then
echo "* mongodb exists and is running"
else
echo "* starting mongodb"
docker start mongodb
fi
else
echo "* creating new mongodb server"
# Start a mongo db server as a daemon
# The server will restart automatically on boot and will use the data-db container as a volume
docker run -p 27017 --name=mongodb --volumes-from=data-db -d mongo
fi
echo
# test if the data-files container has been created
if docker inspect -f {{.Name}} data-files
then
echo "* data-files exists"
else
echo "* creating data-files"
# The data container has a volume at /data/db, is named 'data' and is based on busybox
docker create -v /data --name data-files busybox echo "Data container - files"
# To connect a client to this server we would:
# sudo docker run --link=mongodb:mongodb -i mongo mongo --host mongodb
fi
echo
#make sure the samba server is running
if docker inspect -f {{.State.Running}} samba-server
then
echo "* samba-server running"
else
# create the samba server
echo "* creating samba server"
sudo docker run --rm -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba data-files
fi
echo
# test if the mean-dev container has been created
if docker inspect -f {{.Name}} mean-dev
then
# make sure the server is running
if docker inspect -f {{.State.Running}} mean-dev
then
echo "* mean-dev exists and is running"
else
echo "* starting mean-dev"
fi
else
echo "* creating mean-dev"
docker run -d --name=mean-dev --volumes-from=data-files --link=mongodb:mongodb -p=8000:8000 -p=9000:9000 -p=3000:3000 -p=35729:35729 -it adamarthurryan/mean-dev
fi
echo
echo
echo "* to attach to the mean-dev server: "
echo "> sudo docker attach mean-dev"
echo
echo "* to run an instance for access to tools:"
echo "> sudo docker run --volumes-from=data-files --rm -it adamarthurryan/mean-dev"
echo
echo "* or maybe you want another dev server:"
echo "docker run -d --name=thename --volumes-from=data-files --link=mongodb:mongodb -p=localnum:9000 -p=localnum:34729 -it adamarthurryan/mean-dev"
echo
echo "* mount the data folder with ./mount-data"