1

I wrote a .sh file that only has a series of linux commands to automatically download all of my required files, packages and software should I need to do an OS wipe. This is what it looks like:

sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y
sudo apt-get remove --auto-remove cheese -y
sudo ubuntu-drivers autoinstall -y

sudo add-apt-repository -y ppa:kdenlive/kdenlive-stable
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo add-apt-repository -y ppa:cappelikan/ppa
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y

sudo apt-get install build-essential git curl wget ca-certificates gnupg lsb-release unrar libglvnd-dev pkg-config libssl-dev libffi-dev python3-dev python3-pip synaptic ubuntu-restricted-extras kdenlive nvidia-cuda-toolkit ffmpeg v4l2loopback-dkms obs-studio p7zip-full bazel-bootstrap libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-dev protobuf-compiler libboost-all-dev libopenblas-dev libleveldb-dev libsnappy-dev libhdf5-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler clang zlib1g  torbrowser-launcher octave liboctave-dev mainline deluge tree dconf-editor nemo spyder octave htop cmake qsharp mthree cirq-core cirq-pascal  pyquil -y

wget https://zoom.us/client/latest/zoom_amd64.deb
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
wget https://github.com/TorchStudio/torchstudio/releases/download/0.9.7/TorchStudio_0.9.7-Linux_Installer.deb
wget https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb?_ga=2.120179208.140754703.1654140064-1729555164.1654140064

git clone https://github.com/qulacs/qulacs.git

sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)

#! Install Display driver
#! chmod +x displaylink-driver-*
#! sudo ./displaylink-driver-*

pip3 install –upgrade pip

#! Install python packages
pip3 install numpy pandas Pillow lxml opencv-python matplotlib spotify_dl instaloader scikit-learn scikit-image scipy numba tensorflow tensorflow-addons torch torchvision torchaudio fastai keras jupyterlab notebook qiskit tensorflow-quantum cirq argon2-cffi ipykernel ipython-genutils nbconvert nbformat prometheus-client Send2Trash terminado ipython jupyter-server jupyterlab-server nbclassic vosk pyquil imutils dlib mxnet qulacs torchviz

pip3 install pennylane --upgrade

pip3 install pennylane-sf pennylane-qiskit pennylane-cirq pennylane-forest pennylane-qsharp --force --no-dependencies


#! Install apps
sudo snap install clion --classic
sudo snap install pycharm-professional --classic
sudo snap install webstorm --classic
sudo snap install thunderbird
sudo snap install walc
sudo snap install gimp
sudo snap install telegram-desktop
sudo snap install slack --classic
sudo snap install caprine
sudo snap install skype
sudo snap install teams
sudo snap install android-messages-desktop --edge
sudo snap install discord
sudo snap install code --classic
sudo snap install simplescreenrecorder
sudo snap install vlc
sudo snap install meshlab
sudo snap install amass
sudo snap install obs-studio
sudo snap install inkscape
sudo snap install remmina
sudo snap install netron
sudo snap install feroxbuster
sudo snap install joplin
sudo snap install poweshell –classic
sudo snap install zaproxy –classic
sudo snap install bitcoin-core
sudo snap install flutter –classic
sudo snap alias flutter.dart dart
sudo snap install android-studio –classic

#! Install chrome, zoom and torchstudio
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo dpkg -i zoom_amd64.deb
sudo dpkg -i TorchStudio*
sudo dpkg -i nordvpn*
sudo chmod 777 ./quacs/script/build_gcc.sh nordvpn*
./qulacs/script/build_gcc.sh
sudo apt-get install ./nordvpn*
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y
sudo apt-get install nordvpn


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

However, a lot of the commands don't get executed. Particularly, the sudo apt-get install commands and pip3 commands. How can I fix this situation? Where am I going wrong?

2 Answers 2

0

To answer:

Particularly, the sudo apt-get install commands and pip3 commands.

Looking at your sudo apt-get install you may have crossed the number of acceptable arguments for apt-get but I'm just guessing as documentation does not state that there's a limit.

To debug your script I suggest you run:

bash -x yourscript.sh

which will output all the calls with all the messages.

If it is the case you could try to install with following for loop and separate package file:

for i in `cat packageList`;do sudo apt-get -y install $i;done

Also don't forget that you want to run this script without being interactive - therefore sudo must not ask for password and other commands must not ask for any confirmation or similar.

Hope it helps.

1
0

Few things here. You didn't say how you are running it but given you didn't say any specific errors I'm guessing as a background task. Meaning you never see the password prompt for the tons of sudo lines causing them to (timeout) fail. If you are indeed running it in the background run it with >$HOME/Desktop/script.log 2>&1 to see what is failing.

You need to either split the script into things that need sudo and things that don't. Then remove all the sudo prefixes and run the script that requires it (sudo my_cool_reinstall_script.sh) once so you give your password upfront and everything in the script can run as you expect. Or you can write an sudoers rule allowing sudo apt* to run without your password to execute the script as is.

This however assumes that maybe you give sudo password for the first command, grace time expires and you don't notice it's asking again and times out.

OR perhaps you are trying to install packages whose names have changed. I notice your drivers command is depreciated as autoinstall is now just install and ubuntu-drivers will kick as warning about that too.

I have tried something similar and gave up due to ppa's being changed, closed, package name changes and various other issues that just made it not feasible. NixOS is the only distro I know that you can easily do this.

It's hard to say right now without knowing how you're running it in a way that you don't see the errors from the failing commands.

-- Also no you have not hit any limit with apt that requires a loop. If there is a limit I've yet to hit it and I've installed a lot more in a one liner.

2
  • I run it as ./file.sh
    – oo92
    Jun 6 at 22:43
  • 2
    Your response seems there is a positional logic being lost in translation. Are you running it in a way you can see it as it executes? I'm confused as to how you're running it without seeing the errors or output from the failing commands.
    – g0Brrrr
    Jun 6 at 23:04

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.