In a shell script (running as a launch daemon, thus as root), I'm trying to transfer ownership of a home directory from a local user to a network user.
Stripped of all the logging and debugging code, here's what the script does:
----
# $sourcedir contains the old directory name (from the old, local user)
# $userdir contains the new directory name (from the new, network, user)
# $tgtgu contains the user:group specifier for the network user (like 3953253:20)
# Remove any conflicting old directory
rm -R $userdir || true
# Rename the old directory to the new name
mv -f "$sourcedir" "$userdir"
# Change the ownership
chown -R $tgtgu \"$userdir\"
----
The 'chown' statement claims that '$userdir' does not exist at that point. Part of the debugging code confirms that the directory does, in fact, exist.
Does anyone know why I would not be able to change the owner of the newly-renamed directory, or why chown would report that it does not exist?
Stripped of all the logging and debugging code, here's what the script does:
----
# $sourcedir contains the old directory name (from the old, local user)
# $userdir contains the new directory name (from the new, network, user)
# $tgtgu contains the user:group specifier for the network user (like 3953253:20)
# Remove any conflicting old directory
rm -R $userdir || true
# Rename the old directory to the new name
mv -f "$sourcedir" "$userdir"
# Change the ownership
chown -R $tgtgu \"$userdir\"
----
The 'chown' statement claims that '$userdir' does not exist at that point. Part of the debugging code confirms that the directory does, in fact, exist.
Does anyone know why I would not be able to change the owner of the newly-renamed directory, or why chown would report that it does not exist?