Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 666 lines (578 sloc) 18.632 kb
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
1 #!/usr/bin/env escript
2
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
3 %% The contents of this file are subject to the Erlang Web Public License,
4 %% Version 1.0, (the "License"); you may not use this file except in
5 %% compliance with the License. You should have received a copy of the
6 %% Erlang Web Public License along with this software. If not, it can be
7 %% retrieved via the world wide web at http://www.erlang-consulting.com/.
8 %%
9 %% Software distributed under the License is distributed on an "AS IS"
10 %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 %% the License for the specific language governing rights and limitations
12 %% under the License.
13 %%
14 %% The Initial Developer of the Original Code is Erlang Training & Consulting
15 %% Ltd. Portions created by Erlang Training & Consulting Ltd are Copyright 2009,
16 %% Erlang Training & Consulting Ltd. All Rights Reserved.
17
18 %%%-----------------------------------------------------------------------------
19 %%% File : start.erl
20 %%% @author Michal Ptaszek <michal.ptaszek@erlang.consulting.com>
21 %%% @doc A start script for the Erlang Web framework.
22 %%% @end
23 %%%-----------------------------------------------------------------------------
24
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
25 -include_lib("kernel/include/file.hrl").
26
8500eb5 Added support for embedded mode
Piotr Kaleta authored
27 main(["ewgi_inets"]) ->
28 start(ewgi_inets);
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
29 main(["yaws"]) ->
30 start(yaws);
31 main(_) ->
32 start(inets).
33
34 start(Server) ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
35 create_start_dirs(),
36 RootDir = prepare_paths(),
37
38 Info = get_info(),
39 copy_bin_files(Info),
40
41 create_start_scripts(Info),
d1e6dcd EW scripts updated to accept the correct start_erl.data file
michal.ptaszek authored
42 create_start_erl_data(Info),
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
43
44 create_basic_config_files(),
45 create_welcome_page(),
46
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
47 create_rel_file(Info, Server),
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
48
49 generate_boot_file(),
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
50 copy_conf_files(),
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
51 create_sys_config_file(Server),
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
52
53 copy_escripts(RootDir).
54
55 confirm_created(Name) ->
56 io:format("Element created: ~s~n", [Name]).
57
58 inform_exists(Name) ->
59 io:format("Element exists, skipping: ~s~n", [Name]).
60
61 handle_error(Reason) ->
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
62 io:format("An error has occured: ~p~n", [Reason]).
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
63
64 create_start_dirs() ->
65 Creator = fun(X) ->
66 case file:make_dir(X) of
67 ok -> confirm_created(X);
68 {error, eexist} -> inform_exists(X);
69 {error, Reason} -> handle_error(Reason)
70 end
71 end,
919107a bugs in start.erl
michal.ptaszek authored
72 Dirs = ["config", "docroot", "log", "pipes", "templates", "bin",
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
73 "lib", "releases", filename:join("releases", "0.1"),
74 filename:join("templates", "cache"),
75 filename:join("docroot", "conf")],
76 lists:foreach(Creator, Dirs),
77
78 {ok, Apps1} = file:list_dir("lib"),
79 Apps = lists:delete(".svn", Apps1),
80 LibDirs = lists:map(fun(X) ->
81 filename:join("lib", X)
82 end, Apps),
83 AppDirs = ["doc", "ebin", "include", "priv", "src"],
84 lists:foreach(fun(Lib) ->
85 AppDirsComplete = lists:map(fun(Name) ->
86 filename:join(Lib, Name)
87 end, AppDirs),
88 lists:foreach(Creator, AppDirsComplete)
89 end, LibDirs).
90
91 prepare_paths() ->
92 ScriptName = escript:script_name(),
93 {ok, Dir} = file:get_cwd(),
94
6ec1bb0 added first sketch of the e_components script
michal.ptaszek authored
95 Splitted0 = filename:split(ScriptName),
96 Splitted = lists:sublist(Splitted0, 1, length(Splitted0)-2),
97 RootDir = case length(Splitted) of
98 0 ->
99 Dir;
100 _ ->
919107a bugs in start.erl
michal.ptaszek authored
101 filename:join([Dir | Splitted])
6ec1bb0 added first sketch of the e_components script
michal.ptaszek authored
102 end,
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
103
104 {ok, Libs} = file:list_dir(filename:join(RootDir, "lib")),
105
106 lists:foreach(fun(Lib) ->
107 Path = filename:join([RootDir, "lib", Lib, "ebin"]),
108 code:add_path(Path)
109 end, lists:delete(".svn", Libs)),
110
111 RootDir.
112
113 get_info() ->
114 Dir = code:root_dir(),
115 Version = erlang:system_info(version),
116
117 {Version, Dir}.
118
119 copy_bin_files({Version, Path}) ->
120 Prefix = filename:join([Path, "erts-" ++ Version, "bin"]),
121 ToCopyList = ["heart", "to_erl", "run_erl"],
122 Copier = fun(X) ->
123 Source = filename:join(Prefix, X),
124 Dest = filename:join("bin", X),
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
125 case filelib:is_file(Dest) of
126 true ->
127 inform_exists(Dest);
128 false ->
129 case file:copy(Source, Dest) of
130 {ok, _} -> confirm_created(Dest);
131 {error, Reason} -> handle_error(Reason)
132 end,
133 file:write_file_info(Dest, #file_info{mode=8#00744})
134 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
135 end,
136 lists:foreach(Copier, ToCopyList).
137
138 create_script(FileName, Content) ->
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
139 case filelib:is_file(FileName) of
140 true ->
141 inform_exists(FileName);
142 false ->
143 case file:open(FileName, [write]) of
144 {ok, Fd} ->
145 io:format(Fd, Content, []),
146 file:close(Fd),
147 file:write_file_info(FileName,
148 #file_info{mode=8#00744}),
149 confirm_created(FileName);
150 {error, Reason} -> handle_error(Reason)
151 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
152 end.
153
d1e6dcd EW scripts updated to accept the correct start_erl.data file
michal.ptaszek authored
154 create_start_scripts({_, Path}) ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
155 BinStart = "#!/bin/sh\n\n"
156
157 "ROOTDIR=`pwd`\n"
158 "export TERM=xterm\n"
159 "export SHELL=/bin/bash\n"
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
160 "export HEART_COMMAND=\"$ROOTDIR/bin/start\"\n\n"
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
161
162 "echo \"Starting Erlang Web\"\n"
163 "RELDIR=$ROOTDIR/releases\n"
164 "rm -f $ROOTDIR/erlang.log.?\n"
165 "START_ERL_DATA=${1:-$RELDIR/start_erl.data}\n"
166 "$ROOTDIR/bin/run_erl -daemon pipes/ $ROOTDIR/log \"exec $ROOTDIR/bin/start_erl "
167 "$ROOTDIR $RELDIR $START_ERL_DATA\"\n",
168
169 BinStartName = filename:join("bin", "start"),
170 create_script(BinStartName, BinStart),
171
172 BinStop = "#!/bin/sh\n\n"
d1e6dcd EW scripts updated to accept the correct start_erl.data file
michal.ptaszek authored
173
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
174 "ROOTDIR=`pwd`\n"
175 "PID=$(ps ax | grep -E .*beam.*$ROOTDIR | grep -v grep | awk '{print $1}')\n\n"
176
177 "if [ $PID ]; then\n"
178 "\techo \"Stopping Erlang Web\"\n"
179 "\tHEART_PID=$(ps ax | grep heart | grep -v beam | grep $PID | awk '{print $1}')\n"
180 "\tif [ $HEART_PID ]; then\n"
181 "\t\tkill $HEART_PID\n"
182 "\telse\n"
183 "\t\tkill $PID\n"
184 "\tfi\n"
185 "else\n"
186 "\techo \"Erlang Web is not running\"\n"
187 "fi\n",
188
189 BinStopName = filename:join("bin", "stop"),
190 create_script(BinStopName, BinStop),
191
192 BinConnect = "#!/bin/sh\n\n"
193 "bin/to_erl pipes/\n",
194
195 BinConnectName = filename:join("bin", "connect"),
196 create_script(BinConnectName, BinConnect),
197
7116a6e start.erl changed to accept the new e_start.erl module
michal.ptaszek authored
198 BinStartInteractive = "#!/bin/sh\n\n"
199
80814fa Added configuration files and mochiweb directory
Piotr Kaleta authored
200 "if [ $# -eq 0 ]
201 then
202 SERVER=inets
203 NODE_TYPE=single_node
204 elif [ $# -eq 1 ]
205 then
206 case $1 in
207 yaws)
208 SERVER=yaws
209 ;;
210 ewgi_mochiweb)
211 SERVER=ewgi_mochiweb
212 ;;
213 ewgi_inets)
214 SERVER=ewgi_inets
215 ;;
216 *)
217 SERVER=inets
218 esac
219 NODE_TYPE=single_node
220 shift
221 else
222 case $1 in
223 yaws)
224 SERVER=yaws
225 ;;
226 ewgi_mochiweb)
227 SERVER=ewgi_mochiweb
228 ;;
229 ewgi_inets)
230 SERVER=ewgi_inets
231 ;;
232 *)
233 SERVER=inets
234 esac
235 case $2 in
236 frontend)
237 NODE_TYPE=frontend
238 ;;
239 backend)
240 NODE_TYPE=backend
241 ;;
242 single_node_with_cache)
243 NODE_TYPE=single_node_with_cache
244 ;;
245 *)
246 NODE_TYPE=single_node
247 esac
248 shift
249 shift
250 fi
251
252 erl -pa lib/*/ebin -s e_start start $NODE_TYPE $SERVER $@",
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
253
254 BinStartInteractiveName = filename:join("bin", "start_interactive"),
255 create_script(BinStartInteractiveName, BinStartInteractive),
256
257 FileContent2 = "#!/bin/sh\n\n"
258
259 "ROOTDIR=$1\n"
260 "RELDIR=$2\n"
261 "DataFile=$3\n\n"
262
263 "shift\nshift\nshift\n\n"
264
d1e6dcd EW scripts updated to accept the correct start_erl.data file
michal.ptaszek authored
265 "ERTS_VSN=`awk '{print $2}' $DataFile`\n"
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
266 "VSN=`awk '{print $1}' $DataFile`\n\n"
267
268 "BINDIR=" ++ Path ++ "/erts-$ERTS_VSN/bin\n"
269 "EMU=beam\n"
270 "PROGNAME=`echo $0 | sed 's/.*\\///'`\n"
271 "HOSTNAME=test\n\n"
272
273 "export EMU\n"
274 "export ROOTDIR\n"
275 "export BINDIR\n"
276 "export PROGNAME\n"
277 "export RELDIR\n\n"
278
279 "exec $BINDIR/erlexec -boot $RELDIR/$VSN/start -config $RELDIR/$VSN/sys "
280 "-heart -env HEART_BEAT_TIMEOUT 30 -pa patches +K true -sname $HOSTNAME -smp auto +P 262140 ${1+\"$@\"}\n",
281
282 FileName2 = filename:join("bin", "start_erl"),
283 create_script(FileName2, FileContent2).
284
d1e6dcd EW scripts updated to accept the correct start_erl.data file
michal.ptaszek authored
285 create_start_erl_data({Version, _}) ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
286 Filename = filename:join("releases", "start_erl.data"),
287
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
288 case filelib:is_file(Filename) of
289 true ->
290 inform_exists(Filename);
291 false ->
292 case file:open(Filename, [write]) of
293 {ok, Fd} ->
294 io:format(Fd, "0.1 ~s", [Version]),
295 file:close(Fd),
296 confirm_created(Filename);
297 {error, Reason} ->
298 handle_error(Reason)
299 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
300 end.
301
302 create_basic_config_files() ->
303 conf_dispatcher(),
304 conf_errors(),
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
305 conf_project(),
306 conf_autocomplete().
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
307
308 conf_dispatcher() ->
309 Filename = filename:join(["config", "dispatch.conf"]),
310
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
311 case filelib:is_file(Filename) of
312 true ->
313 inform_exists(Filename);
314 false ->
315 case file:open(Filename, [write]) of
316 {ok, Fd} ->
317 io:format(Fd, "%%~n"
318 "%% ENTRIES FOR THE AUTOCOMPLETE WPART~n"
319 "%%~n", []),
320
321 Entries = [{static, "^/autocomplete\.css$", enoent},
322 {static, "^/jquery\.autocomplete\.js$", enoent},
323 {static, "^/jquery\.js$", enoent},
324 {static, "^/indicator\.gif$", enoent}],
325 lists:foreach(fun(Entry) ->
326 io:format(Fd, "~p.~n", [Entry])
327 end, Entries),
328
329 io:format(Fd, "~n%%~n"
330 "%% WELCOME PAGE~n"
331 "%%~n"
332 "~p.~n", [{static, "^/?$", "welcome.html"}]),
333
334 file:close(Fd),
335 confirm_created(Filename);
336 {error, Reason} ->
337 handle_error(Reason)
338 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
339 end.
340
341 conf_errors() ->
342 Filename = filename:join(["config", "errors.conf"]),
343
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
344 case filelib:is_file(Filename) of
345 true ->
346 inform_exists(Filename);
347 false ->
348 case file:open(Filename, [write]) of
349 {ok, Fd} ->
350 io:format(Fd, "{error, 501, \"templates/501.html\"}.\n"
351 "{error, 404, \"templates/404.html\"}.\n", []),
352 file:close(Fd),
353 confirm_created(Filename),
354
355 ErrorPage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
356 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
357 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
358 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
359 "<head>\n"
360 "<title>~p Error</title>\n"
361 "</head>\n"
362 "<body>\n"
363 "<center>\n"
364 "<h1>~p Error</h1>\n"
365 "</center>\n"
366 "</body>\n"
367 "</html>",
368
369 Filename404 = filename:join("templates", "404.html"),
370 case filelib:is_file(Filename404) of
371 true ->
372 inform_exists(Filename404);
373 false ->
374 case file:open(Filename404, [write]) of
375 {ok, Fd404} ->
376 io:format(Fd404, ErrorPage, [404, 404]),
377 file:close(Fd404),
378 confirm_created(Filename404);
379 {error, Reason1} ->
380 handle_error(Reason1)
381 end
382 end,
383
384 Filename501 = filename:join(["templates", "501.html"]),
385 case filelib:is_file(Filename501) of
386 true ->
387 inform_exists(Filename501);
388 false ->
389 case file:open(Filename501, [write]) of
390 {ok, Fd501} ->
391 io:format(Fd501, ErrorPage, [501, 501]),
392 file:close(Fd501),
393 confirm_created(Filename501);
394 {error, Reason2} ->
395 handle_error(Reason2)
396 end;
397 {error, Reason} ->
398 handle_error(Reason)
399 end
400 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
401 end.
402
403 conf_project() ->
404 Filename = filename:join(["config", "project.conf"]),
405
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
406 case filelib:is_file(Filename) of
407 true ->
408 inform_exists(Filename);
409 false ->
410 case file:open(Filename, [write]) of
411 {ok, Fd} ->
412 io:format(Fd, "{http_port, 8080}.~n", []),
413 file:close(Fd),
414 confirm_created(Filename);
415 {error, Reason} ->
416 handle_error(Reason)
417 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
418 end.
419
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
420 conf_autocomplete() ->
421 Wparts = code:priv_dir(wparts),
422 lists:foreach(fun(File) ->
423 Dest = filename:join(["docroot", File]),
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
424 case filelib:is_file(Dest) of
425 true ->
426 inform_exists(Dest);
427 false ->
428 case file:copy(filename:join([Wparts, File]), Dest) of
429 {ok, _} ->
430 confirm_created(Dest);
431 {error, Reason} ->
432 handle_error({Dest, Reason})
433 end
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
434 end
435 end, ["autocomplete.css", "indicator.gif", "jquery.autocomplete.js",
436 "jquery.js"]).
437
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
438 create_welcome_page() ->
439 Filename = filename:join(["templates", "welcome.html"]),
440
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
441 case filelib:is_file(Filename) of
442 true ->
443 inform_exists(Filename);
444 false ->
445 case file:open(Filename, [write]) of
446 {ok, Fd} ->
447 Content = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
448 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
449 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
450 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n"
451
452 "<head>\n"
453 "<title>Erlang Web</title>\n"
454 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n"
455 "</head>\n"
456 "<body>\n"
457 "<h1>Welcome to the Erlang Web!</h1>\n"
458 "</body>\n"
459 "</html>\n",
460 io:format(Fd, Content, []),
461 file:close(Fd),
462 confirm_created(Filename);
463 {error, Reason} ->
464 handle_error(Reason)
465 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
466 end.
467
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
468 create_rel_file({Version, _}, Server) ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
469 Name = "start",
470 Filename = filename:join(["releases", "0.1", Name ++ ".rel"]),
471
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
472 case filelib:is_file(Filename) of
473 true ->
474 inform_exists(Filename);
475 false ->
476 case file:open(Filename, [write]) of
477 {ok, Fd} ->
478 Apps = get_apps_for_release(Server),
479 ReleaseInfo = {release, {Name, "0.1"}, {erts, Version},
480 Apps},
481
482 io:format(Fd, "~p.~n", [ReleaseInfo]),
483 file:close(Fd),
484 confirm_created(Filename);
485 {error, Reason} ->
486 handle_error(Reason)
487 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
488 end.
489
1294a1f Added support for embedded mode
Piotr Kaleta authored
490 get_apps_for_release(ewgi_inets) ->
491 ToLoad = get_apps_for_release(inets),
492 application:load(ewgi),
493 {value, {_, _, Ver}} = lists:keysearch(ewgi, 1, application:loaded_applications()),
494 [{ewgi, Ver} | ToLoad];
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
495 get_apps_for_release(Server) ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
496 {ok, Dir} = file:list_dir("lib/"),
497 [code:add_path("lib/" ++ D ++ "/ebin") || D <- Dir],
498
9a64101 Changed start.erl
Piotr Kaleta authored
499 ToLoad = [xmerl, sasl, crypto, eptic, wpart, wparts, mnesia, ssl,
0349757 EWTS corrected, Yaws 1.85 ported
Michal Ptaszek authored
500 syntax_tools, compiler, runtime_tools, Server],
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
501 [application:load(App) || App <- ToLoad],
502
503 lists:map(fun({Name, _, Vsn}) ->
504 {Name, Vsn}
505 end, application:loaded_applications()).
506
507 generate_boot_file() ->
09f2c47 start scripts are now more verbose
Michal Ptaszek authored
508 systools:make_script("start", [{path, ["releases/0.1", "lib/*/ebin"]},
509 {outdir, "releases/0.1/"}, silent]),
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
510 confirm_created("releases/0.1/start.script"),
511 confirm_created("releases/0.1/start.boot"),
512
513 file:copy("releases/0.1/start.rel", "start.rel"),
09f2c47 start scripts are now more verbose
Michal Ptaszek authored
514 systools:make_tar("start",[{path, ["releases/0.1"]}, {outdir, "releases/0.1/"},
515 {dirs, [include, src]}, silent]),
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
516 file:delete("start.rel"),
517
518 erl_tar:extract("releases/0.1/start.tar.gz", [keep_old_files, compressed]).
519
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
520 copy_conf_files() ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
521 YawsConfig = "config/yaws.conf",
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
522 case filelib:is_file(YawsConfig) of
523 true ->
524 inform_exists(YawsConfig);
525 false ->
a12f472 Start scripts updated to use yaws.conf from eptic application.
michal.ptaszek authored
526 file:copy(code:priv_dir(eptic) ++ "/yaws.conf", YawsConfig),
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
527 confirm_created(YawsConfig)
528 end,
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
529
530 MimeTypes = "docroot/conf/mime.types",
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
531 case filelib:is_file(MimeTypes) of
532 true ->
533 inform_exists(MimeTypes);
534 false ->
535 file:copy(code:priv_dir(eptic) ++ "/mime.types", MimeTypes),
536 confirm_created(MimeTypes)
537 end,
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
538
539 InetsConfig = "config/inets.conf",
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
540 case filelib:is_file(InetsConfig) of
541 true ->
542 inform_exists(InetsConfig);
543 false ->
544 file:copy(code:priv_dir(eptic) ++ "/inets.conf", InetsConfig),
545 confirm_created(InetsConfig)
ab3f564 last changes before 1.3rc1
michal.ptaszek authored
546 end,
80814fa Added configuration files and mochiweb directory
Piotr Kaleta authored
547
548 InetsHttpsConfig = "config/inets_https.conf",
549 case filelib:is_file(InetsHttpsConfig) of
550 true ->
551 inform_exists(InetsHttpsConfig);
552 false ->
553 file:copy(code:priv_dir(eptic) ++ "/inets_https.conf", InetsHttpsConfig),
554 confirm_created(InetsHttpsConfig)
555 end,
556
557 EwgiInetsConfig = "config/ewgi_inets.conf",
558 case filelib:is_file(EwgiInetsConfig) of
559 true ->
560 inform_exists(EwgiInetsConfig);
561 false ->
562 file:copy(code:priv_dir(eptic) ++ "/ewgi_inets.conf", EwgiInetsConfig),
563 confirm_created(EwgiInetsConfig)
564 end,
565
566 EwgiInetsHttpsConfig = "config/ewgi_inets_https.conf",
567 case filelib:is_file(EwgiInetsHttpsConfig) of
568 true ->
569 inform_exists(EwgiInetsHttpsConfig);
570 false ->
571 file:copy(code:priv_dir(eptic) ++ "/ewgi_inets_https.conf", EwgiInetsHttpsConfig),
572 confirm_created(EwgiInetsHttpsConfig)
573 end,
ab3f564 last changes before 1.3rc1
michal.ptaszek authored
574
575 ErrorsConfig = "config/errors_description.conf",
576 case filelib:is_file(ErrorsConfig) of
577 true ->
578 inform_exists(ErrorsConfig);
579 false ->
580 file:copy(code:priv_dir(eptic) ++ "/errors.conf", ErrorsConfig),
581 confirm_created(ErrorsConfig)
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
582 end.
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
583
584 create_sys_config_file(yaws) ->
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
585 Filename = "releases/0.1/sys.config",
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
586 case filelib:is_file(Filename) of
587 true ->
588 inform_exists(Filename);
589 false ->
590 case file:open(Filename, [write]) of
591 {ok, Fd} ->
592 Content = [{yaws, [{conf, "config/yaws.conf"}]}],
593 io:format(Fd, "~p.~n", [Content]),
594 confirm_created(Filename),
595 file:close(Fd);
596 {error, Reason} ->
597 handle_error(Reason)
598 end
114c741 closes #180 - inets as a default embedded web server, some start.erl bug...
michal.ptaszek authored
599 end;
600 create_sys_config_file(inets) ->
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
601 Filename = "releases/0.1/sys.config",
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
602 case filelib:is_file(Filename) of
603 true ->
604 inform_exists(Filename);
605 false ->
606 case file:open(Filename, [write]) of
607 {ok, Fd} ->
608 Content = [{inets, [{services, [{httpd, "config/inets.conf"}]}]}],
609 io:format(Fd, "~p.~n", [Content]),
610 confirm_created(Filename),
611 file:close(Fd);
612 {error, Reason} ->
613 handle_error(Reason)
614 end
8500eb5 Added support for embedded mode
Piotr Kaleta authored
615 end;
616 create_sys_config_file(ewgi_inets) ->
617 Filename = "releases/0.1/sys.config",
618 case filelib:is_file(Filename) of
619 true ->
620 inform_exists(Filename);
621 false ->
622 case file:open(Filename, [write]) of
623 {ok, Fd} ->
624 Content = [{inets, [{services, [{httpd, "config/ewgi_inets.conf"}]}]},
625 {ewgi, [{app_module, e_mod_ewgi}, {app_function, do}]}],
626 io:format(Fd, "~p.~n", [Content]),
627 confirm_created(Filename),
628 file:close(Fd);
629 {error, Reason} ->
630 handle_error(Reason)
631 end
4141c6e created new branches for eptic and erlangweb (1.3)
michal.ptaszek authored
632 end.
633
634 copy_escripts(RootDir) ->
6ec1bb0 added first sketch of the e_components script
michal.ptaszek authored
635 case file:get_cwd() of
636 {ok, RootDir} ->
637 ok;
638 {ok, _} ->
639 Files = [filename:join(["bin", "compile.erl"]),
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
640 filename:join(["bin", "add.erl"]),
130de89 e_dict supports unlimited deep structures
Michal Ptaszek authored
641 filename:join(["bin", "generate.erl"]),
642 filename:join(["bin", "test.erl"]),
130442b merged erlangweb-1.2.1 to 1.3
michal.ptaszek authored
643 filename:join(["bin", "e_component.erl"])],
6ec1bb0 added first sketch of the e_components script
michal.ptaszek authored
644
ca4f781 corrected single_node_with_cache multipart cleanup, start.erl does not e...
michal.ptaszek authored
645 case filelib:is_file("Emakefile") of
646 true ->
647 inform_exists("Emakefile");
648 false ->
649 file:copy(filename:join(RootDir, "Emakefile"), "Emakefile"),
650 confirm_created("Emakefile")
651 end,
6ec1bb0 added first sketch of the e_components script
michal.ptaszek authored
652
653 lists:foreach(fun(File) ->
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
654 case filelib:is_file(File) of
655 true ->
656 inform_exists(File);
657 false ->
658 file:copy(filename:join([RootDir, File]), File),
659 file:write_file_info(File,
660 #file_info{mode=8#00744}),
661 confirm_created(File)
662 end
6ec1bb0 added first sketch of the e_components script
michal.ptaszek authored
663 end, Files)
664 end.
df13cc6 start.erl script does not override existing files anymore
michal.ptaszek authored
665
Something went wrong with that request. Please try again.