Menu

Can't Find psql

Help
Anonymous
2011-04-28
2013-05-30
  • Anonymous

    Anonymous - 2011-04-28

    using the -install command, psql can't be found, even though it is sitting right there at ~/Postgres841/bin/psql

    It looks like the code assumes that psql is in $PATH. psql should probably be given a variable in the code, then redefined if the -install option is given, then changing all instances of psgl to $psgl_bin, then asking the user to add $installdir/bin to his $PATH.

    Alternatively, for an install, you may wish to append $installdir/bin to the $PATH, but then osm2postgresql_02.sh would need to check for the existence of psql in the $PATH and in the hardcoded $installdir.

    Or, osm2postgresql_02.sh can check for the existence of , and create if necessary, a .osm2postgres file in the user's $HOME which would contain the path to psql and osmosis the database name, host, port, and any other options that would need to be remembered from one run to the next.

    Keep up the good work.

     
  • Mayeul

    Mayeul - 2011-04-28

    Thanks a lot for your comment! Indeed, I have another psql installed which is in the path on my machine, so the script did not complained. I'm not using much the one-click installer  because of this bug: http://forums.enterprisedb.com/posts/list/2616.page (enterprisedb is not very responsive).

    [in the help:]
    -b, --bash_init_script  the name of the file (e.g. your bash init script) where to add
                             a command that will add the path to 'psql' if using the 
                             --installdir option. Default is ~/.bashrc
    [in the option parsing part:]
        -b | --bash_init_script ) shift
                            bash_init_script=$1 ;;
    

    After this:

        sudo -k $installdir/postgresplus-8.4.1-2-linux$archfilestring.bin  \
          --enable-components dbserver,postgis --disable-components  \
          slony,pgJdbc,psqlOdbc,npgsql,pgbouncer,pgmemcache,pgagent --prefix $installdir  \
          --datadir $datadir --serverport $port --mode unattended --unattendedmodeui  \
          minimal
      fi
    

    Add this:

    # Add new psql to the path. Thanks tahongawaka for pointing the need for this.
    # See discussion at https://sourceforge.net/projects/osm2postgresql/forums/forum/1683571/topic/4507607
    if  [ -z "$bash_init_script" ] ; then
        bash_init_script=~/.bashrc # use default value
    fi
    echo "Postgres server installed. Adding the path to '$installdir/bin/psql' in $bash_init_script"
    touch $bash_init_script # make sure the file exists
    echo "" >> $bash_init_script # add an empty line
    echo "PATH=$installdir/bin:\$PATH; export PATH" >> $bash_init_script
    echo "The file '$bash_init_script' now contains the following code related to the PATH:"
    cat  $bash_init_script | grep PATH
    
     
  • Rainer Dreyer

    Rainer Dreyer - 2011-06-05

    I had the same problem with psql not being found. I\m using the _03 version of the script, recently downloaded. I manually exported the PATH and then it worked fine :)

    I hit the next issue, though:
    You will be asked the current postgres password now.
    Please type 'postgres' (without quotes).
    Password for user postgres:
    ALTER USER ubuntu WITH PASSWORD 'ubuntu' ;
    ERROR:  role "ubuntu" does not exist
    CREATE DATABASE "OSM2011-06-05_00:06:12" WITH OWNER ubuntu TEMPLATE template_postgis;
    ERROR:  role "ubuntu" does not exist
    \connect: FATAL:  database "OSM2011-06-05_00:06:12" does not exist

    I'm using an ubuntu 11.04 EC2 instance in case that helps to find the issue!

     
  • Mayeul

    Mayeul - 2011-06-05

    Let's say you run the script with linux user named "ubuntu". The script assumes this postgresql user exists and it's password is 'ubuntu'.
    You can create the user by doing one of the following:
    # as ubuntu user:
    echo "CREATE USER `whoami`; ALTER USER `whoami` SUPERUSER;" > psql
    # or:
    echo "CREATE USER ubuntu; ALTER USER ubuntu SUPERUSER;" > psql
    # or: uncomment (read: remove "-" in line 336 of the script

    Please tell me if this works or if you need more helps.

    For the psql not being found, version 03 contains new code that should fixe this, see code near "Postgres server installed. Adding the path to '$installdir/bin/psql' in $bash_init_script"

    However, this might not work on some settings (depending on where your psql is and what  bash config files you use). May I ask you to say precisely what you did to manually export the PATH ?
    I'm using the script in production on Kubuntu 10.10 and 11.04.

    Regards,
    Mayeul

     
  • Rainer Dreyer

    Rainer Dreyer - 2011-06-05

    Unfortunately I terminated that EC2 instance after getting frustrated with it, so I can't give you an exact bash history, but I believe I simply ran "export PATH=$installdir/bin:\$PATH", after which the installation continued (and stopped on the ubuntu role issues).

    I got set up happily using http://weait.com/content/build-your-own-openstreetmap-server on a fresh EC2 instance, though, so no problem!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.