Find the answer to your Linux question:
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 ...
  1. #1
    Just 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

  2. #2
    Just 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

  3. #3
    Just 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

  4. #4
    Linux 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.

    Code:
    grep 'file:' myfile | awk '{print $3}' | xargs mkdir
    Then you would:

    Code:
    setfacl --restore=myfile
    That should set the owners and groups as well. It does on my RHEL4.

  5. #5
    Just 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

  6. #6
    Linux 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

  7. #7
    Just Joined!
    Join Date
    May 2008
    Posts
    10
    Awk is complaining about a syntax error for the print statement.

  8. #8
    Linux 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.

  9. #9
    Just 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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...