Sunday, November 3, 2013

bash scripts organized with rerun

A small "rerun tutorial" or "getting started with rerun".
Rerun wiki: https://github.com/rerun/rerun/wiki

Download the rpm here

#remember to do export http_proxy=http://myuser:mypw@proxy.acme.com:8080

wget http://repository-stagrlee.forge.cloudbees.com/release/rpms/rerun/rerun-1.0.2-1.fc17.noarch.rpm
rpm -i rerun-1.0.2-1.fc17.noarch.rpm
rerun
Available modules in "/usr/lib/rerun/modules":
stubbs: "Simple rerun module builder" - 1.0.2


then I download https://github.com/downloads/rerun-modules/rerun-modules/rerun-modules-repo-1.0-21.noarch.rpm, copy it locally (wget doesn't work with https on github, no clue...)
and I do:

rpm -i rerun-modules-repo-1.0-21.noarch.rpm

this one didn't work for me (connectivity problems) but it's not essential:
yum -y --disablerepo '*' --enablerepo 'rerun-modules' install '*'


I create my first module

rerun stubbs: add-module
Module name:
pippo
Module description:
my first rerun
Created module structure: /usr/lib/rerun/modules/pippo.


If you look in /usr/lib/rerun/modules/pippo, there is a lib folder - containing an empty functions.sh - and a command folder.

rerun stubbs:add-command
Module:
1) pippo
2) stubbs
#? 1
You picked module pippo (1)
Command:
hello
Description:
say hello
Wrote command script: /usr/lib/rerun/modules/pippo/commands/hello/script
Wrote test script: /usr/lib/rerun/modules/pippo/tests/hello-1-test.sh

then I add an option to the command:
rerun stubbs:add-option

Module:
1) pippo
2) stubbs
#? 1
You picked module pippo (1)
Command:
1) hello
#? 1
You picked command hello (1)
Option:
name
Description:
the person to greet
Required:
1) true
2) false
#? 1
Export:
1) true
2) false
#? 1
Default:
Pierre
Wrote option metadata: /usr/lib/rerun/modules/pippo/options/name/metadata
Updated command metadata:  /usr/lib/rerun/modules/pippo/commands/hello/metadata
Updated command script header: /usr/lib/rerun/modules/pippo/commands/hello/script



vi /usr/lib/rerun/modules/pippo/commands/hello/script
and after this text:
# - - -
# Put the command implementation here.
# - - -

I enter this: echo name is $NAME

I run it:

rerun pippo:hello --name Luigi
name is Luigi

and rerun it:

rerun pippo:hello
name is Pierre

Ok at least we have proven that it can can be made to work...

No comments: