From 5ff82c53fd67245761f193c0825813c3dafffbe6 Mon Sep 17 00:00:00 2001 From: Luiz Andrade Date: Tue, 19 Jan 2016 14:50:21 -0200 Subject: [PATCH] Now the install script can change postgres's password. --- ManagementScripts/install.sh | 20 +++++++++++++++++--- ManagementScripts/teste.sh | 16 +++++++++++----- plugins.xml | 4 ++-- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ManagementScripts/install.sh b/ManagementScripts/install.sh index a9a3ebd..0dac89a 100755 --- a/ManagementScripts/install.sh +++ b/ManagementScripts/install.sh @@ -40,8 +40,8 @@ function configure_apache { sudo /etc/init.d/apache2 restart } -function configure_postgresql { - export PGPASSWORD=postgres +function configure_postgresql() { + export PGPASSWORD=$1 postgresqlfolder=$(psql -c 'show config_file' -U postgres -h localhost -p 5432 |grep postgresql.conf) pghbafolder=$(psql -c 'show hba_file' -U postgres -h localhost -p 5432 |grep pg_hba.conf) sudo sed -i "s/listen_addresses = 'localhost'/listen_addresses = '\*'/g" $postgresqlfolder @@ -52,6 +52,11 @@ function configure_postgresql { sudo /etc/init.d/postgresql restart } +function alter_postgres_password() { + export PGPASSWORD=$1 + psql -c "ALTER USER postgres WITH PASSWORD '$2'" -U postgres -h localhost -p 5432 +} + function update_plugins { #getting plugins latest tag html files $WGET https://github.com/lcoandrade/DsgTools/releases/latest -O ~/lastestdsgtools.html @@ -134,7 +139,16 @@ fi echo "Configurar PostgresSQL? (s/n)"; read configurarpostgres configurarpostgres="${configurarpostgres:=s}" if [[ $configurarpostgres == [sS] ]]; then - configure_postgresql + echo "Entre com o password: "; read PASSWORD + configure_postgresql $PASSWORD +fi + +echo "Alterar senha do usuário Postgres? (s/n)"; read alterarsenha +alterarsenha="${alterarsenha:=s}" +if [[ $alterarsenha == [sS] ]]; then + echo "Entre com o password atual: "; read PASSWORD + echo "Entre com o novo password: "; read NEWPASSWORD + alter_postgres_password $PASSWORD $NEWPASSWORD fi echo "Atualizar plugins? (s/n)"; read atualizarplugins diff --git a/ManagementScripts/teste.sh b/ManagementScripts/teste.sh index bd854cd..11eff23 100755 --- a/ManagementScripts/teste.sh +++ b/ManagementScripts/teste.sh @@ -1,11 +1,17 @@ #!/bin/bash #configuring postgresql network-------------------------------------------- -echo "Teste? (s/n) "; read sim -sim="${sim:=s}" -echo $sim -if [ "$sim" == "s" ]; then - echo "SIM SIM" +function alter_postgres_password() { + export PGPASSWORD=$1 + psql -c "ALTER USER postgres WITH PASSWORD '$2'" -U postgres -h localhost -p 5432 +} + +echo "Alterar senha do usuário Postgres? (s/n)"; read alterarsenha +alterarsenha="${alterarsenha:=s}" +if [[ $alterarsenha == [sS] ]]; then + echo "Entre com o password atual: "; read PASSWORD + echo "Entre com o novo password: "; read NEWPASSWORD + alter_postgres_password $PASSWORD $NEWPASSWORD fi #----------------installing and configuring packages-------------------------------------------- diff --git a/plugins.xml b/plugins.xml index bf9a06d..dc542fd 100644 --- a/plugins.xml +++ b/plugins.xml @@ -1,10 +1,10 @@ - + Tools to manage DSG's cartographic production.> DSGManagementTools with the followinf features -Replication of PostGIS databases created with the DsgTools plugin. -1.1.5 +1.2 2.6 2.99 https://github.com/phborba/DSGManagementTools>