sh file execution stops after apt install

New to Debian (Or Linux in general)? Ask your questions here!

sh file execution stops after apt install

Postby christophedm » 2020-02-08 09:58

Hi

I'm new to linux and am trying to run a set of bash commands in sequential order using a sh file.
This is my sh file :

Code: Select all
#!/bin/bash
apt update;
apt -y install apt-transport-https ca-certificates curl;
gnupg2 software-properties-common;
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -;
add-apt-repository \
 "deb [arch=amd64] https://download.docker.com/linux/debian \
 $(lsb_release -cs) \
 stable";
apt update;
apt -y install docker-ce docker-ce-cli containerd.io < "/dev/null";
usermod -aG docker $USER;
newgrp docker;
apt-get install ufw;
ufw allow 22;
ufw allow 80;
ufw allow 443;
ufw enable;
apt-get install nginx;
apt-get update;
apt-get install software-properties-common;
add-apt-repository universe;
add-apt-repository ppa:certbot/certbot;
apt-get update;
apt-get install certbot python-certbot-nginx;


My problem is that execution stops after the line
Code: Select all
apt -y install docker-ce docker-ce-cli containerd.io < "/dev/null";


When docker is already installed.
This is my output :

Code: Select all
root@scw-peaceful-poitras:~# chmod +x prepvps.sh
root@scw-peaceful-poitras:~# sudo ./prepvps.sh
Hit:1 http://security.debian.org buster/updates InRelease
Hit:2 http://deb.debian.org/debian buster InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Hit:4 http://deb.debian.org/debian buster-backports InRelease
Hit:5 http://ppa.launchpad.net/scaleway/stable/ubuntu bionic InRelease
Hit:6 https://download.docker.com/linux/debian buster InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
4 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version (1.8.2).
ca-certificates is already the newest version (20190110).
curl is already the newest version (7.64.0-4).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
./prepvps.sh: line 4: gnupg2: command not found
OK
Hit:1 http://security.debian.org buster/updates InRelease
Hit:2 http://deb.debian.org/debian buster InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Hit:4 http://deb.debian.org/debian buster-backports InRelease
Hit:5 http://ppa.launchpad.net/scaleway/stable/ubuntu bionic InRelease
Hit:6 https://download.docker.com/linux/debian buster InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
4 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree
Reading state information... Done
containerd.io is already the newest version (1.2.10-3).
docker-ce-cli is already the newest version (5:19.03.5~3-0~debian-buster).
docker-ce is already the newest version (5:19.03.5~3-0~debian-buster).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
root@scw-peaceful-poitras:~#
christophedm
 
Posts: 1
Joined: 2020-02-08 09:55

Re: sh file execution stops after apt install

Postby Head_on_a_Stick » 2020-02-08 10:38

This is an XY-problem, adding PPAs to Debian will break your system. Go use Ubuntu instead.
User avatar
Head_on_a_Stick
 
Posts: 12004
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: sh file execution stops after apt install

Postby reinob » 2020-02-08 12:24

From the output you've posted it seems that your script is running and ending just fine.

Please note that you probably wanted:
Code: Select all
apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common


instead of:
Code: Select all
apt -y install apt-transport-https ca-certificates curl;
gnupg2 software-properties-common;


Plus you should not end the commands with ";". Bash is not C.
Plus I'm not sure you know what "newgrp" does, but that's up to you..

What exactly is your problem?
reinob
 
Posts: 779
Joined: 2014-06-30 11:42

Re: sh file execution stops after apt install

Postby Chrisdb » 2020-02-08 19:44

What's the use of
Code: Select all
apt -y install ... < "/dev/null";
Chrisdb
 
Posts: 273
Joined: 2018-04-10 07:16


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable