PostgreSQL部署脚本暂停
我有一个bashshell部署脚本(linodestackscript),它在部署Debian6.0服务器时运行。脚本以root用户身份运行,脚本如下所示:PostgreSQL部署脚本暂停,sql,bash,postgresql,shell,debian,Sql,Bash,Postgresql,Shell,Debian,我有一个bashshell部署脚本(linodestackscript),它在部署Debian6.0服务器时运行。脚本以root用户身份运行,脚本如下所示: apt-get update apt-get install postgresql postgresql-contrib pgadmin3 passwd postgres su - postgres psql -c "ALTER USER postgres WITH PASSWORD 'changeme'" -d template1 su
apt-get update
apt-get install postgresql postgresql-contrib pgadmin3
passwd postgres
su - postgres
psql -c "ALTER USER postgres WITH PASSWORD 'changeme'" -d template1
su - postgres
createdb mytestdb
psql mytestdb
我有两个问题:
首先,当我通过shell手动运行每一行时,它都会工作,但当我作为stackscript运行它时,它会运行passwd postgres行,但在它之后什么也不运行
其次,当我运行passwd postgres行时,它要求我手动输入密码。有什么方法可以将它作为一个变量放入shell脚本中吗?
passwd
旨在以交互方式使用。
批量更改密码的正确命令是chpasswd
例如:
#!/bin/sh
echo 'postgres:newpassword' | chpasswd
还要注意的是,您的脚本执行su-postgres的方式看起来不像是在非交互模式下执行的。
最好这样做:su-c'command1;命令2…'-postgres