Commit d2453c40 authored by Julien Muchembled's avatar Julien Muchembled

randomsleep: simplify

parent 00261687
Pipeline #8410 failed with stage
in 0 seconds
...@@ -20,7 +20,7 @@ make-options = ...@@ -20,7 +20,7 @@ make-options =
post-make-hook = ${:_profile_base_location_}/dcron-hooks.py#d7985eef1ceef01af00ffb1d38708c8d:post_make_hook post-make-hook = ${:_profile_base_location_}/dcron-hooks.py#d7985eef1ceef01af00ffb1d38708c8d:post_make_hook
environment = environment =
PATH=${patch:location}/bin:%(PATH)s PATH=${patch:location}/bin:%(PATH)s
randomsleep_install = ${randomsleep:location} dummy = ${randomsleep:recipe}
[dcron-output] [dcron-output]
# Shared binary location to ease migration # Shared binary location to ease migration
......
...@@ -4,26 +4,12 @@ extends = ...@@ -4,26 +4,12 @@ extends =
../bash/buildout.cfg ../bash/buildout.cfg
[randomsleep] [randomsleep]
recipe = slapos.recipe.build recipe = slapos.recipe.template:jinja2
location = ${buildout:parts-directory}/${:_buildout_section_name_} rendered = ${buildout:bin-directory}/${:_buildout_section_name_}
bin_dir = ${buildout:bin-directory} template =
bash_script_code = inline:#!${bash:location}/bin/bash
if [ "$#" -ne 1 ]; then [ $# = 1 ] || {
echo "usage: randomsleep maxseconds" echo "usage: ${:_buildout_section_name_} maxseconds"
exit exit 1
fi }
exec ${coreutils:location}/bin/sleep $((RANDOM * $1 >> 15)).$((RANDOM * 100 >> 15)) exec ${coreutils:location}/bin/sleep $((RANDOM * $1 >> 15)).$((RANDOM * 100 >> 15))
wrapper_script_code =
#!${bash:location}/bin/bash
. ${:location}/randomsleep.bash
script =
os.makedirs(self.options['location'])
bash_script_path = os.path.join(self.options['location'], 'randomsleep.bash')
with open(bash_script_path, 'w') as f:
f.write(self.options['bash_script_code'])
wrapper_script_path = os.path.join(self.options['bin_dir'], 'randomsleep')
with open(wrapper_script_path, 'w') as f:
f.write(self.options['wrapper_script_code'])
os.chmod(wrapper_script_path, 0o750)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment