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

[Feature Request]: check/ck_hostname: check if current host name matches given regular expression #80

Open
1 task done
aronchanisme opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels
function/check priority/p0 priority p0 type/feature propose a new feature request
Milestone

Comments

@aronchanisme
Copy link
Collaborator

Is there an existing issue for the feature request?

  • I have checked the existing issues.

Feature Description

check/ck_hostname: check if current host name matches given regular expression

usage: 
check/ck_hostname.sh <reg_expr>, where,
reg_expr: a regular expression, e.g. "^abc.*$"

example:
check/ck_hostname.sh "^abc.*$"


github@test0:/data/cus_reg$ /tmp/1.sh "^test.*$"
The hostname test0 matches the regex pattern.
github@test0:/data/cus_reg$ /tmp/1.sh "^tes.*$"
The hostname test0 matches the regex pattern.
github@test0:/data/cus_reg$ /tmp/1.sh "^tes1.*$"
The hostname test0 does not match the regex pattern.

output:
return 0: if matches
return 1: otherwise

Feature Implementation

hostname=`hostname`
reg_exp="$1"
if [[ ${hostname} =~ "${reg_exp}" ]]; then
    echo "matches"
fi

Additional information

No response

@aronchanisme aronchanisme added priority/p0 priority p0 type/feature propose a new feature request function/check labels Oct 23, 2024
@aronchanisme aronchanisme added this to the mo_ctl 2.0 milestone Oct 23, 2024
@aronchanisme aronchanisme self-assigned this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
function/check priority/p0 priority p0 type/feature propose a new feature request
Projects
None yet
Development

No branches or pull requests

1 participant