Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos
Commits
71d0c4fd
Commit
71d0c4fd
authored
Apr 19, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrapper script: use dash instead of bash
parent
605e564b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
27 deletions
+22
-27
slapos/recipe/librecipe/generic.py
slapos/recipe/librecipe/generic.py
+22
-27
No files found.
slapos/recipe/librecipe/generic.py
View file @
71d0c4fd
...
@@ -141,17 +141,18 @@ class GenericBaseRecipe(object):
...
@@ -141,17 +141,18 @@ class GenericBaseRecipe(object):
accepting to run only if no other instance is running.
accepting to run only if no other instance is running.
"""
"""
lines
=
[
'#!/bin/
ba
sh'
]
lines
=
[
'#!/bin/sh'
]
for
comment
in
comments
:
if
comments
:
lines
.
append
(
'# %s'
%
comment
)
lines
+=
'# '
,
'
\
n
# '
.
join
(
comments
),
'
\
n
'
if
environment
:
lines
.
append
(
'COMMAND='
+
shlex
.
quote
(
command
))
for
key
in
environment
:
lines
.
append
(
'export %s=%s'
%
(
key
,
environment
[
key
]))
for
key
in
environment
or
():
lines
.
append
(
'export %s=%s'
%
(
key
,
environment
[
key
]))
if
pidfile
:
if
pidfile
:
lines
.
append
(
dedent
(
"""
\
lines
.
append
(
dedent
(
"""
# Check for other instances
# Check for other instances
pidfile=%s
pidfile=%s
if [ -e $pidfile ]; then
if [ -e $pidfile ]; then
...
@@ -163,37 +164,31 @@ class GenericBaseRecipe(object):
...
@@ -163,37 +164,31 @@ class GenericBaseRecipe(object):
rm $pidfile
rm $pidfile
fi
fi
fi
fi
echo $$ > $pidfile"""
%
(
pidfile
,
command
)))
echo $$ > $pidfile"""
%
shlex
.
quote
(
pidfile
)))
# Inspired by http://stackoverflow.com/a/10826085
lines
.
append
(
dedent
(
"""
\
COMMAND=%s
lines
.
append
(
dedent
(
'''
# If the wrapped command uses a shebang, execute the referenced
# If the wrapped command uses a shebang, execute the referenced
# executable passing the script path as first argument.
# executable passing the script path as first argument.
# This is to workaround the limitation of 127 characters in #!
# This is to workaround the limitation of 127 characters in #!
if [[ -f $COMMAND && x$(head -c2 "$COMMAND") = x"#!" ]]; then
[ ! -f "$COMMAND" ] || {
SHEBANG=$(head -1 "$COMMAND")
[ "`head -c2`" != "#!" ] || read -r EXE ARG
INTERPRETER=( ${SHEBANG#
\
#!} )
} < "$COMMAND"
COMMAND="${INTERPRETER[@]} $COMMAND"
fi
exec $
COMMAND """
%
shlex
.
quote
(
command
)
))
exec $
EXE ${ARG:+"$ARG"} "$COMMAND"'''
))
parameters
=
map
(
shlex
.
quote
,
parameters
)
if
parameters_extra
:
# pass-through further parameters
parameters
.
append
(
'"$@"'
)
for
param
in
parameters
:
for
param
in
parameters
:
if
len
(
lines
[
-
1
])
<
40
:
if
len
(
lines
[
-
1
])
<
40
:
lines
[
-
1
]
+=
' '
+
shlex
.
quote
(
param
)
lines
[
-
1
]
+=
' '
+
param
else
:
else
:
lines
[
-
1
]
+=
'
\
\
'
lines
[
-
1
]
+=
'
\
\
'
lines
.
append
(
'
\
t
'
+
shlex
.
quote
(
param
))
lines
.
append
(
'
\
t
'
+
param
)
if
parameters_extra
:
# pass-through further parameters
lines
[
-
1
]
+=
'
\
\
'
lines
.
append
(
'
\
t
"$@"'
)
content
=
'
\
n
'
.
join
(
lines
)
+
'
\
n
'
lines
.
append
(
''
)
return
self
.
createFile
(
name
,
content
,
0700
)
return
self
.
createFile
(
name
,
'
\
n
'
.
join
(
lines
)
,
0700
)
def
createDirectory
(
self
,
parent
,
name
,
mode
=
0700
):
def
createDirectory
(
self
,
parent
,
name
,
mode
=
0700
):
path
=
os
.
path
.
join
(
parent
,
name
)
path
=
os
.
path
.
join
(
parent
,
name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment