Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I run the following non interactive script on Ubuntu Server 13.04 it's interrupted when lxc-docker package finishes installation.

Script :

ssh -o StrictHostKeychecking=no -t -t -i $CERT $USER@$SERVER <<'ENDSSH'

sudo DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository -y ppa:dotcloud/lxc-docker
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install lxc-docker

echo "some other actions here..."

exit #SSH session

ENDSSH
exit

Everything seems to be fine but then the script is interrupted after this line in the output :

Processing triggers for ureadahead ...

1) Why is this happenning? How can I prevent that?

2) If not, how I can detect that ssh session has finished unsucessfully?

Last lines from installation (shortened) :

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  bridge-utils bsdtar cgroup-lite debootstrap dnsmasq-base libapparmor1
  libarchive13 libcap2-bin liblxc0 liblzo2-2 libnetfilter-conntrack3
  libnettle4 libpam-cap libseccomp1 lxc lxc-templates python3-lxc
Suggested packages:
  bsdcpio lrzip libcap-dev btrfs-tools lvm2 lxctl qemu-user-static
The following NEW packages will be installed:
  bridge-utils bsdtar cgroup-lite debootstrap dnsmasq-base libapparmor1
  libarchive13 libcap2-bin liblxc0 liblzo2-2 libnetfilter-conntrack3
  libnettle4 libpam-cap libseccomp1 lxc lxc-docker lxc-templates python3-lxc
0 upgraded, 18 newly installed, 0 to remove and 29 not upgraded.
Need to get 2,495 kB of archives.
After this operation, 8,742 kB of additional disk space will be used.
Get:1 http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ raring/main liblzo2-2 amd64 2.06-1build1 [53.2 kB]
Get:2 http://us-west-2.ec2.archive.ubuntu.com/ubuntu/ raring/main libnettle4 amd64 2.4-3 [94.7 kB]
.
.
.
.
.
.
Setting up libnetfilter-conntrack3:amd64 (1.0.1-1) ...
Setting up dnsmasq-base (2.65-1ubuntu1) ...
Setting up python3-lxc (0.9.0-0ubuntu3.2) ...
Setting up lxc (0.9.0-0ubuntu3.2) ...
lxc start/running
Setting up lxc dnsmasq configuration.
Setting up bsdtar (3.1.2-5ubuntu1) ...
Setting up libcap2-bin (1:2.22-1.2ubuntu2) ...
Setting up libpam-cap:amd64 (1:2.22-1.2ubuntu2) ...
Setting up cgroup-lite (1.8) ...
cgroup-lite start/running
Setting up debootstrap (1.0.46ubuntu1) ...
Processing triggers for ureadahead ...
Setting up lxc-docker (0.4.0-1) ...
docker start/running, process 2444
Setting up lxc-templates (0.9.0-0ubuntu3.2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Processing triggers for ureadahead ...
share|improve this question

1 Answer 1

Just to state the obvious (as a work-around, not a proper solution), maybe try to scp the script to the server, and then execute the script...?

$ cat<<ENDSSH > /tmp/tmp.sh
sudo DEBIAN_FRONTEND=noninteractive apt-get ...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install lxc-docker
echo "some other actions here..."
exit
ENDSSH

And then,

$ scp  /tmp/tmp.sh ${USER}@${SERVER}:/tmp/tmp.sh \
  && ssh $USER@$SERVER 'chmod u+x /tmp/tmp.sh && /tmp/tmp.sh; rm /tmp/tmp.sh'

If that also terminates, then the remote commands may have to be run in the background, disconnect, followed by another ssh command to check the result of executing the script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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