diff options
Diffstat (limited to 'bitbake/bin/toaster')
-rwxr-xr-x | bitbake/bin/toaster | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 34f65e4721..4c6ac5ac40 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster | |||
@@ -37,7 +37,7 @@ function webserverKillAll() | |||
37 | kill -SIGTERM -$(< ${pidfile}) 2>/dev/null | 37 | kill -SIGTERM -$(< ${pidfile}) 2>/dev/null |
38 | sleep 1; | 38 | sleep 1; |
39 | # Kill processes if they are still running - may happen in interactive shells | 39 | # Kill processes if they are still running - may happen in interactive shells |
40 | ps fux | grep "python.*manage.py" | awk '{print $2}' | xargs kill | 40 | ps fux | grep "python.*manage.py runserver" | awk '{print $2}' | xargs kill |
41 | done; | 41 | done; |
42 | rm ${pidfile} | 42 | rm ${pidfile} |
43 | fi | 43 | fi |
@@ -69,13 +69,13 @@ function webserverStartAll() | |||
69 | fi | 69 | fi |
70 | if [ $retval -eq 0 ]; then | 70 | if [ $retval -eq 0 ]; then |
71 | echo "Starting webserver" | 71 | echo "Starting webserver" |
72 | python $BBBASEDIR/lib/toaster/manage.py runserver 0.0.0.0:8000 </dev/null >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid | 72 | python $BBBASEDIR/lib/toaster/manage.py runserver "0.0.0.0:$WEB_PORT" </dev/null >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid |
73 | sleep 1 | 73 | sleep 1 |
74 | if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then | 74 | if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then |
75 | retval=1 | 75 | retval=1 |
76 | rm "${BUILDDIR}/.toastermain.pid" | 76 | rm "${BUILDDIR}/.toastermain.pid" |
77 | else | 77 | else |
78 | echo "Webserver address: 0.0.0.0:8000" | 78 | echo "Webserver address: http://0.0.0.0:$WEB_PORT/" |
79 | fi | 79 | fi |
80 | fi | 80 | fi |
81 | return $retval | 81 | return $retval |
@@ -103,7 +103,7 @@ function stop_system() | |||
103 | kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null | 103 | kill $(< ${BUILDDIR}/.toasterui.pid ) 2>/dev/null |
104 | rm ${BUILDDIR}/.toasterui.pid | 104 | rm ${BUILDDIR}/.toasterui.pid |
105 | fi | 105 | fi |
106 | BBSERVER=0.0.0.0:8200 bitbake -m | 106 | BBSERVER=0.0.0.0:-1 bitbake -m |
107 | unset BBSERVER | 107 | unset BBSERVER |
108 | webserverKillAll | 108 | webserverKillAll |
109 | # force stop any misbehaving bitbake server | 109 | # force stop any misbehaving bitbake server |
@@ -126,9 +126,46 @@ function notify_chldexit() { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | |||
130 | # Verify prerequisites | ||
131 | |||
132 | if ! echo "import django; print (1,) == django.VERSION[0:1] and django.VERSION[1:2][0] in (5,6)" | python 2>/dev/null | grep True >/dev/null; then | ||
133 | echo -e "This program needs Django 1.5 or 1.6. Please install with\n\npip install django==1.6" | ||
134 | return 2 | ||
135 | fi | ||
136 | |||
137 | if ! echo "import south; print [0,8,4] == map(int,south.__version__.split(\".\"))" | python 2>/dev/null | grep True >/dev/null; then | ||
138 | echo -e "This program needs South 0.8.4. Please install with\n\npip install south==0.8.4" | ||
139 | return 2 | ||
140 | fi | ||
141 | |||
142 | # read command line parameters | ||
143 | |||
129 | BBBASEDIR=`dirname ${BASH_SOURCE}`/.. | 144 | BBBASEDIR=`dirname ${BASH_SOURCE}`/.. |
130 | RUNNING=0 | 145 | RUNNING=0 |
131 | 146 | ||
147 | NOTOASTERUI=0 | ||
148 | WEBSERVER=1 | ||
149 | TOASTER_BRBE="" | ||
150 | WEB_PORT="8000" | ||
151 | |||
152 | for param in $*; do | ||
153 | case $param in | ||
154 | noui ) | ||
155 | NOTOASTERUI=1 | ||
156 | ;; | ||
157 | noweb ) | ||
158 | WEBSERVER=0 | ||
159 | ;; | ||
160 | brbe=* ) | ||
161 | TOASTER_BRBE=$'\n'"TOASTER_BRBE=\""${param#*=}"\"" | ||
162 | ;; | ||
163 | webport=*) | ||
164 | WEB_PORT="${param#*=}" | ||
165 | esac | ||
166 | done | ||
167 | |||
168 | |||
132 | if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then | 169 | if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; then |
133 | # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that. | 170 | # We are called as standalone. We refuse to run in a build environment - we need the interactive mode for that. |
134 | # Start just the web server, point the web browser to the interface, and start any Django services. | 171 | # Start just the web server, point the web browser to the interface, and start any Django services. |
@@ -152,7 +189,7 @@ if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; th | |||
152 | echo "Failed to start the web server, stopping" 1>&2; | 189 | echo "Failed to start the web server, stopping" 1>&2; |
153 | exit 1; | 190 | exit 1; |
154 | fi | 191 | fi |
155 | xdg-open http://0.0.0.0:8000/ >/dev/null 2>&1 & | 192 | xdg-open http://0.0.0.0:$WEB_PORT/ >/dev/null 2>&1 & |
156 | trap trap_ctrlc SIGINT | 193 | trap trap_ctrlc SIGINT |
157 | echo "Running. Stop with Ctrl-C" | 194 | echo "Running. Stop with Ctrl-C" |
158 | while [ $RUNNING -gt 0 ]; do | 195 | while [ $RUNNING -gt 0 ]; do |
@@ -170,23 +207,6 @@ if [ -z "$BUILDDIR" ] || [ -z `which bitbake` ]; then | |||
170 | fi | 207 | fi |
171 | 208 | ||
172 | 209 | ||
173 | |||
174 | # Verify prerequisites | ||
175 | |||
176 | if ! echo "import django; print (1,) == django.VERSION[0:1] and django.VERSION[1:2][0] in (5,6)" | python 2>/dev/null | grep True >/dev/null; then | ||
177 | echo -e "This program needs Django 1.5 or 1.6. Please install with\n\npip install django==1.6" | ||
178 | return 2 | ||
179 | fi | ||
180 | |||
181 | if ! echo "import south; print [0,8,4] == map(int,south.__version__.split(\".\"))" | python 2>/dev/null | grep True >/dev/null; then | ||
182 | echo -e "This program needs South 0.8.4. Please install with\n\npip install south==0.8.4" | ||
183 | return 2 | ||
184 | fi | ||
185 | |||
186 | |||
187 | |||
188 | |||
189 | |||
190 | # Determine the action. If specified by arguments, fine, if not, toggle it | 210 | # Determine the action. If specified by arguments, fine, if not, toggle it |
191 | if [ "x$1" == "xstart" ] || [ "x$1" == "xstop" ]; then | 211 | if [ "x$1" == "xstart" ] || [ "x$1" == "xstop" ]; then |
192 | CMD="$1" | 212 | CMD="$1" |
@@ -198,22 +218,6 @@ else | |||
198 | fi; | 218 | fi; |
199 | fi | 219 | fi |
200 | 220 | ||
201 | NOTOASTERUI=0 | ||
202 | WEBSERVER=1 | ||
203 | TOASTER_BRBE="" | ||
204 | for param in $*; do | ||
205 | case $param in | ||
206 | noui ) | ||
207 | NOTOASTERUI=1 | ||
208 | ;; | ||
209 | noweb ) | ||
210 | WEBSERVER=0 | ||
211 | ;; | ||
212 | brbe=* ) | ||
213 | TOASTER_BRBE=$'\n'"TOASTER_BRBE=\""${param#*=}"\"" | ||
214 | esac | ||
215 | done | ||
216 | |||
217 | echo "The system will $CMD." | 221 | echo "The system will $CMD." |
218 | 222 | ||
219 | # Make sure it's safe to run by checking bitbake lock | 223 | # Make sure it's safe to run by checking bitbake lock |
@@ -223,12 +227,18 @@ if [ -e $BUILDDIR/bitbake.lock ]; then | |||
223 | (flock -n 200 ) 200<$BUILDDIR/bitbake.lock || lock=0 | 227 | (flock -n 200 ) 200<$BUILDDIR/bitbake.lock || lock=0 |
224 | fi | 228 | fi |
225 | 229 | ||
226 | if [ ${CMD} == "start" ] && ( [ $lock -eq 0 ] || [ -e $BUILDDIR/.toastermain.pid ] ); then | 230 | if [ ${CMD} == "start" ] && [ $lock -eq 0 ]; then |
227 | echo "Error: bitbake lock state error. File locks show that the system is on." 2>&1 | 231 | echo "Error: bitbake lock state error. File locks show that the system is on." 1>&2 |
228 | echo "If you see problems, stop and then start the system again." 2>&1 | 232 | echo "Please wait for the current build to finish, stop and then start the system again." 1>&2 |
229 | return 3 | 233 | return 3 |
230 | fi | 234 | fi |
231 | 235 | ||
236 | if [ ${CMD} == "start" ] && [ -e $BUILDDIR/.toastermain.pid ] && kill -0 `cat $BUILDDIR/.toastermain.pid`; then | ||
237 | echo "Error: bitbake appears to be dead, but the webserver is alive. Something fishy is going on." 1>&2 | ||
238 | echo "Cleaning up the web server at to start a clean slate." | ||
239 | webserverKillAll | ||
240 | fi | ||
241 | |||
232 | 242 | ||
233 | # Execute the commands | 243 | # Execute the commands |
234 | 244 | ||
@@ -241,12 +251,12 @@ case $CMD in | |||
241 | return 4 | 251 | return 4 |
242 | fi | 252 | fi |
243 | unset BBSERVER | 253 | unset BBSERVER |
244 | bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:8200 | 254 | bitbake --postread conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 |
245 | if [ $? -ne 0 ]; then | 255 | if [ $? -ne 0 ]; then |
246 | start_success=0 | 256 | start_success=0 |
247 | echo "Bitbake server start failed" | 257 | echo "Bitbake server start failed" |
248 | else | 258 | else |
249 | export BBSERVER=0.0.0.0:8200 | 259 | export BBSERVER=0.0.0.0:-1 |
250 | if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited | 260 | if [ $NOTOASTERUI == 0 ]; then # we start the TOASTERUI only if not inhibited |
251 | bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid | 261 | bitbake --observe-only -u toasterui >${BUILDDIR}/toaster_ui.log 2>&1 & echo $! >${BUILDDIR}/.toasterui.pid |
252 | fi | 262 | fi |