import corrected __group from nico/nico
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								21aacd44b4
							
						
					
				
			
			
				commit
				
					
						18e433dd85
					
				
			
		
					 1 changed files with 22 additions and 23 deletions
				
			
		| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
					# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
 | 
				
			||||||
 | 
					# 2011 Nico Schottelius (nico-cdist at schottelius.org)
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# This file is part of cdist.
 | 
					# This file is part of cdist.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
| 
						 | 
					@ -23,16 +24,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
name="$__object_id"
 | 
					name="$__object_id"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
command=
 | 
					 | 
				
			||||||
if grep -q "^$name" "$__object/explorer/group"; then
 | 
					 | 
				
			||||||
   # group exists
 | 
					 | 
				
			||||||
   command="groupmod"
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
   # group does not exist
 | 
					 | 
				
			||||||
   command="groupadd"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
get_current_value() {
 | 
					get_current_value() {
 | 
				
			||||||
   local key="$1"
 | 
					   local key="$1"
 | 
				
			||||||
   local index
 | 
					   local index
 | 
				
			||||||
| 
						 | 
					@ -46,9 +37,11 @@ get_current_value() {
 | 
				
			||||||
   cut -d':' -f $index "$__object/explorer/group"
 | 
					   cut -d':' -f $index "$__object/explorer/group"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
set -- "$@"
 | 
					set -- "$@"
 | 
				
			||||||
cd "$__object/parameter"
 | 
					cd "$__object/parameter"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if grep -q "^$name" "$__object/explorer/group"; then
 | 
				
			||||||
 | 
					   # group exists, only change changed values
 | 
				
			||||||
   for property in $(ls .); do
 | 
					   for property in $(ls .); do
 | 
				
			||||||
      current_value=$(get_current_value "$property")
 | 
					      current_value=$(get_current_value "$property")
 | 
				
			||||||
      new_value="$(cat "$property")"
 | 
					      new_value="$(cat "$property")"
 | 
				
			||||||
| 
						 | 
					@ -58,9 +51,15 @@ for property in $(ls .); do
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
   done
 | 
					   done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
   if [ $# -gt 0 ]; then
 | 
					   if [ $# -gt 0 ]; then
 | 
				
			||||||
      # Update changed properties
 | 
					      # Update changed properties
 | 
				
			||||||
   echo $command $@ $name
 | 
					      echo groupmod $@ $name
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					   for property in $(ls .); do
 | 
				
			||||||
 | 
					      new_value="$(cat "$property")"
 | 
				
			||||||
 | 
					      set -- "$@" "--$property" \"$new_value\"
 | 
				
			||||||
 | 
					   done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   echo groupadd "$@" "$name"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue