Get the IP address of the archive server by parsing ping output instead of using getent

This seems to work for more network configurations.
This commit is contained in:
cimryan
2018-10-18 09:07:13 -07:00
committed by GitHub
parent 6563aa9200
commit 5f38228860

View File

@@ -109,7 +109,7 @@ function create_usb_drive_backing_files () {
function configure_archive () { function configure_archive () {
echo "Configuring the archive..." echo "Configuring the archive..."
mkdir /mnt/archive mkdir /mnt/archive
local archive_server_ip_address="$(getent hosts $archiveserver | cut -d' ' -f1)" local archive_server_ip_address="$(ping -c 1 -w 1 $archiveserver 2>/dev/null | head -n 1 | grep -o -e "(\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\})" | tr -d '()')"
echo "//$archive_server_ip_address/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab echo "//$archive_server_ip_address/$sharename /mnt/archive cifs vers=3,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0" >> /etc/fstab
echo "username=$shareuser" > /root/.teslaCamArchiveCredentials echo "username=$shareuser" > /root/.teslaCamArchiveCredentials