[ADD] Launch script: Add documentation
This commit is contained in:
parent
6d97d5e9ac
commit
c046048fe2
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.
|
# This file gives parameters to launch Docker containers for Gissmo projects.
|
||||||
#
|
#
|
||||||
# PROJECT_DIR: will contains all python libraries and gissmo git repository
|
# 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_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_VERSION="9.5"
|
||||||
POSTGRES_DOCKER_NAME="gissmo_db"
|
POSTGRES_DOCKER_NAME="gissmo_db"
|
||||||
DB_VOLUME_NAME="dbdata"
|
DB_VOLUME_NAME="dbdata"
|
||||||
GIT_BRANCH="restful"
|
GIT_BRANCH="restful"
|
||||||
GISSMO_VERSION="1.5"
|
GISSMO_VERSION="1.5"
|
||||||
|
# GISSMO_DOCKER_NAME="gissmo"
|
||||||
GISSMO_DOCKER_PORT="8002"
|
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
|
if ! test -f ${CONFIG_FILE}; then
|
||||||
CONFIG_FILE="${PWD}/${CONFIG_FILENAME}"
|
CONFIG_FILE="${PWD}/${CONFIG_FILENAME}"
|
||||||
if ! test -f ${CONFIG_FILE}; then
|
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!"
|
to 'config' one either in ${CONFIG_DEFAULT_DIR} or ${PWD}. Then try again!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -83,38 +83,24 @@ not_implemented() {
|
|||||||
show_help() {
|
show_help() {
|
||||||
echo "$PROGRAM COMMAND [arg ...]"
|
echo "$PROGRAM COMMAND [arg ...]"
|
||||||
echo -e " Where ${green}COMMAND${reset} is one of:"
|
echo -e " Where ${green}COMMAND${reset} is one of:"
|
||||||
echo -e " - create Create postgreSQL database volume and \
|
echo -e " - create Create postgreSQL database volume and
|
||||||
postgreSQL Docker container"
|
postgreSQL Docker container"
|
||||||
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME \
|
echo -e " - dev [arg ...] Mount Git repository directory AS VOLUME
|
||||||
for Gissmo Docker container and launch it in \
|
for Gissmo Docker container and launch it in
|
||||||
'development' mode"
|
'development' mode"
|
||||||
echo -e " - init Create project directory as python virtual \
|
echo -e " - init Create project directory as python virtual
|
||||||
environment, fetch git repository and install \
|
environment, fetch git repository and install
|
||||||
Python dependancies"
|
Python dependancies"
|
||||||
echo -e " - migrate Launch migration command: \
|
echo -e " - migrate Launch migration command:
|
||||||
python manage.py migrate"
|
python manage.py migrate"
|
||||||
echo -e " - restore dump Restore the given dump"
|
echo -e " - restore dump Restore the given dump"
|
||||||
echo -e " - start [arg ...] Launch Gissmo Docker container \
|
echo -e " - start [arg ...] Launch Gissmo Docker container
|
||||||
(created by 'create' command) with a name given \
|
(created by 'create' command) with a name given
|
||||||
in GISSMO_DOCKER_NAME variable. args is optional."
|
in GISSMO_DOCKER_NAME variable. args is optional."
|
||||||
echo -e " - stop Stop Gissmo Docker container which name is \
|
echo -e " - stop Stop Gissmo Docker container which name is
|
||||||
GISSMO_DOCKER_NAME variable content"
|
GISSMO_DOCKER_NAME variable content"
|
||||||
echo ""
|
echo ""
|
||||||
echo "For an example you can use it in this order:"
|
echo "Use README.md file for more explanations."
|
||||||
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"
|
|
||||||
# TODO: Add clean() command with args to: STOP and DELETE Gissmo container,
|
# TODO: Add clean() command with args to: STOP and DELETE Gissmo container,
|
||||||
# STOP and DELETE postgreSQL container, DELETE dbdata OR do all these
|
# STOP and DELETE postgreSQL container, DELETE dbdata OR do all these
|
||||||
# things into one.
|
# things into one.
|
||||||
@ -144,7 +130,7 @@ check_command() {
|
|||||||
|
|
||||||
test_docker_cmd() {
|
test_docker_cmd() {
|
||||||
if test -z "$docker_cmd"; then
|
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."
|
in the PATH."
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
@ -171,15 +157,15 @@ test_create() {
|
|||||||
error_and_quit "No database directory given (DB_DIR in config file)."
|
error_and_quit "No database directory given (DB_DIR in config file)."
|
||||||
fi
|
fi
|
||||||
if test -z "$DB_VOLUME_NAME"; then
|
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)."
|
config file)."
|
||||||
fi
|
fi
|
||||||
if test -z "$POSTGRES_VERSION"; then
|
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)."
|
config file)."
|
||||||
fi
|
fi
|
||||||
if test -z "$POSTGRES_DOCKER_NAME"; then
|
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)."
|
(POSTGRES_DOCKER_NAME in config file)."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -198,7 +184,7 @@ dev() {
|
|||||||
if [ $? -eq 1 ]; then
|
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."
|
$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
|
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."
|
another name please set GISSMO_DOCKER_NAME in configuration file."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -228,7 +214,7 @@ init() {
|
|||||||
fi
|
fi
|
||||||
. bin/activate || error_and_quit "Failed entering python virtual environment"
|
. bin/activate || error_and_quit "Failed entering python virtual environment"
|
||||||
cd $GISSMO_DIR
|
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."
|
installation failed."
|
||||||
info "Python dependancies checked."
|
info "Python dependancies checked."
|
||||||
deactivate || error_and_quit "Failed exiting python virtual environment."
|
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}"
|
error_and_quit "Docker file don't exists: ${DOCKERFILE}"
|
||||||
fi
|
fi
|
||||||
if test -z "$GISSMO_DOCKER_PORT"; then
|
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)."
|
(GISSMO_DOCKER_PORT in config file)."
|
||||||
fi
|
fi
|
||||||
test_postgresql_exists
|
test_postgresql_exists
|
||||||
@ -302,7 +288,7 @@ start() {
|
|||||||
if [ $? -eq 1 ]; then
|
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."
|
$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
|
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."
|
another name please set GISSMO_DOCKER_NAME in configuration file."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user