简体   繁体   中英

Issues with script on 64bit Ubuntu

I have used one script, https://github.com/reddit/reddit/blob/master/install-reddit.sh on several machines and every time it worked perfectly. Now, one one server which has Ubuntu 64bit, I encounter issues with one part of the script.

###############################################################################
# Configure PostgreSQL
###############################################################################
SQL="SELECT COUNT(1) FROM pg_catalog.pg_database WHERE datname = 'reddit';"
IS_DATABASE_CREATED=$(sudo -u postgres psql -t -c "$SQL")

if [ $IS_DATABASE_CREATED -ne 1 ]; then
    cat <<PGSCRIPT | sudo -u postgres psql
CREATE DATABASE reddit WITH ENCODING = 'utf8' TEMPLATE template0;
CREATE USER reddit WITH PASSWORD 'password';
PGSCRIPT
fi

sudo -u postgres psql reddit < $REDDIT_HOME/reddit/sql/functions.sql

This is basically breaking the whole install process. I have tried running the lines manually from the script, like sudo -u postgres psql but I get no output at all. It seems that the database creation is not complete, because if I follow the guide for manually setting up POSTGRESQL, the command sudo -u postgres initdb -D /usr/local/pgsql/data fails with this output:

sudo: initdb: command not found

I also tried adding things to the path, export PATH=$PATH:/usr/lib/postgresql/bin but without help too, initdb wont start. Postgresql is installed, so I don't really know what is causing this.

Output of /etc/init.d/postgresql status is Running clusters: 9.1/main so the service is running.

I even tried installing ia32-libs and libc6-i386 but that didn't do much difference either.

UPDATE: After dealing with that issue, as described in the comments, I have encountered another one. I will put this here too as I think it's also closely related to this. I get the following error then:

+ sudo -u reddit make pyx
[+] including definitions from Makefile.py
python setup.py build_ext --inplace
/home/reddit/reddit/r2/ez_setup.py:101: UserWarning: Module ez_setup was already imported from /home/reddit/reddit/r2/ez_setup.pyc, but /usr/lib/pymodules/python2.7 is being added to sys.path
  import pkg_resources
running build_ext
skipping './r2/models/_builder.c' Cython extension (up-to-date)
building 'r2.models._builder' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c ./r2/models/_builder.c -o build/temp.linux-x86_64-2.7/./r2/models/_builder.o
unable to execute gcc: Permission denied
error: command 'gcc' failed with exit status 1

So, this gcc thing is now causing issues. This lines are triggering this: cd $REDDIT_HOME/reddit/r2 sudo -u $REDDIT_OWNER make pyx # generate the .c files from .pyx

$REDDIT_OWNER is reddit, so it runs as that user, and that ends up in those errors. Can anyone suggest a potential solution for this too? make: * [build/pyx-buildstamp] Error 1

Thanks for your help!

You're probably running into a problem where the PATH get reset by sudo. See here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM