Results 1 to 9 of 9
Good day
I have a question on how to create a script to setfacls on another system. I have the output from getfacl, on the new system the file system ...
- 05-28-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 10
setfacl script
Good day
I have a question on how to create a script to setfacls on another system. I have the output from getfacl, on the new system the file system does not exist. I would like to create the file system and set the acls at the same time. Any suggestions would be greatly appretiated.
AB
- 05-28-2008 #2Just Joined!
- Join Date
- May 2008
- Posts
- 10
Here is what the output of the getfacl looks like.
# file: somedir/
# owner: lisa
# group: staff
user::rwx
group::rwx
other:---
I need to create all of the directories and subdirectories listed in the file. I know that I can use setfacl --restore=myfile to set all of the acls. But how would I go about creating all the directories.
Thanks a lot
Allen
- 05-29-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 10
Actually the script needs to create directories with the owners and groups.
How would I do such a task.
Thanks
ARB
- 05-29-2008 #4Linux User
- Join Date
- Jun 2007
- Posts
- 318
You would have to scan myfile for 'file:', extract the directory name, and create the directory using mkdir.
Then you would:Code:grep 'file:' myfile | awk '{print $3}' | xargs mkdir
That should set the owners and groups as well. It does on my RHEL4.Code:setfacl --restore=myfile
- 05-29-2008 #5Just Joined!
- Join Date
- May 2008
- Posts
- 10
Cool, but if I ran that as root wouldn't it create all the directories as root:root
- 05-29-2008 #6Linux User
- Join Date
- Jun 2007
- Posts
- 318
As I said "That should set the owners and groups as well.". You'll just have to try it like I did.
- Create a directory
- Use getfacl to save the ACL information
- Change the owner and group on the directory to something else
- Use setfacl with the --restore option to see if it changes them back
- 05-29-2008 #7Just Joined!
- Join Date
- May 2008
- Posts
- 10
Awk is complaining about a syntax error for the print statement.
- 05-29-2008 #8Linux User
- Join Date
- Jun 2007
- Posts
- 318
Sorry but I can't help you unless you post the commands that you typed in and the exact error message that you got.
- 05-29-2008 #9Just Joined!
- Join Date
- May 2008
- Posts
- 10
Hey thanks for your help! I realized the error was I used parenthasis() insted of brackets {}
I actually wrote a perl script.
open(FILE,"@ARGV[0");
while (defined ($line = <FILE>)) {
chomp $line;
if $line =~ /mydir/) {
$directory = substr($line,
;
}
mkdir $directory, "\n";
}
But your solution is much more to the point!


Reply With Quote