Commit 0d18cb78 authored by kpetersn's avatar kpetersn
Browse files

Added a readme

parent fafc8f1e
takeOwnership
=============
takeOwnership.sh is a bash script that allows reclaiming ownership of files in a directory that is group writable.
Why is this script needed?
--------------------------
There are a number of compounding factors:
* Only root can change the user ownership of a file with the ```chown``` command
* The default ```umask``` of ```22``` encourages creating files that are not writable by group members
* Files frequently need to be modified by group members.
Usage
-----
```
$ ./takeOwnership.sh
Usage: takeOwnership.sh <username> <directory> <file_pattern>
```
* *username* the username of the files from which ownership will be taken
* *directory* the directory containing the files from which ownership will be taken
* *file_pattern* the glob pattern matching filenames from which ownership will be taken
Example
-------
```
$ ./takeOwnership.sh bcda /net/s32dserv/xorApps/epics/synApps_5_6/ioc/32idsectorApp/op/adl "*.adl"
```
This will change the ownership of all adl files in the 32idsectorApp/op/adl dir (and subdirectories) from bcda to the user running the takeOwnership script.
Theory of Operation
-------------------
The user running takeOwnership.sh must have write access to the directory specified in the 2nd argument.
takeOwnership.sh does the following:
1. Runs ```find``` with ```-user=<username>``` and ```-name="<file_pattern>"``` to get a list of the relevant files
1. Iterates over the list of files
1. Moves each file to file-DELETE-ME-SOON
1. Copies file-DELETE-ME-SOON to file, preserving timestamps
1. Deletes file-DELETE-ME-SOON
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment