begin to cleanup __file
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								1619964cbb
							
						
					
				
			
			
				commit
				
					
						e06e8026dd
					
				
			
		
					 2 changed files with 27 additions and 73 deletions
				
			
		|  | @ -18,27 +18,13 @@ | ||||||
| # along with cdist. If not, see <http://www.gnu.org/licenses/>. | # along with cdist. If not, see <http://www.gnu.org/licenses/>. | ||||||
| # | # | ||||||
| # | # | ||||||
| # __file is a very basic type and should be able to be used as an | # __file is a very basic type, which will probably be reused quite often | ||||||
| # example for typewrites later |  | ||||||
| # | # | ||||||
| 
 | 
 | ||||||
| # If destination was specified, do not use the id | destination="/$__object_id" | ||||||
| if [ -f "$__object/parameter/destination" ]; then |  | ||||||
|    destination="$(cat "$__object/parameter/destination")" |  | ||||||
| else |  | ||||||
|    # If no destination has been supplied, the id is the destination |  | ||||||
|    # Prepend /, which got lost in the object id (and relative paths |  | ||||||
|    # don't make sense) |  | ||||||
|    destination="/$__object_id" |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| # Ensure we have an absolute path |  | ||||||
| if ! $(echo "$destination" | grep -q ^/); then |  | ||||||
|    echo "Error: Destination ($destination) of $__object_id is not absolute." >&2 |  | ||||||
|    exit 1 |  | ||||||
| fi |  | ||||||
| 
 | 
 | ||||||
| # Use correct md5sum binary - MacOSx is different here | # Use correct md5sum binary - MacOSx is different here | ||||||
|  | # FIXME: broken: we don't know the host os! | ||||||
| case "$os" in | case "$os" in | ||||||
|    macosx) |    macosx) | ||||||
|       md5sum="md5" |       md5sum="md5" | ||||||
|  | @ -49,22 +35,7 @@ case "$os" in | ||||||
|    ;;   |    ;;   | ||||||
| esac | esac | ||||||
| 
 | 
 | ||||||
| type="$(cat "$__object/parameter/type")" | if [ -f "$__object/parameter/source" ]; then | ||||||
| 
 |  | ||||||
| case "$type" in |  | ||||||
|    directory) |  | ||||||
|       if [ -f "$__object/parameter/source" ]; then |  | ||||||
|          echo "Source not supported for directory currently - FIXME" >&2 |  | ||||||
|          exit 1 |  | ||||||
|       else |  | ||||||
|          if [ no = "$(cat "$__object/explorer/exists")" ]; then |  | ||||||
|             echo mkdir \"$destination\" |  | ||||||
|          fi |  | ||||||
|       fi |  | ||||||
|    ;; |  | ||||||
| 
 |  | ||||||
|    file) |  | ||||||
|       if [ -f "$__object/parameter/source" ]; then |  | ||||||
|    source="$(cat "$__object/parameter/source")" |    source="$(cat "$__object/parameter/source")" | ||||||
| 
 | 
 | ||||||
|    if [ -f "$source" ]; then |    if [ -f "$source" ]; then | ||||||
|  | @ -83,29 +54,12 @@ case "$type" in | ||||||
|       echo "Source \"$source\" does not exist." >&2 |       echo "Source \"$source\" does not exist." >&2 | ||||||
|       exit 1 |       exit 1 | ||||||
|    fi |    fi | ||||||
|       else | else | ||||||
|    if [ no = "$(cat "$__object/explorer/exists")" ]; then |    if [ no = "$(cat "$__object/explorer/exists")" ]; then | ||||||
|       echo touch \"$destination\" |       echo touch \"$destination\" | ||||||
|    fi |    fi | ||||||
|       fi | fi | ||||||
|    ;; |  | ||||||
| 
 | 
 | ||||||
|    symlink) |  | ||||||
|       if [ ! -f "$__object/parameter/source" ]; then |  | ||||||
|          echo "Source required for symlink" >&2 |  | ||||||
|          exit 1 |  | ||||||
|       fi |  | ||||||
|       source="$(cat "$__object/parameter/source")" |  | ||||||
| 
 |  | ||||||
|       # FIXME: handle directories or document & ignore? |  | ||||||
|       echo ln -sf \"$source\" \"$destination\" |  | ||||||
|    ;; |  | ||||||
| 
 |  | ||||||
|    *) |  | ||||||
|       echo "Unsupported type: \"$type\"" >&2 |  | ||||||
|       exit 1 |  | ||||||
|    ;; |  | ||||||
| esac |  | ||||||
| 
 | 
 | ||||||
| # Mode settings | # Mode settings | ||||||
| if [ -f "$__object/parameter/mode" ]; then | if [ -f "$__object/parameter/mode" ]; then | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| Proposal for new types, which replace __file: | Proposal for new types, which replace __file: | ||||||
| 
 | 
 | ||||||
| __directory /etc [--mode --owner --group --parents [yes|no] ] | x __directory /etc [--mode --owner --group --parents [yes|no] ] | ||||||
| 
 | 
 | ||||||
| __link /destination --source abc --type [symbolic|hard] | x __link /destination --source abc --type [symbolic|hard] | ||||||
| 
 | 
 | ||||||
| __file /etc/passwd [--source] --mode --owner --group | __file /etc/passwd [--source] --mode --owner --group | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue