forked from ungleich-public/cdist
		
	Fix sed argumenting on FreeBSD. While specifying -i flag is optional on GNU sed, it is mandatory on non-GNU variants. In order to keep behavior backward-compatible, the backup file is always removed.
This commit is contained in:
		
					parent
					
						
							
								7d2799d958
							
						
					
				
			
			
				commit
				
					
						0e11583b1e
					
				
			
		
					 3 changed files with 10 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -34,7 +34,8 @@ fi
 | 
			
		|||
case "$state_should" in
 | 
			
		||||
   absent)
 | 
			
		||||
      # remove lines starting with key
 | 
			
		||||
      echo "sed -i '/^$key\($delimiter\+\)/d' \"$file\""
 | 
			
		||||
      echo "sed -i cdist-backup '/^$key\($delimiter\+\)/d' \"$file\""
 | 
			
		||||
      echo "rm -f \"$file.cdist-backup\""
 | 
			
		||||
   ;;
 | 
			
		||||
   present)
 | 
			
		||||
      case "$state_is" in
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +45,8 @@ case "$state_should" in
 | 
			
		|||
         ;;
 | 
			
		||||
         wrongvalue)
 | 
			
		||||
            # change exisiting value
 | 
			
		||||
            echo "sed -i \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\""
 | 
			
		||||
            echo "sed -i cdist-backup \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\""
 | 
			
		||||
            echo "rm -f \"$file.cdist-backup\""
 | 
			
		||||
         ;;
 | 
			
		||||
         *)
 | 
			
		||||
            echo "Unknown explorer state: $state_is" >&2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,8 @@ DONE
 | 
			
		|||
      removed)
 | 
			
		||||
         cat << DONE
 | 
			
		||||
su - $user -c "rm -Rf \"\\\$HOME/.rvm\";
 | 
			
		||||
sed -i '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\""
 | 
			
		||||
sed -i cdist-backup '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\""
 | 
			
		||||
rm -f \"\\\$HOME/.bashrc.cdist-backup\""
 | 
			
		||||
DONE
 | 
			
		||||
      ;;
 | 
			
		||||
   esac
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,8 @@ case "$state_should" in
 | 
			
		|||
    present)
 | 
			
		||||
        case "$os" in
 | 
			
		||||
            archlinux)
 | 
			
		||||
                echo "sed -i 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf"
 | 
			
		||||
                echo "sed -i cdist-backup 's/^\\(DAEMONS=.*\\))/\\1 $name)/' /etc/rc.conf"
 | 
			
		||||
		echo "rm -f /etc/rc.conf.cdist-backup"
 | 
			
		||||
            ;;
 | 
			
		||||
            debian|ubuntu)
 | 
			
		||||
                echo "update-rc.d \"$name\" defaults >/dev/null"
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +67,8 @@ case "$state_should" in
 | 
			
		|||
            archlinux)
 | 
			
		||||
                # Replace a) at the beginning b) in the middle c) end d) only
 | 
			
		||||
                # Support @name as well...makes it more ugly, but well...
 | 
			
		||||
                echo "sed -i /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/'"
 | 
			
		||||
                echo "sed -i cdist-backup /etc/rc.conf -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name /\\1/' -e 's/^\\(DAEMONS=(.* \\)@\\{0,1\\}$name \\(.*\\)/\\1\\2/' -e 's/^\\(DAEMONS=(.*\\) @\\{0,1\\}$name)/\\1)/' -e 's/^\\(DAEMONS=(\\)@\\{0,1\\}$name)/\\1)/'"
 | 
			
		||||
		echo "rm -f /etc/rc.conf.cdist-backup"
 | 
			
		||||
            ;;
 | 
			
		||||
            debian|ubuntu)
 | 
			
		||||
                echo update-rc.d -f \"$name\" remove
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue