icinga2/test/jenkins/bootstrap-vm.sh

35 lines
1013 B
Bash
Raw Normal View History

#!/bin/sh
2013-12-10 09:27:04 +01:00
if [ "$1" != "--force" ]; then
2013-12-10 10:06:51 +01:00
echo 'This script is NOT intended to be ran by an individual user.' \
2013-12-10 09:27:04 +01:00
'If you are not human, pass "--force" as the first option to it!'
2013-12-10 10:06:51 +01:00
exit 1
fi
2013-12-10 09:27:04 +01:00
if [ $# -lt 3 ]; then
echo 'Too few arguments. You need to pass "--force <user> <host>"' \
'to run this script.'
exit 1
fi
user=$2
host=$3
SSH_OPTIONS="-o PasswordAuthentication=no"
SSH="ssh $SSH_OPTIONS $user@$host"
2013-12-10 10:06:51 +01:00
$SSH "mkdir /vagrant"
# TODO clone git and use the icinga2x puppet modules
git clone git://git.icinga.org/icinga-vagrant.git
scp -qr icinga-vagrant/icinga2x/.vagrant-puppet $user@$host:/vagrant
rm -rf icinga-vagrant
2014-02-05 13:20:50 +01:00
$SSH "useradd vagrant"
$SSH "su -c 'mkdir -p -m 0700 ~/.ssh' vagrant"
$SSH "su -c \"echo '`cat ~/.ssh/id_rsa.pub`' >> ~/.ssh/authorized_keys\" vagrant"
2013-12-10 09:27:04 +01:00
$SSH "echo '10.10.27.1 packages.icinga.org' >> /etc/hosts"
2013-12-10 10:06:51 +01:00
$SSH "puppet apply --modulepath=/vagrant/.vagrant-puppet/modules" \
" /vagrant/.vagrant-puppet/manifests/default.pp"
exit 0