From 0f3bcf30ae748a75c22a03d4655dba4d8dc71185 Mon Sep 17 00:00:00 2001 From: startxfr Date: Sat, 6 Feb 2016 02:53:52 +0100 Subject: modif de conf OS --- OS/Dockerfile | 8 +++++--- OS/docker-compose.yml | 4 +++- OS/run.sh | 7 +++---- OS/sx-lib.sh | 31 +++++++++++++++++++++++++------ 4 files changed, 36 insertions(+), 14 deletions(-) (limited to 'OS') diff --git a/OS/Dockerfile b/OS/Dockerfile index da351a2..82c9a7a 100644 --- a/OS/Dockerfile +++ b/OS/Dockerfile @@ -7,10 +7,12 @@ RUN dnf -y install deltarpm pwgen tar python-dnf-plugins-extras-migrate && \ dnf-2 migrate && \ dnf -y install psmisc procps coreutils findutils iputils net-tools wget logrotate zip && \ dnf clean all +ENV STARTUPLOG=/logs/startup.log \ + LOG_PATH=/logs COPY *.sh /bin/ RUN chmod 775 /bin/sx-lib.sh /bin/run.sh && \ - mkdir /data && \ - mkdir /data/logs -ENV TERM=xterm + mkdir /data /logs && \ + touch $STARTUPLOG +VOLUME [$LOG_PATH] CMD ["/bin/run.sh"] diff --git a/OS/docker-compose.yml b/OS/docker-compose.yml index b062fc8..bd30b96 100644 --- a/OS/docker-compose.yml +++ b/OS/docker-compose.yml @@ -8,4 +8,6 @@ fedora: environment: CONTAINER_TYPE: "os" CONTAINER_SERVICE: "fedora" - CONTAINER_INSTANCE: "os-fedora" \ No newline at end of file + CONTAINER_INSTANCE: "os-fedora" + volumes: + - "/tmp/container/logs/fedora:/logs" \ No newline at end of file diff --git a/OS/run.sh b/OS/run.sh index 13a5bd4..e491694 100644 --- a/OS/run.sh +++ b/OS/run.sh @@ -1,7 +1,6 @@ #!/bin/bash source /bin/sx-lib.sh -check_environment -display_container_header -display_container_started -tail -f /etc/redhat-release \ No newline at end of file +check_environment | tee -a $STARTUPLOG +display_container_header | tee -a $STARTUPLOG +start_service \ No newline at end of file diff --git a/OS/sx-lib.sh b/OS/sx-lib.sh index 0df6f9c..3d9691a 100644 --- a/OS/sx-lib.sh +++ b/OS/sx-lib.sh @@ -1,6 +1,7 @@ #!/bin/bash -export TERM=dumb +export TERM=xterm +pid=0 function check_environment { if [ ! -v CONTAINER_TYPE ]; then @@ -39,8 +40,26 @@ function display_container_header { echo "+=====================================================" } -function display_container_started { - echo "+=====================================================" - echo "| Container $HOSTNAME is now running..." - echo "+=====================================================" -} \ No newline at end of file +function stop_handler { + echo "+=====================================================" | tee -a $STARTUPLOG + echo "| Container $HOSTNAME is now STOPPED" | tee -a $STARTUPLOG + echo "+=====================================================" | tee -a $STARTUPLOG + if [ $pid -ne 0 ]; then + kill -SIGTERM "$pid" + wait "$pid" + fi + exit 143; # 128 + 15 -- SIGTERM +} + +function start_service { + trap 'kill ${!}; stop_handler' SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL SIGSTOP SIGCONT + echo "+=====================================================" | tee -a $STARTUPLOG + echo "| Container $HOSTNAME is now RUNNING" | tee -a $STARTUPLOG + echo "+=====================================================" | tee -a $STARTUPLOG + tail -f /dev/null & + pid="$!" + while true + do + tail -f /dev/null & wait ${!} + done +} -- cgit v1.2.1