| 
														
															@@ -10,36 +10,34 @@ function mail_send { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               -S smtp-use-starttls \ 
														 | 
														
														 | 
														
															               -S smtp-use-starttls \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               -S smtp-auth=login \ 
														 | 
														
														 | 
														
															               -S smtp-auth=login \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               -S ssl-verify=ignore \ 
														 | 
														
														 | 
														
															               -S ssl-verify=ignore \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              -S smtp-auth-user=$(cat /run/secrets/jenkins-mail-user) \ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              -S smtp-auth-user=${JENKINS-MAIL-USER} \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               -S smtp-auth-password=$(cat /run/secrets/jenkins-mail-pass) \ 
														 | 
														
														 | 
														
															               -S smtp-auth-password=$(cat /run/secrets/jenkins-mail-pass) \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               -S nss-config-dir=/etc/pki/nssdb \ 
														 | 
														
														 | 
														
															               -S nss-config-dir=/etc/pki/nssdb \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-              -S from=$(cat /run/secrets/jenkins-mail-user) \ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+              -S from=${JENKINS-MAIL-USER} \ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															               ${RECIPIENT-MAIL-BOX} 
														 | 
														
														 | 
														
															               ${RECIPIENT-MAIL-BOX} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+if [ -z "$*" ]; then message="No domain specified!!!"; mail_send; exit 1;fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 if [ -d /${git_dir} ] 
														 | 
														
														 | 
														
															 if [ -d /${git_dir} ] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 then 
														 | 
														
														 | 
														
															 then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  cd /${git_dir} && git pull https://${GIT_USER}:$(cat /run/secrets/jenkins-mail-pass)@${git_url} && git checkout ${branch} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  cd /${git_dir} && git pull https://${GIT_USER}:$(cat /run/provision-pass)@${git_url} && git checkout ${branch} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if [ $? -ne 0 ];then message="Can't pull ${git_url}"; mail_send; exit 1;fi 
														 | 
														
														 | 
														
															   if [ $? -ne 0 ];then message="Can't pull ${git_url}"; mail_send; exit 1;fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 else 
														 | 
														
														 | 
														
															 else 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  cd / && git clone https://${GIT_USER}:$(cat /run/secrets/jenkins-mail-pass)@${git_url} && cd /${git_dir} && git checkout ${branch} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  cd / && git clone https://${GIT_USER}:$(cat /run/secrets/provision-pass)@${git_url} && cd /${git_dir} && git checkout ${branch} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if [ $? -ne 0 ];then message="Can't clone ${git_url}"; mail_send; exit 1;fi 
														 | 
														
														 | 
														
															   if [ $? -ne 0 ];then message="Can't clone ${git_url}"; mail_send; exit 1;fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 fi 
														 | 
														
														 | 
														
															 fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-if [ ! -z "$*" ] 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-then 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  domain=$(echo "$*" | sed 's/ / -d /g') 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  certbot certonly --dry-run --webroot -w /var/www/html --config-dir /${git_dir}/letsencrypt -m admin@sdsys.ru -d ${domain} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if [ $? -ne 0 ];then message="Can't execute "dry-run" for $(echo $*). Generate cert and key will be skipped!!!"; mail_send; exit 1;fi 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  certbot certonly --webroot -w /var/www/html --config-dir /${git_dir}/letsencrypt -m admin@sdsys.ru -d ${domain} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if [ $? -ne 0 ];then message="Can't generate cert and key for $(echo $*). See log !!!"; mail_send; exit 1;fi 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  echo "Generate new key and cert for $(echo $*)" > /tmp/commit.txt 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  cd /${git_dir} && git add -A && git config --global user.email "${JENKINS_MAIL}" && git config --global user.name "Jenkins" && git commit -F /tmp/commit.txt 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  git push https://${GIT_USER}:$(cat /run/secrets/jenkins-mail-pass)@${git_url} ${branch} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if [ $? -ne 0 ];then message="Can't push diff to ${git_url} !!!"; mail_send; exit 1;fi 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  message="Certs for domain $(echo $*) is generated!!!" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  mail_send 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-else 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  message="No domain specified!!!" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  mail_send 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-fi 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+domain=$(echo "$*" | sed 's/ / -d /g') 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+certbot certonly --dry-run --webroot -w /var/www/html --config-dir /${git_dir}/letsencrypt -m admin@sdsys.ru -d ${domain} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+if [ $? -ne 0 ];then message="Can't execute "dry-run" for $(echo $*). Generate cert and key will be skipped!!!"; mail_send; exit 1;fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+certbot certonly --webroot -w /var/www/html --config-dir /${git_dir}/letsencrypt -m admin@sdsys.ru -d ${domain} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+if [ $? -ne 0 ];then message="Can't generate cert and key for $(echo $*). See log !!!"; mail_send; exit 1;fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+echo "Generate new key and cert for $(echo $*)" > /tmp/commit.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+cd /${git_dir} && git add -A && git config --global user.email "${JENKINS_MAIL}" && git config --global user.name "Jenkins" && git commit -F /tmp/commit.txt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+git push https://${GIT_USER}:$(cat /run/secrets/provision-pass)@${git_url} ${branch} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+if [ $? -ne 0 ];then message="Can't push diff to ${git_url} !!!"; mail_send; exit 1;fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+message="Certs for domain $(echo $*) is generated!!!" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mail_send 
														 |