How to work with Microservice Utility Tool

Product/components used and version/fix level:

Cumulocity Production

Detailed explanation of the problem:

Hi, I was using microservice utility tool to do a deployment but I am facing some issues. I downloaded the raw file from here https://raw.githubusercontent.com/SoftwareAG/cumulocity-examples/develop/microservices/scripts/microservice and saved it with the name micro.sh
Then I opened my wsl and wrote the command chmod +x micro.sh
But while doing ./micro.sh help, i was getting error the script wasnt getting triggered so I searched and I got this solution. newline - Bash script – "/bin/bash^M: bad interpreter: No such file or directory" - Stack Overflow

So I used this command and I was able to access my script

sed -i -e 's/\r$//' micro.sh

But now I am getting this error while using the command ./micro.sh help

[INFO] Read input
./micro.sh: line 22: cd: too many arguments

So I went to the home directory and directly accessed the script like this
/path/to/script/micro.sh help

And I was able to access the help menu but when I am trying to pack it is not letting me do that. I am getting this error now

[INFO] Read input
[INFO] Start packaging
[INFO] Check input
[ERROR] Stopped: missing docker directory in work directory: /home/rooot
find: ‘docker’: No such file or directory
[ERROR] Stopped: missing dockerfile in work directory: /home/rooot
[ERROR] Stopped: missing cumulocity.json in work directory: /home/rooot
[WARNING] Pack skiped

Even though I have the docker folder and json file in my /path/to/script directory. Please help me understand how can I do the packing of my project with the script. I am not able to understand what I am doing wrong.

Thanks in advance.

Hi Samanyu,

can you provide the complete command for micro.sh, please?
You can anonymize user, password, tenant and target address if neccessary.

Regards,
Holger

Hi Holger,

I didn’t perform any other command as I was getting the same error with them as well.

However, I deleted the cd $WORK_DIR line from the script and it started working now. It was trying to access the same directory again.

I think you’re executing the script from the wrong directory. If you’re having this folder structure:

home
└── dirA
    └── dirB
        └── dirC
            └── script.sh

And you’re executing ./dirA/dirB/dirC/script.sh from your home directory, the script is executed within the home directoy (and not within dirC). So the script is trying to find your Dockerfile in home and fails.

You could try to navigate to the correct directory and start it from there. Alternatively, there’s a --dir parameter you can use to specify your work directory (personally never used it, but should work).

1 Like

Hi Samanyu,

please check the output of “pwd” manually before starting the script.
Looks like it was not returning a value, therefore “cd $WORK_DIR” was jumping to the home-directory of the current user (like root in your case) instead of jumping to the current directory (for the case there was no -dir or --directory parameter in your command line).

One option might be to have the “cd $WORK_DIR” active in the script, but explicitly provide the currernt directory to the -dir parameter. This will bypass the case, that pwd will not provide a valid value.

Regards,
Holger

:thinking: This could work but I managed it to work by removing the cd command. I also encountered one more issue.

Here on the first line, it was maxdepthcd and I was getting this error so I made it maxdepth and now it is working.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.