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

kamctl - shell interpreter selection #2019

Closed
miconda opened this issue Jul 29, 2019 · 3 comments
Closed

kamctl - shell interpreter selection #2019

miconda opened this issue Jul 29, 2019 · 3 comments

Comments

@miconda
Copy link
Member

miconda commented Jul 29, 2019

Description

The kamctl tool seems to require bash, while trying to use /bin/sh, which can point to dash or other shell interpreters.

For example, the output of kamdbctl create:

MySQL password for root:
-e \E[37;33mINFO: creating database kamailio_simple_db ...
-e \E[37;33mINFO: granting privileges to database kamailio_simple_db ...
-e \E[37;33mINFO: creating standard tables into kamailio_simple_db ...
-e \E[37;33mINFO: Core Kamailio tables succesfully created.
Install presence related tables? (y/n): n
/usr/sbin/kamdbctl: 216: /usr/sbin/kamdbctl: Bad substitution

It seems that the issue is expanding the variable when getting the answer for y/n question:

Such expression seems to be specific for bash:

Troubleshooting

Reproduction

Run kamctl with /bin/sh pointing to bash.

Possible Solutions

Decide what to do to have an acceptable solution: enforce bash, remove bashisms`...

Or maybe focus to make kamcli a (full) replacement for kamctl/kamdbctl and get rid of those old-style shell/bash scripts:

@sergey-safarov
Copy link
Member

May be this

#!/bin/sh

get_answer ()
{
    value=$1
    question=$2
    if [ "${value}" = "ask" ]; then
        echo -n "$question"
        read value
    fi
    ANSWER=$(echo ${value} | grep -o -e '[YyNn]' | sed -e 's/Y/y/' -e 's/N/n/')
}

get_answer ask "My question?"

miconda added a commit that referenced this issue Sep 16, 2019
@miconda
Copy link
Member Author

miconda commented Sep 16, 2019

Thanks @sergey-safarov, I replaced the existing function with the one you proposed until getting to a decision on kamcli vs kamctl+bash/shell.

miconda added a commit that referenced this issue Sep 24, 2019
- contributed by Sergey Safarov, GH #2019

(cherry picked from commit 88d06a0)
miconda added a commit that referenced this issue Sep 24, 2019
- contributed by Sergey Safarov, GH #2019

(cherry picked from commit 88d06a0)
(cherry picked from commit 25585a6)
Copy link

github-actions bot commented Nov 8, 2023

This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.

@github-actions github-actions bot added the Stale label Nov 8, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants