编写vagrant shell配置脚本,在initdb上获取postgres的错误

时间:2016-07-05 22:39:58

标签: mysql postgresql shell

使用以下命令运行Vagrantfile

config.vm.provision "shell", path: "provision.sh"

provision.sh包含:

echo 'hello, world!'
sudo apt-get -y update
sudo apt-get -y install git
sudo /usr/sbin/update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
sudo apt-get -y install postgresql libpq-dev
sudo mkdir -p /usr/local/pgsql/data
sudo chown postgres:postgres /usr/local/pgsql/data
sudo chown postgres:postgres /usr/local/pgsql/
sudo su postgres
/usr/lib/postgresql/9.1/bin/initdb -D /usr/local/pgsql/data
createuser -s vagrant
exit
sudo apt-get -y install curl
/curl -sSL https://get.rvm.io | bash
source /home/vagrant/.rvm/scripts/rvm
which rvm
rvm requirements
rvm install 1.9.3
rvm install 2.1
rvm use 2.1 --default
which ruby
ruby -v
gem install bundler
sudo apt-get -y install nodejs
echo 'All Done!'

流浪者(或流浪汉提供)最后给出:

==> default: Reading package lists...
==> default: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: git is already the newest version.
==> default: 0 upgraded, 0 newly installed, 0 to remove and 184 not upgraded.
==> default: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: libpq-dev is already the newest version.
==> default: postgresql is already the newest version.
==> default: 0 upgraded, 0 newly installed, 0 to remove and 184 not upgraded.
==> default: initdb: cannot be run as root
==> default: Please log in (using, e.g., "su") as the (unprivileged) user that will
==> default: own the server process.
==> default: createuser: could not connect to database postgres: FATAL:  role "root" does not exist

虽然我实际上想要使用mysql配置我的vm,但这是我从以下开始的示例:http://tutorials.jumpstartlab.com/topics/vagrant_setup.html

如何从shell配置脚本运行initdb并解决此问题?

0 个答案:

没有答案