简体   繁体   中英

bash script LAMP creation “yes”

I wrote this little bash script:

#!/bin/bash


apt-get update
apt-get upgrade
apt-get install apache2
apt-get install php5
apt-get install mysql-server
apt-get install php5-mysql
service apache2 restart
apt-get update 
apt-get install python-software-properties
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php5-5.6
apt-get update
apt-get upgrade
apt-get install php5
apt-get install vsftpd
apt-get install php5-curl

in order to create lamp and install php 5.6 on ubuntu 14.04

Everything works just fine, but I need to type "y" when prompted for and one time I need to hit enter (at this line:

add-apt-repository ppa:ondrej/php5-5.6 )

The script executes without typing "y" when running it with

yes | ./script.sh

but at the point I need to hit enter, it just gives me an output of numerous "y" and breaks. After running the script those files:

E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/cache/apt/archives/

are locked and I need to unlock them again, in order to install further stuff.

Is there a way to get this running properly? Without a lock of files and just doing what it is supposed to do...

您可以将每个apt-get install更改为apt-get -y install ,并将add-apt-repository更改为add-apt-repository -y以对所有问题都回答是。

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