| |
| /pliant/fullpliant/run.pli |
| |
| 1 |
abstract | |
| 2 |
[This is the script that will start the FullPLiant operating system services.] | |
| 3 |
| |
| 4 |
module "/pliant/language/context.pli" | |
| 5 |
module "/pliant/language/compiler.pli" | |
| 6 |
module "/pliant/language/stream.pli" | |
| 7 |
module "/pliant/admin/file.pli" | |
| 8 |
module "/pliant/fullpliant/this_computer.pli" | |
| 9 |
module "/pliant/fullpliant/user.pli" | |
| 10 |
| |
| 11 |
pliant_compiler_semaphore request | |
| 12 |
| |
| 13 |
function log | |
| 14 |
(var Stream log) open "file:/log/pliant.log" append+safe | |
| 15 |
log writeline "run "+string:datetime | |
| 16 |
(var Stream err) open "file:/tmp/console" in+safe | |
| 17 |
while not err:atend | |
| 18 |
log writeline " "+err:readline | |
| 19 |
err close ; log close | |
| 20 |
file_delete"file:/tmp/console" | |
| 21 |
log | |
| 22 |
| |
| 23 |
if (constant this_computer:env:"kernel":"make":"CONFIG_ISDN"="y" or this_computer:env:"kernel":"make":"CONFIG_ISDN"="m") | |
| 24 |
module "/pliant/linux/network/isdn.pli" | |
| 25 |
| |
| 26 |
function clean_tmp_directory | |
| 27 |
var Array:FileInfo files := file_list "file:/tmp/" standard | |
| 28 |
for (var Int i) 0 files:size-1 | |
| 29 |
if (files:i:name_without_path parse "pliant_" any) | |
| 30 |
if files:i:is_directory | |
| 31 |
file_tree_delete files:i:name | |
| 32 |
else | |
| 33 |
file_delete files:i:name | |
| 34 |
clean_tmp_directory | |
| 35 |
| |
| 36 |
gvar Str precompile := "" | |
| 37 |
| |
| 38 |
if (constant this_computer:env:"pliant":"dns":"service"="true") | |
| 39 |
constant (compile_message "Compiling DNS server. Please wait ...") | |
| 40 |
precompile += "/pliant/protocol/dns/server.pli[lf]" | |
| 41 |
module "/pliant/protocol/dns/server.pli" | |
| 42 |
compile_message "" | |
| 43 |
dns_server cache this_computer:env:"pliant":"dns":"cache" default this_computer:env:"pliant":"dns":"default" detached | |
| 44 |
| |
| 45 |
if (constant (file_query "security:/dhcp.conf" standard)=defined) | |
| 46 |
module "/pliant/linux/network/dhcp.pli" | |
| 47 |
dhcp_server | |
| 48 |
| |
| 49 |
if (constant this_computer:env:"pliant":"mail":"smtp_service"="true") | |
| 50 |
constant (compile_message "Compiling SMTP server. Please wait ...") | |
| 51 |
precompile += "/pliant/protocol/smtp/server.pli[lf]" | |
| 52 |
module "/pliant/protocol/smtp/server.pli" | |
| 53 |
compile_message "" | |
| 54 |
smtp_server detached | |
| 55 |
| |
| 56 |
if (constant this_computer:env:"pliant":"mail":"pop3_service"="true") | |
| 57 |
constant (compile_message "Compiling POP3 server. Please wait ...") | |
| 58 |
precompile += "/pliant/protocol/pop3/server.pli[lf]" | |
| 59 |
module "/pliant/protocol/pop3/server.pli" | |
| 60 |
compile_message "" | |
| 61 |
pop3_server detached | |
| 62 |
| |
| 63 |
if (constant this_computer:env:"pliant":"mail":"redirect_service"="true") | |
| 64 |
constant (compile_message "Compiling mail redirection daemon. Please wait ...") | |
| 65 |
precompile += "/pliant/protocol/smtp/redirect.pli[lf]" | |
| 66 |
module "/pliant/protocol/smtp/redirect.pli" | |
| 67 |
compile_message "" | |
| 68 |
redirect_mails | |
| 69 |
console "Mailboxes redirection daemon is running." eol | |
| 70 |
| |
| 71 |
if (constant this_computer:env:"pliant":"ftp":"service"="true") | |
| 72 |
constant (compile_message "Compiling FTP server. Please wait ...") | |
| 73 |
precompile += "/pliant/protocol/ftp/server.pli[lf]" | |
| 74 |
module "/pliant/protocol/ftp/server.pli" | |
| 75 |
compile_message "" | |
| 76 |
ftp_server detached | |
| 77 |
| |
| 78 |
if (constant this_computer:env:"pliant":"remote":"service"="true") | |
| 79 |
constant (compile_message "Compiling remote execution server. Please wait ...") | |
| 80 |
precompile += "/pliant/util/remote/server.pli[lf]" | |
| 81 |
module "/pliant/util/remote/server.pli" | |
| 82 |
compile_message "" | |
| 83 |
remote_server detached | |
| 84 |
| |
| 85 |
if (constant this_computer:env:"pliant":"cluster":"service"="true") | |
| 86 |
constant (compile_message "Compiling clustering server. Please wait ...") | |
| 87 |
precompile += "/pliant/appli/cluster/server.pli[lf]" | |
| 88 |
module "/pliant/appli/cluster/server.pli" | |
| 89 |
compile_message "" | |
| 90 |
cluster_server detached | |
| 91 |
if (constant this_computer:env:"pliant":"cluster":"daemon"="true") | |
| 92 |
constant (compile_message "Compiling clustering daemon. Please wait ...") | |
| 93 |
precompile += "/pliant/appli/cluster/daemon.pli[lf]" | |
| 94 |
module "/pliant/appli/cluster/daemon.pli" | |
| 95 |
compile_message "" | |
| 96 |
cluster_daemon | |
| 97 |
| |
| 98 |
if (constant this_computer:env:"pliant":"lpr":"service"="true") | |
| 99 |
constant (compile_message "Compiling LPR server. Please wait ...") | |
| 100 |
precompile += "/pliant/protocol/lpr/server.pli[lf]" | |
| 101 |
module "/pliant/protocol/lpr/server.pli" | |
| 102 |
compile_message "" | |
| 103 |
lpr_server detached | |
| 104 |
eif (constant this_computer:env:"printer":size>0) | |
| 105 |
constant (compile_message "Compiling print spooler. Please wait ...") | |
| 106 |
precompile += "/pliant/protocol/lpr/spool.pli[lf]" | |
| 107 |
module "/pliant/protocol/lpr/spool.pli" | |
| 108 |
compile_message "" | |
| 109 |
lpr_spool | |
| 110 |
console "Print spooler is running." eol | |
| 111 |
| |
| 112 |
if (constant this_computer:env:"pliant":"ui":"service"="true") or (constant this_computer:env:"pliant":"ui":"http_proxy"="true") or (constant this_computer:env:"pliant":"ui":"console"="true") | |
| 113 |
constant (compile_message "Compiling Pliant ui server. Please wait ...") | |
| 114 |
precompile += "/pliant/graphic/ui/server/main.pli[lf]" | |
| 115 |
module "/pliant/graphic/ui/server/main.pli" | |
| 116 |
constant (compile_message "Compiling ui applets. Please wait ...") | |
| 117 |
module "/pliant/graphic/ui/sample/run.pli" # FIXME | |
| 118 |
compile_message "" | |
| 119 |
ui_server | |
| 120 |
console "Pliant ui server is running." eol | |
| 121 |
if (constant this_computer:env:"pliant":"multiplexer":"service"="true") or (constant this_computer:env:"pliant":"ui":"service"="true") or (constant this_computer:env:"pliant":"ui":"http_proxy"="true") or (constant this_computer:env:"pliant":"ui":"console"="true") | |
| 122 |
constant (compile_message "Compiling Pliant TCP port multiplexer. Please wait ...") | |
| 123 |
precompile += "/pliant/util/pml/multiplexer.pli[lf]" | |
| 124 |
module "/pliant/util/pml/multiplexer.pli" | |
| 125 |
compile_message "" | |
| 126 |
gvar Int mx_port := multiplexer_server | |
| 127 |
if mx_port<>undefined | |
| 128 |
console "Pliant multiplexer is running on TCP port " mx_port eol | |
| 129 |
if (constant this_computer:env:"pliant":"ui":"console"="true") | |
| 130 |
constant (compile_message "Compiling Pliant ui client. Please wait ...") | |
| 131 |
precompile += "/pliant/graphic/ui/client/main.pli[lf]" | |
| 132 |
module "/pliant/graphic/ui/client/main.pli" | |
| 133 |
module "/pliant/language/stream/loopback.pli" | |
| 134 |
multiplexer_port "loopback:/server/ui" "loopback:/client/ui" | |
| 135 |
compile_message "" | |
| 136 |
function run_ui | |
| 137 |
thread | |
| 138 |
console "Pliant ui console is running." eol | |
| 139 |
var ExtendedStatus status := ui_client "console [dq]framebuffer[dq] terminal 2 url [dq]loopback:/[dq] windows_manager [dq]loopback:/windows_manager[dq]" | |
| 140 |
if status=failure | |
| 141 |
console "No. in facts, the ui returned error: " status:message eol | |
| 142 |
run_ui | |
| 143 |
| |
| 144 |
if (constant os_api="linux" and (exists this_computer:env:"logical")) | |
| 145 |
constant (compile_message "Compiling logical computers support. Please wait ...") | |
| 146 |
precompile += "/pliant/fullpliant/logical.pli[lf]" | |
| 147 |
module "/pliant/fullpliant/logical.pli" | |
| 148 |
compile_message "" | |
| 149 |
| |
| 150 |
if (constant this_computer:env:"pliant":"system":"medium"="cdrom") | |
| 151 |
module "recover.pli" | |
| 152 |
| |
| 153 |
if (constant this_computer:env:"pliant":"system":"distribution"<>"fullpliant") | |
| 154 |
module "/pliant/install/install.pli" | |
| 155 |
| |
| 156 |
if (constant this_computer:env:"pliant":"ui":"http_proxy"="true") | |
| 157 |
compile_message "Compiling HTTP proxy server. Please wait ..." | |
| 158 |
module "/pliant/graphic/console/http_proxy.pli" | |
| 159 |
compile_message "" | |
| 160 |
else | |
| 161 |
compile_message "Compiling HTTP server. Please wait ..." | |
| 162 |
precompile += "/pliant/protocol/http/server.pli[lf]" | |
| 163 |
precompile += "/pliant/protocol/http/style/default.style[lf]" | |
| 164 |
module "/pliant/protocol/http/server.pli" | |
| 165 |
compile_message "" | |
| 166 |
| |
| 167 |
compile_message "Compiling and running custom code. Please wait ..." | |
| 168 |
function run_custom | |
| 169 |
safe | |
| 170 |
plugin run | |
| 171 |
failure err | |
| 172 |
(var Stream log) open "file:/tmp/run.log" out+safe | |
| 173 |
log writeline err | |
| 174 |
run_custom | |
| 175 |
compile_message "" | |
| 176 |
| |
| 177 |
compile_message "Starting logging services. Please wait ..." | |
| 178 |
precompile += "/pliant/language/debug/log_database.pli[lf]" | |
| 179 |
module "/pliant/language/debug/log_database.pli" | |
| 180 |
if (constant log_database:data:file:size>0) | |
| 181 |
precompile += "/pliant/language/debug/trace.pli[lf]" | |
| 182 |
precompile += "/pliant/language/debug/log.pli[lf]" | |
| 183 |
module "/pliant/language/debug/trace.pli" | |
| 184 |
module "/pliant/language/debug/log.pli" | |
| 185 |
function run_log | |
| 186 |
each f log_database:data:file | |
| 187 |
trace_log keyof:f f:file f:mini_mb*2n^20 f:maxi_mb*2n^20 | |
| 188 |
trace_memory := log_database:data:memory | |
| 189 |
run_log | |
| 190 |
compile_message "" | |
| 191 |
| |
| 192 |
if (constant this_computer:env:"hardware":"video":"x11"="vnc") | |
| 193 |
module "/pliant/protocol/vnc/client.pli" | |
| 194 |
function run_vnc | |
| 195 |
thread | |
| 196 |
vnc_client "127.0.0.1" "" | |
| 197 |
run_vnc | |
| 198 |
if (constant this_computer:env:"pliant":"system":"medium"="cdrom") | |
| 199 |
function run_recover | |
| 200 |
thread | |
| 201 |
sleep 15 | |
| 202 |
recover_menu | |
| 203 |
run_recover | |
| 204 |
if (constant this_computer:env:"pliant":"language":"load"<>"") | |
| 205 |
function run_load | |
| 206 |
thread | |
| 207 |
sleep 120 | |
| 208 |
safe | |
| 209 |
plugin load | |
| 210 |
var Str all := this_computer:env:"pliant":"language":"load" | |
| 211 |
while all<>"" | |
| 212 |
if not (all parse any:(var Str first) "[lf]" any:(var Str remain)) | |
| 213 |
first := all ; remain := "" | |
| 214 |
if first<>"" | |
| 215 |
pliant_compiler_semaphore request | |
| 216 |
console " loading " first eol | |
| 217 |
# var DateTime start := datetime | |
| 218 |
pliant_load_module first the_module:"/pliant/language/basic/safe.pli" 0 (null map Module) | |
| 219 |
# console " done in " (string datetime:seconds-start:seconds "fixed 0") " second(s)" eol | |
| 220 |
pliant_compiler_semaphore release | |
| 221 |
all := remain | |
| 222 |
failure err | |
| 223 |
(var Stream log) open "file:/tmp/load.log" out+safe | |
| 224 |
log writeline err | |
| 225 |
run_load | |
| 226 |
| |
| 227 |
if (constant this_computer:env:"pliant":"system":"distribution"="fullpliant") | |
| 228 |
if (constant (file_query "file:/boot/boot.flag" standard)=success) | |
| 229 |
file_delete "file:/boot/boot.flag" | |
| 230 |
if (constant this_computer:env:"pliant":"system":"embedded"<>"" and this_computer:env:"hardware":"video":"x11"<>"none") | |
| 231 |
module "embedded/command.pli" | |
| 232 |
function run_embedded | |
| 233 |
thread | |
| 234 |
sleep 2 | |
| 235 |
embedded_command "xsetroot -solid #407060" "" | |
| 236 |
embedded_command "mozilla" "user [dq]me[dq] detached" | |
| 237 |
# embedded_command "/usr/lib/mozilla/mozilla-bin" "user [dq]me[dq] detached" | |
| 238 |
run_embedded | |
| 239 |
eif os_api="win32" | |
| 240 |
function os_ShellExecute hwnd op file params dir bshow | |
| 241 |
arg Int hwnd ; arg CStr op file params dir ; arg Int bshow | |
| 242 |
external "shell32.dll" "ShellExecuteA" | |
| 243 |
gvar Str login := "" | |
| 244 |
if (exists user_database:data:user:"pliant") and user_secret_database:data:password<>"" | |
| 245 |
login := "pliant:"+user_secret_database:data:password+"@" | |
| 246 |
gvar Str url := "http://"+login+"localhost"+(shunt this_computer:env:"pliant":"http":"port"="80" "" ":"+this_computer:env:"pliant":"http":"port")+"/" | |
| 247 |
function run_web_browser | |
| 248 |
thread | |
| 249 |
sleep 2 | |
| 250 |
os_ShellExecute 0 "open" url "" "c:\" 1 | |
| 251 |
run_web_browser | |
| 252 |
| |
| 253 |
if (constant this_computer:env:"pliant":"http":"autoload"<>"no") and (constant this_computer:env:"pliant":"ui":"http_proxy"<>"true") | |
| 254 |
function run_autoload | |
| 255 |
thread | |
| 256 |
sleep 5 | |
| 257 |
pliant_compiler_semaphore request | |
| 258 |
http_precompile "/pliant/protocol/http/default.page" | |
| 259 |
http_precompile "/pliant/browse/virtual_tree.page" | |
| 260 |
pliant_compiler_semaphore release | |
| 261 |
run_autoload | |
| 262 |
| |
| 263 |
if this_computer:env:"pliant":"language":"recommended"<>precompile | |
| 264 |
this_computer "pliant" "language" "recommended" := precompile | |
| 265 |
| |
| 266 |
function run_http | |
| 267 |
pliant_compiler_semaphore release | |
| 268 |
if not (this_computer:env:"pliant":"http":"port" parse (var Int port)) | |
| 269 |
port := 80 | |
| 270 |
if (constant this_computer:env:"pliant":"ui":"http_proxy"="true") | |
| 271 |
if (constant this_computer:env:"pliant":"ui":"console"<>"true") | |
| 272 |
module "/pliant/language/stream/loopback.pli" | |
| 273 |
multiplexer_port "loopback:/server/ui" "loopback:/client/ui" | |
| 274 |
sleep 0.1 | |
| 275 |
console_http_proxy port port protocol "loopback" | |
| 276 |
eif (constant this_computer:env:"pliant":"system":"distribution"="fullpliant") | |
| 277 |
http_server port port secured log this_computer:env:"pliant":"http":"log" | |
| 278 |
eif os_api="win32" | |
| 279 |
http_server port port secured log this_computer:env:"pliant":"http":"log" welcome_message "HTTP server is running.[lf][lf]Pliant URL is "+url | |
| 280 |
else | |
| 281 |
http_server port port secured log this_computer:env:"pliant":"http":"log" welcome_message "HTTP server is running.[lf][lf]Using your favorite browser, connect to the server via the URL[lf]http://localhost"+(shunt this_computer:env:"pliant":"http":"port"="80" "" ":"+this_computer:env:"pliant":"http":"port")+"/" | |
| 282 |
run_http | |
| |