The script for automatically configuring pgsql under BT5

Source: Internet
Author: User
#! /Bin/sh # Killdatabaseprocessecho & quot; Killingdatabaseprocess .. & quot; kill $ (pgreppostgres) & gt;/dev/null2 & gt; & amp; 1 ## replacethemd5authwithtrustforlocal1_4co #! /Bin/sh
 
# Kill database process
Echo "Killing database process .."
Kill $ (pgrep postgres)>/dev/null 2> & 1
 
# Replace the md5 auth with trust for local ipv4 connections
Echo "Allowing all local IPV4 connections .."
Cp/opt/framework3/postgresql/data/pg_assist.conf/opt/framework3/postgresql/data/pg_assist.conf.bak
Cat/opt/framework3/postgresql/data/pg_assist.conf | sed-e's/host all 127.0.0.1 \/32 md5/host all 127.0.0.1 \/32 trust/'>/opt /framework3/postgresql/data/tmp. conf
Mv/opt/framework3/postgresql/data/tmp. conf/opt/framework3/postgresql/data/pg_apps.conf
 
# Restart IPVs server (only necessary during this process, on reboot it will start automatically)
Echo "Restarting IPVs server (only necessary during this process, on reboot it will start automatically ).."
Su postgres-c "/opt/framework3/postgresql/bin/postgres-D/opt/framework3/postgresql/data-p 7175 &"
# Wait for server to start
Sleep 5
 
# Now we can access via psql we can change user for database
Echo "Changing login s user login s password to 'others' s _ password '.."
Su postgres-c "psql-h 127.0.0.1-p 7175-c \" alter user login s with password 'login S _ password' \ ";">/dev/null 2> & 1
 
# Create a database for usage with msf
Echo "Creating database 'MSF _ db' for use with metasploit .."
Su postgres-c "psql-h 127.0.0.1-p 7175-c \" create database msf_db \ ";">/dev/null 2> & 1
 
# Change back to md5 auth
Echo "Changing back to md5 auth .."
Cat/opt/framework3/postgresql/data/pg_assist.conf | sed-e's/host all 127.0.0.1 \/32 trust/host all 127.0.0.1 \/32 md5/'>/opt /framework3/postgresql/data/tmp. conf
Mv/opt/framework3/postgresql/data/tmp. conf/opt/framework3/postgresql/data/pg_apps.conf
 
###############################
 
# Msfconsole
 
# Change ruby version
Echo "##################################"
Echo "Changing Ruby version-please choose the '0' option .."
Echo "##################################"
Update-alternatives -- config ruby
 
# Install S s gem
Gem install postgres
 
# Go into msfconsole and choose the db_driver
Echo "Updating msf .."
/Opt/framework3/msf3/msfupdate
 
Echo
Echo "###################################### ################################"
Echo "starting msfconsole .."
Echo "now enter 'DB _ driver postgresql 'and then 'DB _ connect S: postgres_password@127.0.0.1: 7175/msf_db '"
Echo "###################################### ################################"
 
/Opt/framework3/msf3/msfconsole

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.