Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom command script files with extensions other than .sh? #739

Open
kenny-evitt opened this issue Oct 12, 2021 · 0 comments
Open

Comments

@kenny-evitt
Copy link

Steps to reproduce

In my project's rel/config.exs file, I just added two new ('something') custom commands:

release :my_project do
  set version: current_version(:my_project)
  set commands: [
    disable_something: "rel/commands/disable_something.bash",
    enable_something:  "rel/commands/enable_something.bash",
    seed:              "rel/commands/seed.sh"
  ]
  ...

But after deploying a release I don't see the new commands – but I DO still see the seed command:

$ bin/my_project
USAGE
  my_project <task> [options] [args..]

COMMANDS

  start                Start my_project as a daemon
  start_boot <file>    Start my_project as a daemon, but supply a custom .boot file
  foreground           Start my_project in the foreground
  ...
  seed (custom command)

And when I try to run one of the new 'something' commands:

ubuntu@ip-172-31-64-81:~$ web/partially/bin/partially enable_maintenance_mode
'enable_maintenance_mode' is not a valid command
...

This code in priv/libexec/commands/help.sh (and similar code elsewhere that I am imagining exists) seems like it might be why the new commands aren't listed:

for command in "$REL_DIR"/commands/*.sh; do
    [ -f "$command" ] || continue
    __has_commands=1
    echo "  $(basename ${command%.*}) (custom command)"
done

I believe I saw elsewhere that Distillery explicitly requires Bash and not any Bourne-compatible shell. I picked-up the habit of naming my own Bash shell scripts with a .bash extension from my favorite Bash guide author:

Also, please refrain from giving scripts a .sh extension. It serves no purpose, and it's completely misleading (since it's going to be a bash script, not an sh script).

[Based on the above, I figured .bash was clearer than no extension, and more accurate/precise than .sh.]

The current docs include examples of shell scripts for custom commands with no extension in the script file names too – those don't seem like they would work either.

But this is a very minor issue, easily worked-around, and I think, for my own project, just calling the relevant code via the builtin eval or rpc commands is just as good (and a little better in not requiring any extra config or an extra shell script).

Verbose Logs

[Please let me know if these would be useful.]

Description of issue

What are the expected results?

All of the custom commands should be listed, maybe regardless of the extension (if any) of the corresponding shell scripts.

What version of Distillery?

2.1.1

What OS, Erlang/Elixir versions are you seeing this issue on?

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS"

Elixir is version 1.12.3 and Erlang/OTP is 24.0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant