[ADD] Launch script: Add documentation
This commit is contained in:
		
							
								
								
									
										53
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | ||||
| # Gissmo Launch Script | ||||
|  | ||||
| This script, called **Gissmo Launcher**, aims to manage Docker containers while working on Gissmo project (Cf. https://github.com/eost/gissmo/). | ||||
|  | ||||
| It's not a part of previous Github's branch because of its current private state. I hope this will change. | ||||
|  | ||||
| ## Requirements | ||||
|  | ||||
| I suggest you to check these points befaure using Gissmo Launcher: | ||||
|  | ||||
|   * docker | ||||
|   * bash (Bourne Again Shell) | ||||
|   * tput command (try ```which tput``` to know if you have it) | ||||
|   * a default configuration file to give Gissmo Launcher some data | ||||
|  | ||||
| ## Configuration file | ||||
|  | ||||
| Just copy *config.example* file to *config* one: | ||||
|  | ||||
|     cp ./config.example ./config | ||||
|  | ||||
| It should work. | ||||
|  | ||||
| If any problem, have a look into *config.example* file in which all possible parameters are given. | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| Just do: | ||||
|  | ||||
|     ./launch.sh | ||||
|  | ||||
| It will display you a list of available commands. | ||||
|  | ||||
| ## Examples | ||||
|  | ||||
| Here is an example on how I frequently use Gissmo Launcher: | ||||
|  | ||||
|     launch.sh init | ||||
|     launch.sh create | ||||
|     launch.sh restore ~/2015.05.06.dump | ||||
|     launch.sh migrate | ||||
|     launch.sh dev | ||||
|     launch.sh stop | ||||
|     launch.sh start python manage.py shell | ||||
|     launch.sh stop | ||||
|  | ||||
| ## A different configuration file | ||||
|  | ||||
| If you want to use another configuration file than current, use the **GISSMO_CFG** variable as: | ||||
|  | ||||
|     GISSMO_CFG=~/new_config launch.sh | ||||
|  | ||||
| It will use *new_config* file instead. | ||||
| @ -5,12 +5,19 @@ | ||||
| # This file gives parameters to launch Docker containers for Gissmo projects. | ||||
| # | ||||
| # PROJECT_DIR: will contains all python libraries and gissmo git repository | ||||
| # POSTGRES_VERSION: version of postgreSQL to fetch from Discourse public repo | ||||
| # POSTGRES_DOCKER_NAME: name of postgreSQL Docker container | ||||
| # DB_VOLUME_NAME: name of Docker created container that would be used for pSQL | ||||
| # GIT_BRANCH: name of default branch to retrieve | ||||
| # GISSMO_VERSION: used to generated Gissmo Docker image name. | ||||
| # GISSMO_DOCKER_NAME: used to generate each Gissmo Docker container | ||||
| # GISSMO_DOCKER_PORT: public port from which you will access to Gissmo | ||||
|  | ||||
| PROJECT_DIR="/home/olivier/gissmo_project" | ||||
| PROJECT_DIR="${HOME}/gissmo_project" | ||||
| POSTGRES_VERSION="9.5" | ||||
| POSTGRES_DOCKER_NAME="gissmo_db" | ||||
| DB_VOLUME_NAME="dbdata" | ||||
| GIT_BRANCH="restful" | ||||
| GISSMO_VERSION="1.5" | ||||
| # GISSMO_DOCKER_NAME="gissmo" | ||||
| GISSMO_DOCKER_PORT="8002" | ||||
|  | ||||
							
								
								
									
										64
									
								
								launch.sh
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								launch.sh
									
									
									
									
									
								
							| @ -28,7 +28,7 @@ if test -z "$GISSMO_CFG"; then | ||||
|   if ! test -f ${CONFIG_FILE}; then | ||||
|     CONFIG_FILE="${PWD}/${CONFIG_FILENAME}" | ||||
|     if ! test -f ${CONFIG_FILE}; then | ||||
|       echo "'config' file not found. Use 'config.example' file and copy it \\ | ||||
|       echo "'config' file not found. Use 'config.example' file and copy it  | ||||
| to 'config' one either in ${CONFIG_DEFAULT_DIR} or ${PWD}. Then try again!" | ||||
|       exit 1 | ||||
|     fi | ||||
| @ -83,38 +83,24 @@ not_implemented() { | ||||
| show_help() { | ||||
|   echo    "$PROGRAM COMMAND [arg ...]" | ||||
|   echo -e "  Where ${green}COMMAND${reset} is one of:" | ||||
|   echo -e "   - create          Create postgreSQL database volume and \ | ||||
|                       postgreSQL Docker container" | ||||
|   echo -e "   - dev [arg ...]   Mount Git repository directory AS VOLUME \ | ||||
|                       for Gissmo Docker container and launch it in \ | ||||
|                       'development' mode" | ||||
|   echo -e "   - init            Create project directory as python virtual \ | ||||
|                       environment, fetch git repository and install \ | ||||
|                       Python dependancies" | ||||
|   echo -e "   - migrate         Launch migration command: \ | ||||
|                       python manage.py migrate" | ||||
|   echo -e "   - create          Create postgreSQL database volume and | ||||
|                      postgreSQL Docker container" | ||||
|   echo -e "   - dev [arg ...]   Mount Git repository directory AS VOLUME | ||||
|                      for Gissmo Docker container and launch it in | ||||
|                      'development' mode" | ||||
|   echo -e "   - init            Create project directory as python virtual | ||||
|                      environment, fetch git repository and install | ||||
|                      Python dependancies" | ||||
|   echo -e "   - migrate         Launch migration command: | ||||
|                      python manage.py migrate" | ||||
|   echo -e "   - restore dump    Restore the given dump" | ||||
|   echo -e "   - start [arg ...] Launch Gissmo Docker container \ | ||||
|                       (created by 'create' command) with a name given \ | ||||
|                       in GISSMO_DOCKER_NAME variable. args is optional." | ||||
|   echo -e "   - stop            Stop Gissmo Docker container which name is \ | ||||
|                       GISSMO_DOCKER_NAME variable content" | ||||
|   echo -e "   - start [arg ...] Launch Gissmo Docker container | ||||
|                      (created by 'create' command) with a name given | ||||
|                      in GISSMO_DOCKER_NAME variable. args is optional." | ||||
|   echo -e "   - stop            Stop Gissmo Docker container which name is | ||||
|                      GISSMO_DOCKER_NAME variable content" | ||||
|   echo "" | ||||
|   echo "For an example you can use it in this order:" | ||||
|   echo "" | ||||
|   echo -e "    $PROGRAM init" | ||||
|   echo -e "    $PROGRAM create" | ||||
|   echo -e "    $PROGRAM restore ~/2015.05.06.dump" | ||||
|   echo -e "    $PROGRAM migrate" | ||||
|   echo -e "    $PROGRAM dev" | ||||
|   echo -e "    $PROGRAM stop" | ||||
|   echo -e "    $PROGRAM start python manage.py shell" | ||||
|   echo -e "    $PROGRAM stop" | ||||
|   echo "" | ||||
|   echo -e "If GISSMO_CFG used, you can specify another configuration file. \ | ||||
|                       Example:" | ||||
|   echo "" | ||||
|   echo -e "    GISSMO_CFG=~/new_config $PROGRAM" | ||||
|   echo "Use README.md file for more explanations." | ||||
|   # TODO: Add clean() command with args to: STOP and DELETE Gissmo container, | ||||
|   # STOP and DELETE postgreSQL container, DELETE dbdata OR do all these | ||||
|   # things into one. | ||||
| @ -144,7 +130,7 @@ check_command() { | ||||
|  | ||||
| test_docker_cmd() { | ||||
|   if test -z "$docker_cmd"; then | ||||
|     error_and_quit "Docker command not found. Install docker or fill\ | ||||
|     error_and_quit "Docker command not found. Install docker or fill | ||||
|  in the PATH." | ||||
|   fi | ||||
|   return 0 | ||||
| @ -171,15 +157,15 @@ test_create() { | ||||
|     error_and_quit "No database directory given (DB_DIR in config file)." | ||||
|   fi | ||||
|   if test -z "$DB_VOLUME_NAME"; then | ||||
|     error_and_quit "No database volume name given (DB_VOLUME_NAME in \ | ||||
|     error_and_quit "No database volume name given (DB_VOLUME_NAME in  | ||||
| config file)." | ||||
|   fi | ||||
|   if test -z "$POSTGRES_VERSION"; then | ||||
|     error_and_quit "No postgres version given (POSTGRES_VERSION in \ | ||||
|     error_and_quit "No postgres version given (POSTGRES_VERSION in  | ||||
| config file)." | ||||
|   fi | ||||
|   if test -z "$POSTGRES_DOCKER_NAME"; then | ||||
|     error_and_quit "You need a name for your Docker database container \ | ||||
|     error_and_quit "You need a name for your Docker database container  | ||||
| (POSTGRES_DOCKER_NAME in config file)." | ||||
|   fi | ||||
| } | ||||
| @ -198,7 +184,7 @@ dev() { | ||||
|   if [ $? -eq 1 ]; then | ||||
|     $docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -p ${GISSMO_DOCKER_PORT}:8000 -v ${GISSMO_DIR}:/opt/gissmo --name ${GISSMO_DOCKER_NAME} gissmo:${GISSMO_VERSION} ${ARGS:='development'} || error_and_quit "Failed to create and launch ${GISSMO_DOCKER_NAME} container." | ||||
|   else | ||||
|     error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need \ | ||||
|     error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need  | ||||
| another name please set GISSMO_DOCKER_NAME in configuration file." | ||||
|   fi | ||||
| } | ||||
| @ -228,7 +214,7 @@ init() { | ||||
|   fi | ||||
|   . bin/activate || error_and_quit "Failed entering python virtual environment" | ||||
|   cd $GISSMO_DIR | ||||
|   pip install -q -r requirements.txt || error_and_quit "Python dependancies \ | ||||
|   pip install -q -r requirements.txt || error_and_quit "Python dependancies  | ||||
| installation failed." | ||||
|   info "Python dependancies checked." | ||||
|   deactivate || error_and_quit "Failed exiting python virtual environment." | ||||
| @ -274,7 +260,7 @@ test_initial_start() { | ||||
|     error_and_quit "Docker file don't exists: ${DOCKERFILE}" | ||||
|   fi | ||||
|   if test -z "$GISSMO_DOCKER_PORT"; then | ||||
|     error_and_quit "No Gissmo Docker container port given \ | ||||
|     error_and_quit "No Gissmo Docker container port given  | ||||
| (GISSMO_DOCKER_PORT in config file)." | ||||
|   fi | ||||
|   test_postgresql_exists | ||||
| @ -302,7 +288,7 @@ start() { | ||||
|   if [ $? -eq 1 ]; then | ||||
|     $docker_cmd run -it --rm --link ${POSTGRES_DOCKER_NAME}:db -p ${GISSMO_DOCKER_PORT}:8000 -e SECRET_KEY="abcdefg" --name ${GISSMO_DOCKER_NAME} gissmo:${GISSMO_VERSION} $ARGS || error_and_quit "Failed to create and launch ${GISSMO_DOCKER_NAME} container." | ||||
|   else | ||||
|     error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need \ | ||||
|     error_and_quit "${GISSMO_DOCKER_NAME} is already launched! If you need  | ||||
| another name please set GISSMO_DOCKER_NAME in configuration file." | ||||
|   fi | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Olivier DOSSMANN
					Olivier DOSSMANN