Skip to content
Advertisement

How to make an autoinstall command script for Debian

So I was working on a project that need some libraries . so I decided to made an .sh script to just install all at once but I don’t know why it fails . I was searching about it , but just found how to create installer like .deb , etc here are the commands lines that I use

install.sh

#!/bin/sh
sudo apt-get update  
sudo apt-get upgrade  
sudo apt-get install python3-pip python3-dev  
sudo apt-get install build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev  
sudo apt-get install python-numpy python-scipy python-matplotlib python aml  
sudo apt-get install libhdf5-serial-dev python-h5py  
sudo apt-get install graphviz  
sudo apt-get install python-opencv  
sudo apt install python-sklearn  
sudo apt install python3-sklearn   
pip3 install matplotlib
pip3 install pydot-ng
pip3 install tensorflow
pip3 install keras
pip3 install scikit-learn 

using

bash install.sh

and I got this , I think that I’m doing just a few things wrong , I think

E: The update command takes no arguments
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
............

Can someone help me please

Advertisement

Answer

Your shebang at the beginning of your script is for a boot script

You’re using:

#!/bin/sh 

When this script should call the bash environment with:

#!/bin/bash

That should solve your problem.

As sergio states these can be done in one liners like:

#!/bin/bash

sudo apt-get update && sudo apt-get upgrade -y

sudo apt-get install -y python3-pip python3-dev  build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev python-numpy python-scipy python-matplotlib python aml libhdf5-serial-dev python-h5py graphviz python-opencv python-sklearn python3-sklearn

sudo pip3 install matplotlib pydot-ng tensorflow keras scikit-learn

At the very least utilize an array for more efficient bash programming like this:

#!/bin/bash

sudo apt-get update && sudo apt-get upgrade -y

aptDepends=( 
               python3-pip 
               python3-dev  
               build-essential 
               cmake 
               git 
               unzip 
               pkg-config
               libopenblas-dev
               liblapack-dev  
               python-numpy
               python-scipy
               python-matplotlib
               python 
               aml  
               libhdf5-serial-dev 
               python-h5py  
               graphviz  
               python-opencv  
               python-sklearn  
               python3-sklearn
           )

pipDepends=(
               matplotlib
               pydot-ng
               tensorflow
               keras
               scikit-learn
           )
sudo apt-get install -y "${aptDepends[@]}" && sudo pip3 install -y "${pipDepends[@]}"
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement