Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
certman
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
certman
Commits
fc25dbab
Commit
fc25dbab
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
added _wait_for_free_slot in cert actions to execute multiple processes sequentially
parent
7cdcb6f3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cm.sh
+26
-0
26 additions, 0 deletions
cm.sh
with
26 additions
and
0 deletions
cm.sh
+
26
−
0
View file @
fc25dbab
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
# 2021-04-12 <axel.hahn@iml.unibe.ch> reject multiple usage of fqdn in cli params
# 2021-04-12 <axel.hahn@iml.unibe.ch> reject multiple usage of fqdn in cli params
# 2021-04-12 <axel.hahn@iml.unibe.ch> optional: force excecution with a given user only
# 2021-04-12 <axel.hahn@iml.unibe.ch> optional: force excecution with a given user only
# 2021-06-24 <axel.hahn@iml.unibe.ch> added transfer command; delete files if acme.sh --install-cert ... failes
# 2021-06-24 <axel.hahn@iml.unibe.ch> added transfer command; delete files if acme.sh --install-cert ... failes
# 2021-07-14 <axel.hahn@iml.unibe.ch> added _wait_for_free_slot in cert actions to execute multiple processes sequentially
# ======================================================================
# ======================================================================
...
@@ -249,6 +250,26 @@ function _update(){
...
@@ -249,6 +250,26 @@ function _update(){
test
${
writelog
}
&&
echo
"[
$(
date
)
]
$*
"
>>
${
logfile
}
test
${
writelog
}
&&
echo
"[
$(
date
)
]
$*
"
>>
${
logfile
}
}
}
# "neverending" loop that waits until the current process is
# the one with lowest PID
function
_wait_for_free_slot
(){
local
_bWait
=
true
typeset
-i
local
_iFirstPID
=
0
_wd
"--- Need to wait until own process PID
$$
is on top ... "
while
[
$_bWait
=
true
]
;
do
_iFirstPID
=
$(
ps
-ef
|
grep
"bash.*
$0
"
|
grep
-v
"grep"
|
sort
-k
2
-n
|
head
-1
|
awk
'{ print $2}'
)
if
[
$_iFirstPID
-eq
$$
]
;
then
_bWait
=
false
_wd
"OK. Go!"
else
_wd
"- all instances"
test
${
showdebug
}
&&
ps
-ef
|
grep
"bash.*
$0
"
|
grep
-v
"grep"
|
sort
-k
2
-n
sleep
10
fi
done
}
# write debug output if showdebug is set to 1
# write debug output if showdebug is set to 1
function
_wd
(){
function
_wd
(){
test
${
showdebug
}
&&
echo
"DEBUG:
$*
"
test
${
showdebug
}
&&
echo
"DEBUG:
$*
"
...
@@ -304,6 +325,7 @@ function _testFqdncount(){
...
@@ -304,6 +325,7 @@ function _testFqdncount(){
# pulic function ADD certificate
# pulic function ADD certificate
#
#
function
public_add
(){
function
public_add
(){
_wait_for_free_slot
_requiresFqdn
_requiresFqdn
_certMustNotExist
_certMustNotExist
...
@@ -342,6 +364,7 @@ function public_add(){
...
@@ -342,6 +364,7 @@ function public_add(){
# pulic function ADD OR RENEW certificate
# pulic function ADD OR RENEW certificate
#
#
function
public_ensure
(){
function
public_ensure
(){
_wait_for_free_slot
_requiresFqdn
_requiresFqdn
_certExists
_certExists
if
[
$?
-eq
0
]
;
then
if
[
$?
-eq
0
]
;
then
...
@@ -369,6 +392,7 @@ function public_ensure(){
...
@@ -369,6 +392,7 @@ function public_ensure(){
# public function to delete a cert
# public function to delete a cert
#
#
function
public_delete
(){
function
public_delete
(){
_wait_for_free_slot
_requiresFqdn
_requiresFqdn
_certMustExist
_certMustExist
...
@@ -394,6 +418,7 @@ function public_list(){
...
@@ -394,6 +418,7 @@ function public_list(){
# public function - renew a certificate
# public function - renew a certificate
# param string fqdn of domain to renew
# param string fqdn of domain to renew
function
public_renew
(){
function
public_renew
(){
_wait_for_free_slot
_requiresFqdn
_requiresFqdn
_certMustExist
_certMustExist
$ACME
--renew
-d
${
CM_fqdn
}
$ACME_Params
$ACME
--renew
-d
${
CM_fqdn
}
$ACME_Params
...
@@ -525,6 +550,7 @@ function public_show(){
...
@@ -525,6 +550,7 @@ function public_show(){
# Transfer cert from acme.sh internal cache to our output dir again
# Transfer cert from acme.sh internal cache to our output dir again
function
public_transfer
(){
function
public_transfer
(){
_wait_for_free_slot
_requiresFqdn
_requiresFqdn
_certExists
_certExists
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment