How can I automount a network share on macOS Catalina? I want to connect to a network share and I want the connection to remain active after logout. I tried:
$ echo &quot;/-      auto_smb        -nosuid,noowners,nofail
        /-      auto_afp        -nobrowse,nosuid&quot; &gt;&gt; /etc/auto_master
$ echo &quot;/System/Volumes/Data/mount/Test2 -fstype=smbfs,soft,noowners,nosuid,rw ://$username:$password@server/share&quot; &gt;&gt; /etc/auto_smb
$ automount -cv

My username and password have special characters so I tried escaping them and replacing them with URL encoding, but it did not work. What am I doing wrong?
This is the article that i used
https://useyourloaf.com/blog/using-the-mac-os-x-automounter/
and my code:
networkPath
persistent=&quot;true&quot;
username
password


function debugEcho () {
  if (true) then
   echo -e $1
  fi
}

shareName=${networkPath##*/}
debugEcho &quot;$shareName&quot;
userPersistent=$username
userPersistent=$(echo &quot;$username&quot; | tr &quot;\\&quot; &quot;;&quot;)
if [[ $username == *&quot;@&quot;* ]]; then
  OIFS=$IFS
  IFS=@
  set -- $username
  user=$1
  domain=$2
  debugEcho &quot;$user $domain&quot;
  userPersistent=&quot;$domain;$user&quot;
  IFS=$OIFS
  debugEcho &quot;$userPersistent&quot;
fi

username=${username//@/&quot;%40&quot;}
debugEcho $username
shareName=&quot;TEST7&quot;

if [[ &quot;$persistent&quot; == &quot;true&quot; ]]; then
  mkdir -p /System/Volumes/Data/mnt
  LINE=&quot;/System/Volumes/Data/mnt/Resources auto_resources&quot;
  FILE='/etc/auto_master'
  grep -qF -- &quot;$LINE&quot; &quot;$FILE&quot; || echo &quot;$LINE&quot; &gt;&gt; &quot;$FILE&quot;
  touch /etc/auto_resources
  LINE=&quot;$shareName -fstype=smbfs ://$userPersistent:$password@$networkPath&quot;
  FILE='/etc/auto_resources'
  grep -qF -- &quot;$LINE&quot; &quot;$FILE&quot; || echo &quot;$LINE&quot; &gt;&gt; &quot;$FILE&quot;
  automount -cv
  open &quot;/System/Volumes/Data/mnt/Resources/&quot;
  path1=&quot;/System/Volumes/Data/mnt/Resources/&quot;
  path2=&quot;~/Desktop/&quot;
  debugEcho &quot;$path1&quot;
  ln -s $path1 $path2

else
  open &quot;smb://$username:$password@$networkPath&quot;

fi