浏览代码

no message

tomishinets.v 6 年之前
父节点
当前提交
98afe9f542
共有 2 个文件被更改,包括 20 次插入5 次删除
  1. 1 1
      Dockerfile
  2. 19 4
      operation.sh

+ 1 - 1
Dockerfile

@@ -9,6 +9,6 @@ RUN yum install -y epel-release \
     && ln -sf /dev/stderr /var/log/nginx/error.log
 #COPY cli.ini /etc/letsencrypt/
 COPY default.conf /etc/nginx/conf.d/
-COPY letsencrypt/ /etc/letsencrypt/
+COPY pki/letsencrypt/ /etc/letsencrypt/
 EXPOSE 80
 CMD ["nginx", "-g", "daemon off;"]

+ 19 - 4
operation.sh

@@ -1,8 +1,23 @@
 #!/bin/bash
 JENKINS_MAIL="jenkins@sdsys.ru"
-git-dir="pki"
+git_dir="pki"
 branch="100883"
 
-cd /
-GIT_SSH_COMMAND='ssh -i /run/secrets/provision-ssh-key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' git clone ${git_url}
-cd ${git-dir} && git checkout ${branch}
+
+if [ -d /${git_dir} ]
+then
+  cd /${git_dir} && git checkout ${branch} && git pull
+else
+  cd / && GIT_SSH_COMMAND='ssh -i /run/secrets/provision-ssh-key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' git clone ${git_url}
+  cd /${git_dir} && git checkout ${branch}
+fi
+
+if [ -z $domain ]
+then
+  domain=$(echo ${domain} | sed 's/ / -d /g')
+  certbot certonly --dry-run --webroot -w /var/www/html --config-dir /${git_dir}/letsencrypt -d ${domain}
+  if [ $? -eq 0 ]
+  then
+    cd /${git_dir} && GIT_SSH_COMMAND='ssh -i /run/secrets/provision-ssh-key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' git push origin ${branch}
+  fi
+fi