hibari / clus

Cluster is a simple tool for installing, configuring, and bootstrapping a cluster of nodes - primarily Hibari nodes.
Other
5 stars 4 forks source link

clus.sh does not use optional fourth parameter <installer_user> #5

Closed tatsuya6502 closed 9 years ago

tatsuya6502 commented 9 years ago

clus.sh's init and delete commands takes optional fourth parameter installer_user, which, I believe, is used as the ssh login user to run remote commands. However clush.sh does not use it for ssh sessions even though it sets up $INSTALLER_USER variable. For instance, it does $SSH $NODE_HOST '$SUDO true' || die ... instead of $SSH $INSTALLER_USER@$NODE_HOST ...

As a result, $USER is always used as the ssh login user.

$ ./priv/clus.sh

Usage: ./priv/clus.sh [-f] <command> ...

  <command> is one of the following:
    init <user> <host> [<installer_user>]
    delete <user> <host> [<installer_user>]

  - "-f" is enable force mode.  disable safety checks to prevent
     deleting and/or overwriting an existing installation.
  - <user> is the account on the server where you will be installing
  - <host> is that server's hostname (or IP address)
  - <installer_user> is *your* loginname

Example usage:
  ./priv/clus.sh init skylark `hostname`

Notes:
  - <user>, <host>, and <installer_user> must be simple names -- no
    special characters etc please (only alphanumerics, dot, hyphen,
    underscore)
  - <user> must be different than <installer_user>.
  - <installer_user> should be your name, for clarity, or whoever will
    be the installer user.  The default <installer_user> is "$USER"

$ grep INSTALLER_USER priv/clus.sh 
        INSTALLER_USER=$USER
        INSTALLER_USER=$4
    if [[ "$NODE_USER" = "root" || "$NODE_USER" = "$INSTALLER_USER" ]] ; then
    echo $INSTALLER_USER | $PERL -lne 'exit 1 if /[^a-zA-Z0-9._-]/' || \
        die "installer_user '$INSTALLER_USER' invalid"
tatsuya6502 commented 9 years ago

Fixed via https://github.com/hibari/clus/commit/9b805074a3e1a01d5393c756b400755669d48f91 on dev branch. Merged dev into master branch.

Now installer_user is working as expected.

[worker@hibari-builder clus]$ echo $USER
worker
[worker@hibari-builder clus]$ ssh hibari@test0
Warning: Permanently added 'test0,10.1.54.22' (RSA) to the list of known hosts.
hibari@test0's password: ^C

[worker@hibari-builder clus]$ ./priv/clus.sh init hibari test0 clus
hibari@test0
[worker@hibari-builder clus]$ ssh hibari@test0
Last login: Sat Sep 26 15:28:50 2015 from 10.1.54.25
[hibari@test0 ~]$ logout
Connection to test0 closed.
[worker@hibari-builder clus]$ ./priv/clus.sh init hibari test0 clus
remote user 'hibari@test0' exists

run ./priv/clus.sh without any arguments for usage
[worker@hibari-builder clus]$ ./priv/clus.sh -f init hibari test0 clus
hibari@test0
[worker@hibari-builder clus]$ ./priv/clus.sh delete hibari test0 clus
-f option is required

run ./priv/clus.sh without any arguments for usage
[worker@hibari-builder clus]$ ./priv/clus.sh -f delete hibari test0 clus
[worker@hibari-builder clus]$ ssh hibari@test0
hibari@test0's password: ^C

[worker@hibari-builder clus]$