Commit 3351552f authored by clewsy's avatar clewsy

Added variable for setting the ssh protocol - default configured to ipv4.

parent 2bbb64c5
......@@ -50,6 +50,12 @@ DEST="/dev/null" ## Default destination for command output. I.e. don't displa
APT_GET_VERBOSITY="--quiet=3" ## Default verbosity setting for apt-get commands. Removed by "-v" option.
QUIET=false
######### Define protocol to be used by ssh.
## Options are: "-4" : IPV4
## "-6" : IPV6
## "" : System default.
PROTOCOL="-4"
########## Interpret options
while getopts 'vqh' OPTION; do ## Call getopts to identify selected options and set corresponding flags.
case "$OPTION" in
......@@ -134,7 +140,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt connection.
echo -e "Testing ssh connection: ${BLUE}${REM_SYS}${RESET}" > ${DEST}
if [ ${QUIET} = false ]; then echo -e -n "${BOLD}ssh connection...\t${RESET}"; fi
if ! ssh -o "BatchMode=yes" -o "ConnectTimeout=4" "${REM_SYS}" "exit" > /dev/null 2>&1; then ## Test ssh connection to current host machine. If it fails...
if ! ssh "${PROTOCOL}" -o "BatchMode=yes" -o "ConnectTimeout=4" "${REM_SYS}" "exit" > /dev/null 2>&1; then ## Test ssh connection to current host machine. If it fails...
{
echo -E "${BOLD}${RED}System not found.${RESET}\t\t${BOLD}${RESET}"
echo -E "${BOLD}${RESET}Skipped.\t\t\t${BOLD}${RESET}"
......@@ -154,7 +160,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt update.
if [ ${QUIET} = false ]; then echo -e -n "${BOLD}update... \t\t${RESET}"; fi
if ! ssh -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes update" > ${DEST}; then
if ! ssh "${PROTOCOL}" -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes update" > ${DEST}; then
{
echo -E "${BOLD}${RESET}apt-get update\t\t${RED}Failure.${RESET}${BOLD}${RESET}"
echo -E "${BOLD}╠═══════════════════════════════╣${RESET}"
......@@ -169,7 +175,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
fi
###### Use apt to check if any packages can be upgraded.
NEW=$(ssh -o "BatchMode=yes" "${REM_SYS}" sudo apt list --upgradable --quiet=2)
NEW=$(ssh "${PROTOCOL}" -o "BatchMode=yes" "${REM_SYS}" sudo apt list --upgradable --quiet=2)
if [[ ! ${NEW} ]]; then ## There are no new packages to update.
{
echo -E "${BOLD}${RESET}Up-to-date\t\t${GREEN}Skipped.${RESET}${BOLD}${RESET}"
......@@ -181,7 +187,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
else ## There are new packages to update.
###### Attempt dist-upgrade.
if [ ${QUIET} = false ]; then echo -e -n "${BOLD}dist-upgrade... \t${RESET}"; fi
if ! ssh -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes --show-progress dist-upgrade" > ${DEST}; then
if ! ssh "${PROTOCOL}" -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes --show-progress dist-upgrade" > ${DEST}; then
{
echo -E "${BOLD}${RESET}apt-get dist-upgrade\t${RED}Failure.${RESET}${BOLD}${RESET}"
echo -E "${BOLD}╠═══════════════════════════════╣${RESET}"
......@@ -197,7 +203,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt autoremove.
if [ ${QUIET} = false ]; then echo -e -n "${BOLD}autoremove... \t\t${RESET}"; fi
if ! ssh -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes --show-progress autoremove" > ${DEST}; then
if ! ssh "${PROTOCOL}" -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes --show-progress autoremove" > ${DEST}; then
{
echo -E "${BOLD}${RESET}apt-get autoremove\t${RED}Failure.${RESET}${BOLD}${RESET}"
echo -E "${BOLD}╠═══════════════════════════════╣${RESET}"
......@@ -213,7 +219,7 @@ while read -r REM_SYS <&2; do ## Loop to repeat commands for each file name entr
###### Attempt autoclean.
if [ ${QUIET} = false ]; then echo -e -n "${BOLD}autoclean... \t\t${RESET}"; fi
if ! ssh -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes autoclean" > ${DEST}; then
if ! ssh "${PROTOCOL}" -o "BatchMode=yes" "${REM_SYS}" "sudo apt-get ${APT_GET_VERBOSITY} --assume-yes autoclean" > ${DEST}; then
{
echo -E "${BOLD}${RESET}apt-get autoclean\t${RED}Failure.${RESET}${BOLD}${RESET}"
echo -E "${BOLD}╠═══════════════════════════════╣${RESET}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment