Shell: Simple bundle watch list

Creating a watchlist could be laboriously (what a word :-/). Therefore using shell scripting could help a lot.

The first sample shows how to grep a list of interesting bundles to watch. In my case it's all mhu-lib bundles (add '--color never' to avoid creation of violating escape sequences):

karaf@root()> bundle:list|grep --color never mhu-lib
 89 | Active |  80 | 3.3.0.SNAPSHOT     | mhu-lib-annotations
 90 | Active |  80 | 3.3.0.SNAPSHOT     | mhu-lib-core
 91 | Active |  80 | 3.3.0.SNAPSHOT     | mhu-lib-jms
 92 | Active |  80 | 3.3.0.SNAPSHOT     | mhu-lib-karaf
 93 | Active |  80 | 3.3.0.SNAPSHOT     | mhu-lib-persistence
karaf@root()>

I only need the bundle names, so cut the last column out of the result:

karaf@root()> bundle:list|grep --color never mhu-lib|cut -d '\|' -f 4 -t
mhu-lib-annotations
mhu-lib-core
mhu-lib-jms
mhu-lib-karaf
mhu-lib-persistence
karaf@root()>

Now we need to parse it line by line. A loop would help. The results are used to add the bundle to the bundle:watch list

bundle:list|grep --color never mhu-lib|cut -d '\|' -f 4 -t|run -c "for b in read *;bundle:watch \$b;done"

The 'read *' command reads everything from the pipe and the for loop will cut it into lines and run the loop for every entry. The line content is stored in 'b'. To stop replacement of '$b' by the shell itself (should be done later in the loop) you need to escape the '$' character.

If you want to use a persistent bundle watch use the 'mhu osgi tool' called 'bundle:persistentwatch'. You need to add the entries to the persistent list.

bundle:list|grep --color never mhu-lib|cut -d '\|' -f 4 -t|run -c "for b in read *;bundle:persistentwatch add \$b;done"

Print the list using 'list':

karaf@root()> bundle:persistentwatch list
Bundle             
-------------------
mhu-lib-annotations
mhu-lib-core       
mhu-lib-jms        
mhu-lib-karaf      
mhu-lib-persistence

Comments

Popular posts from this blog

Sonatype Nexus fails with random "peer not authenticated" errors behind ingress

Creating a flux sync configuration referring a config map for substitution

[mhus lib] Reorg in generation 7 nearly finished