CSIT-111: Add Packer based framework to auto-generate disk images
[csit.git] / resources / tools / disk-image-builder / ubuntu / scripts-remote / vagrant-user.sh
1 #!/bin/sh -e
2
3 # Copyright (c) 2016 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 echo "********** Adding Vagrant user ***********"
17 # Remove cloud-init as this will slow down the Vagrant boot
18 export DEBIAN_FRONTEND=noninteractive
19 apt-get purge -y cloud-init
20
21 # Add Vagrant user
22 useradd -c "Vagrant User" -m -s /bin/bash vagrant
23
24 mkdir /home/vagrant/.ssh
25 cat - > /home/vagrant/.ssh/authorized_keys <<_EOF
26 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
27 _EOF
28
29 chown -R vagrant.vagrant /home/vagrant/.ssh
30 chmod 700 /home/vagrant/.ssh
31
32 mkdir -p /etc/sudoers.d
33 cat - > /etc/sudoers.d/vagrant <<_EOF
34 vagrant ALL=(root) NOPASSWD:ALL
35 _EOF
36 chmod 440 /etc/sudoers.d/vagrant
37
38 echo "********** Rebooting with new kernel **********"
39 reboot
40 sleep 60