Merge pull request #773 from sideeffect42/postgres-nopw
__postgres_{database,role}: Run psql with --no-password (-w)
	
	
This commit is contained in:
		
				commit
				
					
						5b20950045
					
				
			
		
					 3 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -34,7 +34,7 @@ esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
name="$__object_id"
 | 
					name="$__object_id"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")"
 | 
					if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")"
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
    echo 'present'
 | 
					    echo 'present'
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
name="$__object_id"
 | 
					name="$__object_id"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")"
 | 
					if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")"
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
    echo 'present'
 | 
					    echo 'present'
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ case "$state_should" in
 | 
				
			||||||
        [ -n "$password" ] && password="PASSWORD '$password'"
 | 
					        [ -n "$password" ] && password="PASSWORD '$password'"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cmd="CREATE ROLE $name WITH $password $booleans"
 | 
					        cmd="CREATE ROLE $name WITH $password $booleans"
 | 
				
			||||||
        echo "su - '$postgres_user' -c \"psql postgres -c \\\"$cmd\\\"\""
 | 
					        echo "su - '$postgres_user' -c \"psql postgres -wc \\\"$cmd\\\"\""
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    absent)
 | 
					    absent)
 | 
				
			||||||
        echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\""
 | 
					        echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue