Update of Packer builder for Vagrant and various clouds
[osm/devops.git] / packer / packer_templates / _common / check_vagrant_user.sh
1 #!/bin/bash -eux
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # This script is intended for VIMs-type builders such as OpenStack, which
16 # use cloud images where the `vagrant` user does not exist by default
17
18 USER=vagrant
19 USER_NAME=vagrant
20 PASSWORD=vagrant
21
22 # If the `vagrant` user does not exist, it is created
23 (id ${USER} >/dev/null 2>&1) || adduser --disabled-password --gecos "${USER_NAME}" "${USER}"
24
25 # Comment if no password should be set
26 echo "${USER}:${PASSWORD}" | sudo chpasswd