Browse code

Merge pull request #67 from dtroyer/7-stack-home

stack home dir

Jesse Andrews authored on 2011/10/20 07:59:19
Showing 2 changed files
... ...
@@ -44,6 +44,40 @@ if [ ! -d $FILES ]; then
44 44
 fi
45 45
 
46 46
 
47
+
48
+# Settings
49
+# ========
50
+
51
+# This script is customizable through setting environment variables.  If you
52
+# want to override a setting you can either::
53
+#
54
+#     export MYSQL_PASSWORD=anothersecret
55
+#     ./stack.sh
56
+#
57
+# You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh``
58
+#
59
+# Additionally, you can put any local variables into a ``localrc`` file, like::
60
+#
61
+#     MYSQL_PASSWORD=anothersecret
62
+#     MYSQL_USER=hellaroot
63
+#
64
+# We try to have sensible defaults, so you should be able to run ``./stack.sh``
65
+# in most cases.
66
+#
67
+# We our settings from ``stackrc``.  This file is distributed with devstack and
68
+# contains locations for what repositories to use.  If you want to use other 
69
+# repositories and branches, you can add your own settings with another file 
70
+# called ``localrc``
71
+#
72
+# If ``localrc`` exists, then ``stackrc`` will load those settings.  This is 
73
+# useful for changing a branch or repostiory to test other versions.  Also you
74
+# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead
75
+# of letting devstack generate random ones for you.
76
+source ./stackrc
77
+
78
+# Destination path for installation ``DEST``
79
+DEST=${DEST:-/opt/stack}
80
+
47 81
 # OpenStack is designed to be run as a regular user (Dashboard will fail to run
48 82
 # as root, since apache refused to startup serve content from root user).  If
49 83
 # stack.sh is run as root, it automatically creates a stack user with
... ...
@@ -61,7 +95,7 @@ if [[ $EUID -eq 0 ]]; then
61 61
 
62 62
     if ! getent passwd stack >/dev/null; then
63 63
         echo "Creating a user called stack"
64
-        useradd -U -G sudo -s /bin/bash -m stack
64
+        useradd -U -G sudo -s /bin/bash -d $DEST -m stack
65 65
     fi
66 66
 
67 67
     echo "Giving stack user passwordless sudo priviledges"
... ...
@@ -72,7 +106,7 @@ if [[ $EUID -eq 0 ]]; then
72 72
         > /etc/sudoers.d/50_stack_sh )
73 73
 
74 74
     echo "Copying files to stack user"
75
-    STACK_DIR="/home/stack/${PWD##*/}"
75
+    STACK_DIR="$DEST/${PWD##*/}"
76 76
     cp -r -f "$PWD" "$STACK_DIR"
77 77
     chown -R stack "$STACK_DIR"
78 78
     if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
... ...
@@ -83,40 +117,6 @@ if [[ $EUID -eq 0 ]]; then
83 83
     exit 1
84 84
 fi
85 85
 
86
-
87
-# Settings
88
-# ========
89
-
90
-# This script is customizable through setting environment variables.  If you
91
-# want to override a setting you can either::
92
-#
93
-#     export MYSQL_PASSWORD=anothersecret
94
-#     ./stack.sh
95
-#
96
-# You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh``
97
-#
98
-# Additionally, you can put any local variables into a ``localrc`` file, like::
99
-#
100
-#     MYSQL_PASSWORD=anothersecret
101
-#     MYSQL_USER=hellaroot
102
-#
103
-# We try to have sensible defaults, so you should be able to run ``./stack.sh``
104
-# in most cases.
105
-#
106
-# We our settings from ``stackrc``.  This file is distributed with devstack and
107
-# contains locations for what repositories to use.  If you want to use other 
108
-# repositories and branches, you can add your own settings with another file 
109
-# called ``localrc``
110
-#
111
-# If ``localrc`` exists, then ``stackrc`` will load those settings.  This is 
112
-# useful for changing a branch or repostiory to test other versions.  Also you
113
-# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead
114
-# of letting devstack generate random ones for you.
115
-source ./stackrc
116
-
117
-# Destination path for installation ``DEST``
118
-DEST=${DEST:-/opt/stack}
119
-
120 86
 # Set the destination directories for openstack projects
121 87
 NOVA_DIR=$DEST/nova
122 88
 DASH_DIR=$DEST/dash
... ...
@@ -18,6 +18,9 @@ CWD=`pwd`
18 18
 
19 19
 DEST=${DEST:-/opt/stack}
20 20
 
21
+# Param string to pass to stack.sh.  Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
22
+STACKSH_PARAMS=${STACKSH_PARAMS:-}
23
+
21 24
 # Option to use the version of devstack on which we are currently working
22 25
 USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
23 26
 
... ...
@@ -42,7 +45,7 @@ if [ ! -d $CHROOTCACHE/natty-dev ]; then
42 42
     chroot $CHROOTCACHE/natty-dev groupadd libvirtd
43 43
     chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
44 44
     mkdir -p $CHROOTCACHE/natty-dev/$DEST
45
-    chown stack $CHROOTCACHE/natty-dev/$DEST
45
+    chroot $CHROOTCACHE/natty-dev chown stack $DEST
46 46
 
47 47
     # a simple password - pass
48 48
     echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
... ...
@@ -112,6 +115,34 @@ auto eth0
112 112
 iface eth0 inet dhcp
113 113
 EOF
114 114
 
115
+# Set hostname
116
+echo "ramstack" >$CHROOTCACHE/natty-stack/etc/hostname
117
+echo "127.0.0.1		localhost	ramstack" >$CHROOTCACHE/natty-stack/etc/hosts
118
+
119
+# Configure the runner
120
+RUN_SH=$CHROOTCACHE/natty-stack/$DEST/run.sh
121
+cat > $RUN_SH <<EOF
122
+#!/usr/bin/env bash
123
+
124
+# Get IP range
125
+set \`ip addr show dev eth0 | grep inet\`
126
+PREFIX=\`echo \$2 | cut -d. -f1,2,3\`
127
+export FLOATING_RANGE="\$PREFIX.224/27"
128
+
129
+# Kill any existing screens
130
+killall screen
131
+
132
+# Run stack.sh
133
+cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log
134
+echo >> $DEST/run.sh.log
135
+echo >> $DEST/run.sh.log
136
+echo "All done! Time to start clicking." >> $DEST/run.sh.log
137
+EOF
138
+
139
+# Make the run.sh executable
140
+chmod 755 $RUN_SH
141
+chroot $CHROOTCACHE/natty-stack chown stack $DEST/run.sh
142
+
115 143
 # build a new image
116 144
 BASE=$CHROOTCACHE/build.$$
117 145
 IMG=$BASE.img