Browse code

Make running as root work.

Todd Willey authored on 2011/10/28 15:34:19
Showing 1 changed files
... ...
@@ -81,6 +81,15 @@ DEST=${DEST:-/opt/stack}
81 81
 # Configure services to syslog instead of writing to individual log files
82 82
 SYSLOG=${SYSLOG:-False}
83 83
 
84
+# apt-get wrapper to just get arguments set correctly
85
+function apt_get() {
86
+    local sudo="sudo"
87
+    [ "$(id -u)" = "0" ] && sudo="env"
88
+    $sudo DEBIAN_FRONTEND=noninteractive apt-get \
89
+        --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
90
+}
91
+
92
+
84 93
 # OpenStack is designed to be run as a regular user (Dashboard will fail to run
85 94
 # as root, since apache refused to startup serve content from root user).  If
86 95
 # stack.sh is run as root, it automatically creates a stack user with
... ...
@@ -125,9 +134,13 @@ else
125 125
     # Natty uec images sudoers does not have a '#includedir'. add one.
126 126
     sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
127 127
         echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers
128
-    sudo cp $FILES/sudo/nova /etc/sudoers.d/stack_sh_nova
129
-    sudo sed -e "s,%USER%,$USER,g" -i /etc/sudoers.d/stack_sh_nova
130
-    sudo chmod 0440 /etc/sudoers.d/stack_sh_nova
128
+    TEMPFILE=`mktemp`
129
+    cat $FILES/sudo/nova > $TEMPFILE
130
+    sed -e "s,%USER%,$USER,g" -i $TEMPFILE
131
+    chmod 0440 $TEMPFILE
132
+    sudo chown root:root $TEMPFILE
133
+    sudo cp -p $TEMPFILE /etc/sudoers.d/stack_sh_nova
134
+    sudo rm $TEMPFILE
131 135
 fi
132 136
 
133 137
 # Set the destination directories for openstack projects
... ...
@@ -157,14 +170,6 @@ if [ ! -n "$HOST_IP" ]; then
157 157
     HOST_IP=`LC_ALL=C /sbin/ifconfig  | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
158 158
 fi
159 159
 
160
-# apt-get wrapper to just get arguments set correctly
161
-function apt_get() {
162
-    local sudo="sudo"
163
-    [ "$(id -u)" = "0" ] && sudo=""
164
-    $sudo DEBIAN_FRONTEND=noninteractive apt-get \
165
-        --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
166
-}
167
-
168 160
 # Generic helper to configure passwords
169 161
 function read_password {
170 162
     set +o xtrace