Solution 1:

Your script isn't set as executable; just like a script not installed by packaging, you need to make sure it has the executable bit set.

You have two options:

  1. When creating the package, make sure that your script has the executable bit set before creating the package, by running this in your work directory Before building the package:

    chmod +x /path/to/script.sh

OR...

  1. Use the postinst script for your package to set the executable bit after installation. Add a command to the .postinst script similar to the following:

    chmod +x /usr/bin/myscript.sh

For some of my things, I use both methods just to make sure it sets things as executable. That introduces headaches sometimes, but it's better to make sure than not make sure. At least, in my opinion.


As for the script not being able to be executed as myscript, that's because myscript and myscript.sh are different objects.

If you want that, do the following in your .postinst script for your package:

ln -s /usr/bin/myscript.sh /usr/bin/myscript

... and then assuming you fix the executable bit problem, it should then 'just work' for both of the versions you were trying, both myscript.sh and myscript.

HOWEVER the proper way to do this is, instead, to just package the script as myscript and not include the shell extension. You should then include a shebang line at the beginning (#!) indicating the interpreter to use. Since .sh could be anything. Then, set up the package to just install myscript. As muru stated, you should avoid making links in your postinst, but it's up to you what you want to do. There's many different ways to achieve your goal, but not really much strict guidance in the documentation for packaging.