blob: 683a0d6a55550bf71d3aafb4ec5226636895bc3f [file] [log] [blame]
Anthony Youngc1024d82011-11-09 18:58:07 -08001#!/usr/bin/env bash
2
Dean Troyere62ba4d2012-06-27 22:07:34 -05003# **copy_dev_environment_to_uec.sh**
4
Anthony Youngc1024d82011-11-09 18:58:07 -08005# Echo commands
6set -o xtrace
7
8# Exit on error to stop unexpected errors
9set -o errexit
10
11# Keep track of the current directory
12TOOLS_DIR=$(cd $(dirname "$0") && pwd)
Dean Troyer7f9aa712012-01-31 12:11:56 -060013TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
14
15# Import common functions
16. $TOP_DIR/functions
Anthony Youngc1024d82011-11-09 18:58:07 -080017
18# Change dir to top of devstack
19cd $TOP_DIR
20
21# Echo usage
22usage() {
23 echo "Add stack user and keys"
24 echo ""
25 echo "Usage: $0 [full path to raw uec base image]"
26}
27
28# Make sure this is a raw image
29if ! qemu-img info $1 | grep -q "file format: raw"; then
30 usage
31 exit 1
32fi
33
34# Mount the image
35DEST=/opt/stack
36STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage.user
37mkdir -p $STAGING_DIR
38umount $STAGING_DIR || true
39sleep 1
40mount -t ext4 -o loop $1 $STAGING_DIR
41mkdir -p $STAGING_DIR/$DEST
42
43# Create a stack user that is a member of the libvirtd group so that stack
44# is able to interact with libvirt.
45chroot $STAGING_DIR groupadd libvirtd || true
46chroot $STAGING_DIR useradd stack -s /bin/bash -d $DEST -G libvirtd || true
47
Anthony Younge2280932011-11-09 22:29:22 -080048# Add a simple password - pass
Anthony Youngc1024d82011-11-09 18:58:07 -080049echo stack:pass | chroot $STAGING_DIR chpasswd
50
Anthony Younge2280932011-11-09 22:29:22 -080051# Configure sudo
Jesse Andrewsd7326d22011-11-20 10:02:26 -080052( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
53 > $STAGING_DIR/etc/sudoers.d/50_stack_sh )
Anthony Younge2280932011-11-09 22:29:22 -080054
Anthony Youngc1024d82011-11-09 18:58:07 -080055# Copy over your ssh keys and env if desired
56cp_it ~/.ssh $STAGING_DIR/$DEST/.ssh
57cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/$DEST/.ssh/authorized_keys
58cp_it ~/.gitconfig $STAGING_DIR/$DEST/.gitconfig
59cp_it ~/.vimrc $STAGING_DIR/$DEST/.vimrc
60cp_it ~/.bashrc $STAGING_DIR/$DEST/.bashrc
61
Jesse Andrewsd7326d22011-11-20 10:02:26 -080062# Copy devstack
63rm -rf $STAGING_DIR/$DEST/devstack
64cp_it . $STAGING_DIR/$DEST/devstack
65
Anthony Youngc1024d82011-11-09 18:58:07 -080066# Give stack ownership over $DEST so it may do the work needed
67chroot $STAGING_DIR chown -R stack $DEST
68
Anthony Younge2280932011-11-09 22:29:22 -080069# Unmount
70umount $STAGING_DIR