diff options
author | erkin <e.altunbas@vyos.io> | 2021-05-18 15:52:10 +0300 |
---|---|---|
committer | erkin <e.altunbas@vyos.io> | 2021-05-18 15:52:10 +0300 |
commit | a31b092a4f6297cf13261023cb17e8c8e1e6b315 (patch) | |
tree | d8e2952816a2833db2f27e3e697c46eeb99776b2 | |
parent | 4fdebae4d858acd67f35385df3d7428fc6d60a87 (diff) | |
download | vyatta-cfg-system-a31b092a4f6297cf13261023cb17e8c8e1e6b315.tar.gz vyatta-cfg-system-a31b092a4f6297cf13261023cb17e8c8e1e6b315.zip |
T3356: remote: Read username and password from environment variables
-rwxr-xr-x | scripts/install/install-image | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/scripts/install/install-image b/scripts/install/install-image index 8ce635cc..451ae285 100755 --- a/scripts/install/install-image +++ b/scripts/install/install-image @@ -98,6 +98,13 @@ PART_FILE='' # Temp directory for downloaded ISO TEMP_DIR="/var/tmp/install-image.$$" +download_file () +{ + (REMOTE_USERNAME=$USERNAME \ + REMOTE_PASSWORD=$PASSWORD \ + ip vrf exec $VRF python3 -c "import vyos.remote; vyos.remote.friendly_download('$1', '$2')") +} + # Try to fetch the ISO file using a URL provided by the user. # If successful, we leave $NEW_ISO pointing to the ISO file that # was downloaded. @@ -105,21 +112,16 @@ fetch_iso_by_url () { mkdir $TEMP_DIR filename="${TEMP_DIR}/${NEW_ISO##*/}" - if [ -n "$USERNAME" ]; then - AUTH="(\"$USERNAME\", \"$PASSWORD\")" - else - AUTH="None" - fi echo "Trying to fetch ISO file from $NEW_ISO..." - ip vrf exec $VRF python3 -c "import vyos.remote; vyos.remote.friendly_download('$filename', '$NEW_ISO', authentication=$AUTH)" + download_file "$filename" "$NEW_ISO" if [ $? -ne 0 ]; then fail_exit 'Failed to download the ISO file.' fi echo "Done." echo "Checking for digital signature file..." - ip vrf exec $VRF python3 -c "import vyos.remote; vyos.remote.friendly_download('${filename}.asc', '${NEW_ISO}.asc', authentication=$AUTH)" + download_file "${filename}.asc" "${NEW_ISO}.asc" if [ $? -ne 0 ]; then echo "Unable to fetch digital signature file." echo -n "Do you want to continue without signature check? (yes/no) [yes] " @@ -253,10 +255,10 @@ install_existing () } if [ -z "$USERNAME" ] && [ -n "$PASSWORD" ]; then - fail_exit "Password can not be specified without username" + fail_exit "Password cannot be specified without username." fi if [ -n "$USERNAME" ] && [ -z "$PASSWORD" ]; then - fail_exit "Username can not be specified without password" + fail_exit "Username cannot be specified without password." fi if [ $(id -u) != 0 ]; then fail_exit "Image installation requires root privileges!" |