mirror of
https://github.com/armbian/autotests.git
synced 2026-01-06 10:31:09 -08:00
- cleanup
- add keys to duts - add ansible snippet for updating all duts
This commit is contained in:
10
ansi.sh
Executable file
10
ansi.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
# load user configuration
|
||||
source userconfig/configuration.sh
|
||||
sudo echo "[duts]" > /etc/ansible/hosts
|
||||
sudo nmap --exclude $EXCLUDE --open -sn ${SUBNET} -oG - | awk '/Up$/{print $2}' | sort >> /etc/ansible/hosts
|
||||
ansible duts -a "apt update " -u root
|
||||
ansible duts -a "apt -y -qq upgrade " -u root
|
||||
ansible duts -a "reboot " -u root
|
||||
@@ -10,8 +10,7 @@ if [[ $? -eq 0 ]]; then
|
||||
|
||||
#display_alert "$(basename $BASH_SOURCE)" "$(date +%R:%S)" "info"
|
||||
ssh-keygen -qf "$HOME/.ssh/known_hosts" -R "${USER_HOST}" > /dev/null 2>&1
|
||||
sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "\x03" &>/dev/null
|
||||
|
||||
sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "w " &>/dev/null
|
||||
#echo $?
|
||||
# since 20.08
|
||||
if [[ $? -eq 127 ]]; then
|
||||
@@ -43,47 +42,6 @@ MAKE_USER=$(expect -c "
|
||||
echo "${MAKE_USER}" >> ${SRC}/logs/${USER_HOST}.log
|
||||
fi
|
||||
|
||||
# before 20.08
|
||||
if [[ $? -eq 1 ]]; then
|
||||
# clean keys
|
||||
# pass user creation to expect
|
||||
display_alert "Conduct first login steps" "root/${PASS_ROOT} and ${USER_NORMAL}/${PASS_NORMAL}" "info"
|
||||
|
||||
MAKE_USER=$(expect -c "
|
||||
spawn sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST}
|
||||
set timeout 10
|
||||
expect \"Current password:\"
|
||||
send \"1234\r\"
|
||||
expect \"New password:\"
|
||||
send \"${PASS_ROOT}\r\"
|
||||
expect \"Re-enter new password:\"
|
||||
send \"${PASS_ROOT}\r\"
|
||||
expect \"(eg. your forename):\"
|
||||
send \"${USER_NORMAL}\r\"
|
||||
expect \"New password:\"
|
||||
send \"${PASS_NORMAL}\r\"
|
||||
expect \"Retype new password:\"
|
||||
send \"${PASS_NORMAL}\r\"
|
||||
expect \"Name\"
|
||||
send \"${NAME_NORMAL}\r\"
|
||||
expect \"Room Number\"
|
||||
send \"${ROOM_NORMAL}\r\"
|
||||
expect \"Work Phone\"
|
||||
send \"${WORKPHONE_NORMAL}\r\"
|
||||
expect \"Home Phone\"
|
||||
send \"${HOMEPHONE_NORMAL}\r\"
|
||||
expect \"Other\"
|
||||
send \"${OTHER_NORMAL}\r\"
|
||||
expect \"information correct\"
|
||||
send \"Y\r\"
|
||||
expect eof
|
||||
")
|
||||
# Disable user creation: send \"\x03\"
|
||||
# display output
|
||||
echo "${MAKE_USER}" >> ${SRC}/logs/${USER_HOST}.txt
|
||||
echo "${MAKE_USER}" >> ${SRC}/logs/${USER_HOST}.log
|
||||
fi
|
||||
|
||||
# adjust repository
|
||||
remoterelease=$(remote_exec "lsb_release -cs" "")
|
||||
repository="deb http://$LOCALREPO ${remoterelease} main ${remoterelease}-utils ${remoterelease}-desktop"
|
||||
@@ -105,6 +63,12 @@ else
|
||||
remote_exec "dpkg --configure -a --force-confold" "-t" "10m" &>/dev/null
|
||||
fi
|
||||
|
||||
# deploy keys
|
||||
if [[ -f "${HOME}/.ssh/id_rsa.pub" ]]; then
|
||||
sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} "mkdir -p .ssh"
|
||||
cat ${HOME}/.ssh/id_rsa.pub | sshpass -p ${PASS_ROOT} ssh -o "StrictHostKeyChecking=accept-new" ${USER_ROOT}@${USER_HOST} 'cat > .ssh/authorized_keys'
|
||||
fi
|
||||
|
||||
get_board_data
|
||||
[[ -n $BOARD_NAME ]] && display_alert "$BOARD_NAME $BOARD_KERNEL $BOARD_UBOOT $BOARD_DISTRIBUTION_CODENAME $BOARD_IMAGE_TYPE" "$(date +%R:%S) - $(mask_ip "$USER_HOST") Uptime: $BOARD_UPTIME" "info"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user