Преглед на файлове

FD3-231 supervisord + apache + cron. Webservice y script para crear crontab

Guillermo Espinoza преди 7 години
родител
ревизия
e575ae0bdd
променени са 6 файла, в които са добавени 8210 реда и са изтрити 1 реда
  1. 8 1
      supervisord/Dockerfile
  2. 8 0
      supervisord/conf.d/apache.conf
  3. 6 0
      supervisord/conf.d/cron.conf
  4. 22 0
      supervisord/wsdl/cron.php
  5. 18 0
      supervisord/wsdl/cron.sh
  6. 8148 0
      supervisord/wsdl/nusoap.php

+ 8 - 1
supervisord/Dockerfile

@@ -3,8 +3,12 @@ FROM debian:8.0
 RUN apt-get update && apt-get install -yq parallel git vim tmux python-pip lockfile-progs expect telnet
 RUN pip install supervisor
 
+RUN apt-get update && apt-get install -yq sudo php5 php5-cli php5-mysql php-pear php-soap php5-xsl
+RUN apt-get update && apt-get install -yq cron patch apache2 libapache2-mod-php5
+COPY wsdl/ /var/www/html/	
+
 RUN mkdir -p /var/log/supervisor/
-EXPOSE 9001
+EXPOSE 9001 80/tcp
 
 ##################################################################
 #sshd server
@@ -32,5 +36,8 @@ RUN chown root:root -R /etc/ssh/keys
 EXPOSE 22
 ##################################################################
 
+RUN touch /var/log/cron.log
+RUN echo 'www-data ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo
+
 CMD bash -c "/usr/sbin/sshd ; while true; do supervisord --configuration /etc/supervisord/supervisor.conf  --nodaemon ; sleep 5 ; done"
 

+ 8 - 0
supervisord/conf.d/apache.conf

@@ -0,0 +1,8 @@
+[program:apache]
+command=/usr/sbin/apachectl -DFOREGROUND
+redirect_stderr=true
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+autorestart=true
+user=root
+environment=HOME="/root",USER="root"

+ 6 - 0
supervisord/conf.d/cron.conf

@@ -0,0 +1,6 @@
+[program:cron]
+command=/usr/sbin/cron -f L 4
+redirect_stderr=true
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+autorestart=true

+ 22 - 0
supervisord/wsdl/cron.php

@@ -0,0 +1,22 @@
+<?php
+
+require_once "nusoap.php";
+
+function crontab($filename, $content) {
+    if ($content !== "" && $filename !== "") {
+        $dir = '/tmp/cron.d/';
+        $tmpfile = $dir . time();
+        
+        shell_exec("sudo /var/www/html/cron.sh {$tmpfile} '{$content}' {$filename}");
+        shell_exec("/etc/init.d/cron reload");
+        
+        return "Crontab created {$filename} {$content}";
+    } else {
+        return "Crontab content empty";
+    }
+}
+
+$server = new soap_server();
+$server->configureWSDL('crontab', 'localhost?wsdl');
+$server->register("crontab", array("filename" => "xsd:string", "content" => "xsd:string"), array("return" => "xsd:string"));
+$server->service($HTTP_RAW_POST_DATA);

+ 18 - 0
supervisord/wsdl/cron.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+
+filename=$1
+content=$2
+symlink=$3
+
+DIRECTORY=/tmp/cron.d
+if [ ! -d "$DIRECTORY" ]; then
+    mkdir $DIRECTORY
+fi
+
+echo "$content" | tee $filename
+chmod 0644 $filename
+chown root:root $filename
+
+if [ ! -L $filename ]; then
+    ln -s $filename $symlink
+fi

Файловите разлики са ограничени, защото са твърде много
+ 8148 - 0
supervisord/wsdl/nusoap.php