-1

I am making something to show my school which will be installed on multiple RasPi 3s, using Stretch Lite. Because of this, I have made an 'install script' which runs all of the installing packages and installing python stuff. All of the lines can be run exactly as is from the CLI, but when I put them into a .sh file and do sudo chmod +x, it doesn't work when I do ./install.sh.

Here is the error:

E: Invalid operation update
E: Invalid operation upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-dev
./install.sh: 4: ./install.sh: pip3: not found
./install.sh: 5: ./install.sh: git: not found
./install.sh: 6: cd: can't cd to Adafruit_Python_DHT
python3: can't open file 'setup.py': [Errno 2] No such file or directory
./install.sh: 8: cd: can't cd to ../flask-prod
chmod: cannot access 'service.sh'$'\r': No such file or directory

The files are here and the install script is called 'install.sh'

Any help?

This was my original install.sh file:

apt-get update -y
apt-get upgrade -y
apt-get install python3-pip apache2 apache2-utils libexpat1 ssl-cert libapache2-mod-wsgi git-core python-dev -y
pip3 install flask
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
python3 setup.py install
cd flask-prod
chmod +x service.sh
  • 2
    Could you include the bash script you are using? It's difficult to know what's wrong with the script without seeing it. – Aurora0001 Apr 8 '18 at 12:13
  • @scitronboy That file will change when the OP makes another commit, and then nodoby will be able to tell what the original problem was. The code relevant to the question should be in the question. – Dmitry Grigoryev Apr 9 '18 at 8:17
  • @DmitryGrigoryev thanks for correcting me, his original file is here(this is an older commit, it won't change): github.com/Injector-Spenral/Weather-Station/blob/… – scitronboy Apr 9 '18 at 14:44
2

have you tried to execute the steps manually? also, did you run the script with sudo? the errors you show are permissions related

sudo ./install.sh

also, add this to the first line in your script

#!/bin/sh 
  • make sure you add #!/bin/sh to the top of your script. – scitronboy Apr 8 '18 at 17:32
  • I run it in sudo, and the steps do work when copy pasted manually – John Andleson Apr 9 '18 at 2:59
  • did you create the file on windows? if so, try using dos2unix command to fix the new line characters – Frederick Álvarez Apr 9 '18 at 3:02
0

Try changing your file install.sh so it looks like this:

#!/bin/sh
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install python3-pip apache2 apache2-utils libexpat1 ssl-cert libapache2-mod-wsgi git-core python-dev -y
sudo pip3 install flask
cd /home/pi    #change into the home directory
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo python3 setup.py install
cd flask-prod
chmod +x service.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.