Skip to content

Commit

Permalink
more adjustments to better DRLM-ReaR integration
Browse files Browse the repository at this point in the history
  • Loading branch information
didacog committed Mar 14, 2017
1 parent f646047 commit a64bc89
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Log "####################################################"

if send_drlm_managed ${USER} ${CLI_NAME} ${SUDO}; then LogPrint "${CLI_NAME} is now managed by DRLM"; else Error "Error sending config, check logfile"; fi

if send_ssl_cert ${USER} ${CLI_NAME} ${SUDO}; then LogPrint "$PROGRAM:$WORKFLOW: SSL certificate successfuly sent to ${CLI_NAME}"; else Error "Error sending certificate, check logfile"; fi

if send_drlm_hostname ${USER} ${CLI_NAME} ${SUDO}; then LogPrint "$PROGRAM:$WORKFLOW: Success to update DRLM hostname info to ${CLI_NAME}"; else Error "Error updating DRLM hostname information, check logfile"; fi

#send sudo config
if ssh_config_sudo ${USER} ${CLI_NAME} ${DRLM_USER} ${SUDO}; then LogPrint "Sudo has been configured for user ${DRLM_USER}"; else Error "Error: sudo is not configured for user ${DRLM_USER}";fi

Expand Down
25 changes: 24 additions & 1 deletion usr/share/drlm/lib/install-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,37 @@ function ssh_keygen () {
}


#function send_drlm_managed () {
# local USER=$1
# local CLI_NAME=$2
# local SUDO=$3
# ssh -ttt -o UserKnownHostsFile=/dev/null -o StrictHostKeychecking=no ${USER}@${CLI_NAME} "( ${SUDO} echo DRLM_MANAGED=y > /tmp/etc_rear_local.conf && ${SUDO} mv /tmp/etc_rear_local.conf /etc/rear/local.conf && ${SUDO} chown root:root /etc/rear/local.conf && ${SUDO} chmod 644 /etc/rear/local.conf )"
# if [ $? -eq 0 ];then return 0; else return 1; fi
#}

function send_drlm_managed () {
local USER=$1
local CLI_NAME=$2
local SUDO=$3
ssh -ttt -o UserKnownHostsFile=/dev/null -o StrictHostKeychecking=no ${USER}@${CLI_NAME} "( ${SUDO} echo DRLM_MANAGED=y > /tmp/etc_rear_local.conf && ${SUDO} mv /tmp/etc_rear_local.conf /etc/rear/local.conf && ${SUDO} chown root:root /etc/rear/local.conf && ${SUDO} chmod 644 /etc/rear/local.conf )"
ssh -ttt -o UserKnownHostsFile=/dev/null -o StrictHostKeychecking=no ${USER}@${CLI_NAME} "( printf '%s\n%s\n%s\n%s\n' "DRLM_MANAGED=y" "DRLM_SERVER=$(hostname -s)" "DRLM_ID=$CLI_NAME" "DRLM_REST_OPTS=\"$REST_OPTS\"" | ${SUDO} tee /etc/rear/local.conf >/dev/null && ${SUDO} chmod 644 /etc/rear/local.conf )"
if [ $? -eq 0 ];then return 0; else return 1; fi
}

function send_ssl_cert () {
local USER=$1
local CLI_NAME=$2
local SUDO=$3
cat /etc/drlm/cert/$(hostname -s).crt | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeychecking=no ${USER}@${CLI_NAME} "( ${SUDO} tee /etc/rear/cert/$(hostname -s).crt >/dev/null && ${SUDO} chmod 644 /etc/rear/cert/$(hostname -s).crt )"
if [ $? -eq 0 ];then return 0; else return 1; fi
}

function send_drlm_hostname () {
local USER=$1
local CLI_NAME=$2
local SUDO=$3
ssh -ttt -o UserKnownHostsFile=/dev/null -o StrictHostKeychecking=no ${USER}@${CLI_NAME} "( printf '%s\t\t%s\n' "$DRLM_SRV_IP" "$(hostname -s)" | ${SUDO} tee --append /etc/hosts >/dev/null )"
if [ $? -eq 0 ];then return 0; else return 1; fi
}

function create_drlm_user () {
local USER=$1
Expand Down

0 comments on commit a64bc89

Please sign in to comment.