Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

sh file execution stops after apt install

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
christophedm
Posts: 1
Joined: 2020-02-08 09:55

sh file execution stops after apt install

#1 Post by christophedm »

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:~# 

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: sh file execution stops after apt install

#2 Post by Head_on_a_Stick »

This is an XY-problem, adding PPAs to Debian will break your system. Go use Ubuntu instead.
deadbang

reinob
Posts: 1195
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: sh file execution stops after apt install

#3 Post by reinob »

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?

Chrisdb
Posts: 279
Joined: 2018-04-10 07:16

Re: sh file execution stops after apt install

#4 Post by Chrisdb »

What's the use of

Code: Select all

apt -y install ... < "/dev/null";

Post Reply