add test_devinst_in_cowbuilder

This commit is contained in:
Christophe Siraut 2019-10-03 12:58:37 +02:00
parent dfa2f4a17f
commit 8390077b75
1 changed files with 33 additions and 0 deletions

33
test_devinst_in_cowbuilder.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/sh
set -ex
dist=buster
repo='deb http://deb.entrouvert.org/ stretch main'
fork=/tmp/chroot-${dist}
clean() {
chroot $fork cow-shell /etc/init.d/postgresql stop || true
if mount | grep $fork/proc >/dev/null; then umount $fork/proc; fi
if mount | grep $fork/dev/shm >/dev/null; then umount $fork/dev/shm; fi
if [ -d $fork ]; then rm -rf $fork; fi
}
trap clean EXIT
clean
cp -al /var/cache/pbuilder/$dist/base.cow $fork
echo $repo >> $fork/etc/apt/sources.list.d/entrouvert.list
mount -t proc proc $fork/proc # need by postgresql
mount --bind /dev/shm $fork/dev/shm # needed by ansible for multiprocessing
alias shell="COWDANCER_REUSE=yes chroot $fork cow-shell"
shell apt install -y wget ca-certificates gnupg2 git ansible postgresql sudo python
shell adduser --disabled-password --gecos "" testuser
shell usermod -a -G sudo testuser
echo 'testuser ALL=(ALL) NOPASSWD:ALL' >> $fork/etc/sudoers
cp -r . $fork/home/testuser
shell /usr/bin/wget https://deb.entrouvert.org/entrouvert.gpg
shell apt-key add entrouvert.gpg
shell apt update
shell /etc/init.d/postgresql start
shell su testuser -l -c 'ansible-playbook -i inventory.yml install.yml'