move duplicate code into a single file
add debug option (OCDEBUG=1 ./<script>)
update README