Public Repository

Last pushed: 5 months ago
Short Description
pyMFrame Basis
Full Description

Serviceroutine

die Bash-Datei pymframe

#!/bin/bash
#
# description: Serviceroutine fuer Docker
#

service=`basename $0`
mkdir -p /var/log/$service

cli() {
        echo "Strting CLI for ${service}" | tee -a /var/log/$service/messages.log
        echo

        docker run -it -p 8000:80 \
           --rm \
           --name ${service} \
           -v $PWD/app:/usr/local/apache2/htdocs/ \
           -v $PWD/conf/extras/pymframe-alias.conf:/usr/local/apache2/conf/extras/pymframe-alias.conf \
           -v $PWD/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf \
           -v $PWD/datastore:/usr/local/apache2/htdocs/WEB-INF/datastore/ \
           ${service}-img /bin/bash
}

start() {
   echo "Starting ${service}" | tee -a /var/log/$service/messages.log
   echo
        chmod +x ./app/scripts/start.py

        echo -n "homedir: "
        echo $PWD

        docker run -dit -p 8000:80 \
      --rm \
           --name ${service} \
      -v $PWD/app:/usr/local/apache2/htdocs/ \
      -v $PWD/conf/extras/pymframe-alias.conf:/usr/local/apache2/conf/extras/pymframe-alias.conf \
      -v $PWD/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf \
      -v $PWD/datastore:/usr/local/apache2/htdocs/WEB-INF/datastore/ \
      ${service}-img
}

# Stop myapp
stop() {
   echo "Stopping ${service}" | tee -a /var/log/$service/messages.log
   docker stop ${service}
}

# Setzt Randbedingungen nach deploy
setup() {
   echo "Setup ${service}" | tee -a /var/log/$service/messages.log
   chmod -R +x app/scripts
   echo "Shebang line"
   head -1 app/scripts/start.py
   #sed --in-place '1s:^#! c:\\python27\\python.exe -u:#!/usr/bin/python:' app/scripts/start.py
   sed --in-place "1s/.*/\#\!\/usr\/bin\/python/" app/scripts/start.py
   head -1 app/scripts/start.py
   echo "set protection datastore"
   chmod -R 777 ./datastore
   }

### main logic ###
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        cli)
                cli
                ;;
        setup)
                setup
                ;;
        status)
                docker ps -a
                ;;
        buildimage)
                echo "building ${service}-img" | tee -a /var/log/$service/messages.log
                docker build -t "${service}-img" .
                echo "done"
                ;;
        restart)
                stop
                sleep 5s
                start
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|buildimage|setup}"
                exit 1
esac
Docker Pull Command
Owner
wnagy

Comments (0)