Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
18c0c552
Commit
18c0c552
authored
Jul 16, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
indentation 4 spaces
parent
8e2d5d18
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
451 additions
and
451 deletions
+451
-451
debomatic-webui/debomatic-webui.coffee
debomatic-webui/debomatic-webui.coffee
+52
-52
debomatic-webui/lib/broadcaster.coffee
debomatic-webui/lib/broadcaster.coffee
+55
-55
debomatic-webui/lib/client.coffee
debomatic-webui/lib/client.coffee
+155
-155
debomatic-webui/lib/config.coffee
debomatic-webui/lib/config.coffee
+40
-40
debomatic-webui/lib/parser.coffee
debomatic-webui/lib/parser.coffee
+18
-18
debomatic-webui/lib/tail.coffee
debomatic-webui/lib/tail.coffee
+19
-19
debomatic-webui/lib/utils.coffee
debomatic-webui/lib/utils.coffee
+104
-104
debomatic-webui/routes/index.coffee
debomatic-webui/routes/index.coffee
+8
-8
No files found.
debomatic-webui/debomatic-webui.coffee
View file @
18c0c552
...
...
@@ -18,11 +18,11 @@ server = http.createServer(app)
io
=
require
(
"socket.io"
)(
server
)
env
=
process
.
env
.
NODE_ENV
or
"development"
if
"development"
is
env
app
.
use
errorhandler
(
dumpExceptions
:
true
showStack
:
true
)
else
app
.
use
errorhandler
()
if
"production"
is
env
app
.
use
errorhandler
(
dumpExceptions
:
true
showStack
:
true
)
else
app
.
use
errorhandler
()
if
"production"
is
env
app
.
set
"views"
,
__dirname
+
"/views"
app
.
set
"view engine"
,
"ejs"
...
...
@@ -33,35 +33,35 @@ app.get "/", routes.index
app
.
get
config
.
routes
.
distribution
,
routes
.
distribution
# parefernces page
app
.
get
config
.
routes
.
preferences
,
routes
.
preferences
if
config
.
routes
.
preferences
app
.
get
config
.
routes
.
preferences
,
routes
.
preferences
if
config
.
routes
.
preferences
# commands page
app
.
get
config
.
routes
.
commands
,
routes
.
commands
if
config
.
routes
.
commands
app
.
get
config
.
routes
.
commands
,
routes
.
commands
if
config
.
routes
.
commands
# debomatic static page
if
config
.
routes
.
debomatic
app
.
all
config
.
routes
.
debomatic
+
"*"
,
(
req
,
res
,
next
)
->
app
.
all
config
.
routes
.
debomatic
+
"*"
,
(
req
,
res
,
next
)
->
# send 403 status when users want to browse the chroots:
# - unstable/unstable
# - unstable/build/*
# this prevents system crashes
base
=
config
.
routes
.
debomatic
base
+=
(
if
base
[
base
.
length
-
1
]
isnt
"/"
then
"/"
else
""
)
# append /
match
=
req
.
url
.
replace
(
base
,
""
).
split
(
"/"
)
match
.
pop
()
if
match
[
match
.
length
-
1
]
is
""
# case unstable/unstable
if
match
.
length
>=
2
and
((
match
[
0
]
is
match
[
1
])
or
(
match
[
1
]
is
"build"
and
match
.
length
>
2
))
# case unstable/build/*
res
.
status
(
403
).
send
"<h1>403 Forbidden</h1>"
else
# call next() here to move on to next middleware/router
next
()
return
# send 403 status when users want to browse the chroots:
# - unstable/unstable
# - unstable/build/*
# this prevents system crashes
base
=
config
.
routes
.
debomatic
base
+=
(
if
base
[
base
.
length
-
1
]
isnt
"/"
then
"/"
else
""
)
# append /
match
=
req
.
url
.
replace
(
base
,
""
).
split
(
"/"
)
match
.
pop
()
if
match
[
match
.
length
-
1
]
is
""
# case unstable/unstable
if
match
.
length
>=
2
and
((
match
[
0
]
is
match
[
1
])
or
(
match
[
1
]
is
"build"
and
match
.
length
>
2
))
# case unstable/build/*
res
.
status
(
403
).
send
"<h1>403 Forbidden</h1>"
else
# call next() here to move on to next middleware/router
next
()
return
app
.
use
config
.
routes
.
debomatic
,
serve_static
(
config
.
debomatic
.
path
)
app
.
use
config
.
routes
.
debomatic
,
serve_index
(
config
.
debomatic
.
path
,
view
:
"details"
icons
:
true
)
app
.
use
config
.
routes
.
debomatic
,
serve_static
(
config
.
debomatic
.
path
)
app
.
use
config
.
routes
.
debomatic
,
serve_index
(
config
.
debomatic
.
path
,
view
:
"details"
icons
:
true
)
# serve stylesheet-javascript
app
.
use
serve_static
(
__dirname
+
"/public"
)
...
...
@@ -72,32 +72,32 @@ serve_static.mime.define "application/octet-stream": ["dsc"]
# Listening
server
.
listen
config
.
port
,
config
.
host
,
null
,
(
err
)
->
# Checking nodejs with sudo:
# Find out which user used sudo through the environment variable
# and set his user id
uid
=
parseInt
(
process
.
env
.
SUDO_UID
)
if
uid
console
.
log
"Please do not run nodejs with sudo. Changing user to %d"
,
uid
process
.
setgid
uid
process
.
setuid
uid
# Checking nodejs with sudo:
# Find out which user used sudo through the environment variable
# and set his user id
uid
=
parseInt
(
process
.
env
.
SUDO_UID
)
if
uid
console
.
log
"Please do not run nodejs with sudo. Changing user to %d"
,
uid
process
.
setgid
uid
process
.
setuid
uid
# statuses
status
=
[]
broadcast
=
new
Broadcaster
(
io
.
sockets
,
status
)
io
.
sockets
.
on
"connection"
,
(
socket
)
->
client
=
new
Client
(
socket
)
client
.
start
()
client
.
send_status
status
if
status
.
length
>
0
client
.
send_status_debomatic
()
return
# statuses
status
=
[]
broadcast
=
new
Broadcaster
(
io
.
sockets
,
status
)
io
.
sockets
.
on
"connection"
,
(
socket
)
->
client
=
new
Client
(
socket
)
client
.
start
()
client
.
send_status
status
if
status
.
length
>
0
client
.
send_status_debomatic
()
return
console
.
log
"Debomatic-webui listening on %s:%d in %s mode"
,
server
.
address
().
address
,
server
.
address
().
port
,
app
.
settings
.
env
return
console
.
log
"Debomatic-webui listening on %s:%d in %s mode"
,
server
.
address
().
address
,
server
.
address
().
port
,
app
.
settings
.
env
return
server
.
on
"error"
,
(
e
)
->
if
e
.
code
is
"EADDRINUSE"
console
.
log
"Address in use %s:%d. Exit."
,
config
.
host
,
config
.
port
process
.
exit
1
else
console
.
error
e
return
if
e
.
code
is
"EADDRINUSE"
console
.
log
"Address in use %s:%d. Exit."
,
config
.
host
,
config
.
port
process
.
exit
1
else
console
.
error
e
return
debomatic-webui/lib/broadcaster.coffee
View file @
18c0c552
__watch_status_check_same_obj
=
(
obj1
,
obj2
)
->
if
obj1
.
status
is
obj2
.
status
if
obj1
.
distribution
is
obj2
.
distribution
if
obj1
.
hasOwnProperty
(
"package"
)
and
obj2
.
hasOwnProperty
(
"package"
)
return
true
if
obj1
.
package
is
obj2
.
package
return
false
return
true
false
if
obj1
.
status
is
obj2
.
status
if
obj1
.
distribution
is
obj2
.
distribution
if
obj1
.
hasOwnProperty
(
"package"
)
and
obj2
.
hasOwnProperty
(
"package"
)
return
true
if
obj1
.
package
is
obj2
.
package
return
false
return
true
false
# watcher on build_status
__watch_status
=
(
socket
,
status
)
->
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
watcher
.
on
"line"
,
(
new_content
)
->
data
=
null
try
data
=
JSON
.
parse
(
new_content
)
catch
err
utils
.
errors_handler
"Broadcaster:__watch_status:JSON.parse(new_content) - "
,
err
,
socket
return
watcher
=
new
Tail
(
config
.
debomatic
.
jsonfile
)
watcher
.
on
"line"
,
(
new_content
)
->
data
=
null
try
data
=
JSON
.
parse
(
new_content
)
catch
err
utils
.
errors_handler
"Broadcaster:__watch_status:JSON.parse(new_content) - "
,
err
,
socket
return
# looking for same status already in statuses lists
if
data
.
hasOwnProperty
(
"success"
)
i
=
0
# looking for same status already in statuses lists
if
data
.
hasOwnProperty
(
"success"
)
i
=
0
while
i
<
status
.
length
if
__watch_status_check_same_obj
(
data
,
status
[
i
])
status
.
splice
i
,
1
break
while
i
<
status
.
length
if
__watch_status_check_same_obj
(
data
,
status
[
i
])
status
.
splice
i
,
1
break
else
continue
i
++
else
continue
i
++
else
status
.
push
data
socket
.
emit
config
.
events
.
broadcast
.
status_update
,
data
return
status
.
push
data
socket
.
emit
config
.
events
.
broadcast
.
status_update
,
data
return
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
return
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
return
return
return
# watcher on new distributions
__watch_distributions
=
(
socket
)
->
fs
.
watch
config
.
debomatic
.
path
,
persistent
:
true
,
(
event
,
fileName
)
->
fs
.
watch
config
.
debomatic
.
path
,
persistent
:
true
,
(
event
,
fileName
)
->
# wait half a second to get pool subdir created
setTimeout
(
->
utils
.
send_distributions
socket
return
),
500
return
# wait half a second to get pool subdir created
setTimeout
(
->
utils
.
send_distributions
socket
return
),
500
return
return
__watch_pidfile
=
(
socket
)
->
fs
.
watchFile
config
.
debomatic
.
pidfile
,
persistent
:
false
interval
:
1007
,
(
curr
,
prev
)
->
status_debomatic
=
running
:
curr
.
ino
isnt
0
# if === 0 means pidfile does not exists
try
socket
.
emit
socket
.
emit
(
config
.
events
.
broadcast
.
status_debomatic
,
status_debomatic
)
return
__watch_pidfile
=
(
socket
)
->
fs
.
watchFile
config
.
debomatic
.
pidfile
,
persistent
:
false
interval
:
1007
,
(
curr
,
prev
)
->
status_debomatic
=
running
:
curr
.
ino
isnt
0
# if === 0 means pidfile does not exists
try
socket
.
emit
socket
.
emit
(
config
.
events
.
broadcast
.
status_debomatic
,
status_debomatic
)
return
return
return
Broadcaster
=
(
sockets
,
status
)
->
__watch_status
sockets
,
status
__watch_distributions
sockets
__watch_pidfile
sockets
{}
__watch_status
sockets
,
status
__watch_distributions
sockets
__watch_pidfile
sockets
{}
"use strict"
config
=
require
(
"./config"
)
fs
=
require
(
"fs"
)
...
...
debomatic-webui/lib/client.coffee
View file @
18c0c552
__get_files_list_from_package
=
(
data
,
callback
)
->
package_path
=
utils
.
get_package_path
(
data
)
utils
.
get_files_list
package_path
,
false
,
(
files
)
->
data
.
package
.
files
=
[]
data
.
package
.
debs
=
[]
data
.
package
.
sources
=
[]
files
.
forEach
(
f
)
->
file
=
{}
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
file
.
orig_name
=
f
file
.
name
=
f
.
split
(
"_"
)[
0
]
file
.
extension
=
f
.
split
(
"."
).
pop
()
return
if
config
.
debomatic
.
excluded_files
.
indexOf
(
file
.
extension
)
>=
0
if
file
.
extension
is
"deb"
or
file
.
extension
is
"ddeb"
or
file
.
extension
is
"udeb"
data
.
package
.
debs
.
push
file
else
if
f
.
indexOf
(
".tar"
)
>=
0
or
file
.
extension
is
"changes"
or
file
.
extension
is
"dsc"
file
.
name
=
f
.
replace
(
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
,
""
)
if
file
.
extension
is
"changes"
file
.
name
=
file
.
extension
else
file
.
name
=
"orig."
+
f
.
split
(
".orig."
).
pop
()
if
f
.
indexOf
(
".tar"
)
>=
0
and
f
.
indexOf
(
".orig."
)
>
0
data
.
package
.
sources
.
push
file
else
file
.
name
=
file
.
extension
data
.
package
.
files
.
push
file
return
callback
data
return
package_path
=
utils
.
get_package_path
(
data
)
utils
.
get_files_list
package_path
,
false
,
(
files
)
->
data
.
package
.
files
=
[]
data
.
package
.
debs
=
[]
data
.
package
.
sources
=
[]
files
.
forEach
(
f
)
->
file
=
{}
file
.
path
=
path
.
join
(
package_path
,
f
).
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
file
.
orig_name
=
f
file
.
name
=
f
.
split
(
"_"
)[
0
]
file
.
extension
=
f
.
split
(
"."
).
pop
()
return
if
config
.
debomatic
.
excluded_files
.
indexOf
(
file
.
extension
)
>=
0
if
file
.
extension
is
"deb"
or
file
.
extension
is
"ddeb"
or
file
.
extension
is
"udeb"
data
.
package
.
debs
.
push
file
else
if
f
.
indexOf
(
".tar"
)
>=
0
or
file
.
extension
is
"changes"
or
file
.
extension
is
"dsc"
file
.
name
=
f
.
replace
(
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
,
""
)
if
file
.
extension
is
"changes"
file
.
name
=
file
.
extension
else
file
.
name
=
"orig."
+
f
.
split
(
".orig."
).
pop
()
if
f
.
indexOf
(
".tar"
)
>=
0
and
f
.
indexOf
(
".orig."
)
>
0
data
.
package
.
sources
.
push
file
else
file
.
name
=
file
.
extension
data
.
package
.
files
.
push
file
return
callback
data
return
return
__send_package_files_list
=
(
event_name
,
socket
,
data
)
->
__get_files_list_from_package
data
,
(
new_data
)
->
socket
.
emit
event_name
,
new_data
return
__send_package_files_list
=
(
event_name
,
socket
,
data
)
->
__get_files_list_from_package
data
,
(
new_data
)
->
socket
.
emit
event_name
,
new_data
return
return
__read_package_status
=
(
data
,
cb
)
->
package_path
=
utils
.
get_package_path
(
data
)
package_json
=
path
.
join
(
package_path
,
data
.
package
.
orig_name
+
".json"
)
fs
.
readFile
package_json
,
encoding
:
"utf8"
,
(
err
,
content
)
->
if
err
utils
.
errors_handler
"Client:__read_package_status:"
,
err
return
try
content
=
JSON
.
parse
(
content
)
catch
parse_err
utils
.
errors_handler
"Client:__read_package_status:parse_err:"
,
parse_err
return
cb
content
return
__read_package_status
=
(
data
,
cb
)
->
package_path
=
utils
.
get_package_path
(
data
)
package_json
=
path
.
join
(
package_path
,
data
.
package
.
orig_name
+
".json"
)
fs
.
readFile
package_json
,
encoding
:
"utf8"
,
(
err
,
content
)
->
if
err
utils
.
errors_handler
"Client:__read_package_status:"
,
err
return
try
content
=
JSON
.
parse
(
content
)
catch
parse_err
utils
.
errors_handler
"Client:__read_package_status:parse_err:"
,
parse_err
return
cb
content
return
return
__send_package_info
=
(
socket
,
data
)
->
__read_package_status
data
,
(
content
)
->
socket
.
emit
_e
.
package_info
,
content
return
__send_package_info
=
(
socket
,
data
)
->
__read_package_status
data
,
(
content
)
->
socket
.
emit
_e
.
package_info
,
content
return
return
__send_package_status
=
(
socket
,
data
)
->
__read_package_status
data
,
(
content
)
->
socket
.
emit
_e
.
distribution_packages_status
,
content
return
__send_package_status
=
(
socket
,
data
)
->
__read_package_status
data
,
(
content
)
->
socket
.
emit
_e
.
distribution_packages_status
,
content
return
return
__send_distribution_packages
=
(
event_name
,
socket
,
data
)
->
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
utils
.
get_files_list
distro_path
,
true
,
(
packages
)
->
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
p
)
->
pack
=
{}
info
=
p
.
split
(
"_"
)
pack
.
name
=
info
[
0
]
pack
.
version
=
info
[
1
]
pack
.
orig_name
=
p
__send_package_status
socket
,
distribution
:
data
.
distribution
package
:
pack
data
.
distribution
.
packages
.
push
pack
return
socket
.
emit
event_name
,
data
return
__send_distribution_packages
=
(
event_name
,
socket
,
data
)
->
distro_path
=
utils
.
get_distribution_pool_path
(
data
)
utils
.
get_files_list
distro_path
,
true
,
(
packages
)
->
data
.
distribution
.
packages
=
[]
packages
.
forEach
(
p
)
->
pack
=
{}
info
=
p
.
split
(
"_"
)
pack
.
name
=
info
[
0
]
pack
.
version
=
info
[
1
]
pack
.
orig_name
=
p
__send_package_status
socket
,
distribution
:
data
.
distribution
package
:
pack
data
.
distribution
.
packages
.
push
pack
return
socket
.
emit
event_name
,
data
return
return
__send_file
=
(
event_name
,
socket
,
data
,
last_lines
)
->
file_path
=
utils
.
get_file_path
(
data
)
fs
.
readFile
file_path
,
"utf8"
,
(
err
,
content
)
->
if
err
utils
.
errors_handler
"client:__send_file"
,
err
,
socket
return
data
.
file
.
orig_name
=
file_path
.
split
(
"/"
).
pop
()
if
last_lines
>
0
data
.
file
.
content
=
content
.
split
(
"
\n
"
).
slice
(
-
last_lines
).
join
(
"
\n
"
)
else
data
.
file
.
content
=
content
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
socket
.
emit
event_name
,
data
return
__send_file
=
(
event_name
,
socket
,
data
,
last_lines
)
->
file_path
=
utils
.
get_file_path
(
data
)
fs
.
readFile
file_path
,
"utf8"
,
(
err
,
content
)
->
if
err
utils
.
errors_handler
"client:__send_file"
,
err
,
socket
return
data
.
file
.
orig_name
=
file_path
.
split
(
"/"
).
pop
()
if
last_lines
>
0
data
.
file
.
content
=
content
.
split
(
"
\n
"
).
slice
(
-
last_lines
).
join
(
"
\n
"
)
else
data
.
file
.
content
=
content
data
.
file
.
path
=
file_path
.
replace
(
config
.
debomatic
.
path
,
config
.
routes
.
debomatic
)
socket
.
emit
event_name
,
data
return
return
return
__handler_get_file
=
(
socket
,
data
)
->
file_path
=
utils
.
get_file_path
(
data
)
utils
.
watch_path_onsocket
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
(
event_name
,
socket
,
data
)
->
data
.
file
.
content
=
null
socket
.
emit
event_name
,
data
file_path
=
utils
.
get_file_path
(
data
)
utils
.
watch_path_onsocket
_e
.
file_newcontent
,
socket
,
data
,
file_path
,
(
event_name
,
socket
,
data
)
->
data
.
file
.
content
=
null
socket
.
emit
event_name
,
data
return
if
config
.
web
.
file
.
preview
.
indexOf
(
data
.
file
.
name
)
>=
0
and
not
data
.
file
.
force
__send_file
_e
.
file
,
socket
,
data
,
config
.
web
.
file
.
num_lines
else
__send_file
_e
.
file
,
socket
,
data
return
if
config
.
web
.
file
.
preview
.
indexOf
(
data
.
file
.
name
)
>=
0
and
not
data
.
file
.
force
__send_file
_e
.
file
,
socket
,
data
,
config
.
web
.
file
.
num_lines
else
__send_file
_e
.
file
,
socket
,
data
return
Client
=
(
socket
)
->
@
start
=
->
# init send distributions
utils
.
send_distributions
socket
# init events
socket
.
on
_e
.
distribution_packages
,
(
data
)
->
return
unless
utils
.
check_data_distribution
(
data
)
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
utils
.
generic_handler_watcher
_e
.
distribution_packages
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
data
=
null
return
socket
.
on
_e
.
package_files_list
,
(
data
)
->
return
unless
utils
.
check_data_package
(
data
)
package_path
=
utils
.
get_package_path
(
data
)
utils
.
generic_handler_watcher
_e
.
package_files_list
,
socket
,
data
,
package_path
,
__send_package_files_list
data
=
null
return
socket
.
on
_e
.
file
,
(
data
)
->
return
unless
utils
.
check_data_file
(
data
)
__handler_get_file
socket
,
data
data
=
null
return
socket
.
on
_e
.
package_info
,
(
data
)
->
return
unless
utils
.
check_data_package
(
data
)
__send_package_info
socket
,
data
data
=
null
return
# on client disconnection close all watchers
socket
.
on
"disconnect"
,
->
socket_watchers
=
socket
.
watchers
return
unless
socket_watchers
for
key
of
socket_watchers
try
socket_watchers
[
key
].
close
()
catch
error_watch
utils
.
errors_handler
"client:disconnect"
,
error_watch
return
return
@
send_status
=
(
status
)
->
socket
.
emit
_e
.
status
,
status
return
@
send_status_debomatic
=
->
fs
.
exists
config
.
debomatic
.
pidfile
,
(
exists
)
->
socket
.
emit
config
.
events
.
broadcast
.
status_debomatic
,
running
:
exists
return
@
start
=
->
# init send distributions
utils
.
send_distributions
socket
# init events
socket
.
on
_e
.
distribution_packages
,
(
data
)
->
return
unless
utils
.
check_data_distribution
(
data
)
distribution_path
=
path
.
join
(
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
)
utils
.
generic_handler_watcher
_e
.
distribution_packages
,
socket
,
data
,
distribution_path
,
__send_distribution_packages
data
=
null
return
socket
.
on
_e
.
package_files_list
,
(
data
)
->
return
unless
utils
.
check_data_package
(
data
)
package_path
=
utils
.
get_package_path
(
data
)
utils
.
generic_handler_watcher
_e
.
package_files_list
,
socket
,
data
,
package_path
,
__send_package_files_list
data
=
null
return
socket
.
on
_e
.
file
,
(
data
)
->
return
unless
utils
.
check_data_file
(
data
)
__handler_get_file
socket
,
data
data
=
null
return
socket
.
on
_e
.
package_info
,
(
data
)
->
return
unless
utils
.
check_data_package
(
data
)
__send_package_info
socket
,
data
data
=
null
return
# on client disconnection close all watchers
socket
.
on
"disconnect"
,
->
socket_watchers
=
socket
.
watchers
return
unless
socket_watchers
for
key
of
socket_watchers
try
socket_watchers
[
key
].
close
()
catch
error_watch
utils
.
errors_handler
"client:disconnect"
,
error_watch
return
return
@
send_status
=
(
status
)
->
socket
.
emit
_e
.
status
,
status
return
@
send_status_debomatic
=
->
fs
.
exists
config
.
debomatic
.
pidfile
,
(
exists
)
->
socket
.
emit
config
.
events
.
broadcast
.
status_debomatic
,
running
:
exists
return
return
return
return
"use strict"
fs
=
require
(
"fs"
)
...
...
debomatic-webui/lib/config.coffee
View file @
18c0c552
#
# * Please DO NOT edit this file.
# *
Please DO NOT edit this file.
# *
# * Edit auto-generated 'user.config.js' file instead.
# *
Edit auto-generated 'user.config.js' file instead.
# *
#
...
...
@@ -10,8 +10,8 @@
#
# * Configure host and port.
# * Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
# * $ authbind nodejs index.js
# *
Please for ports < 1000 use authbind. DO NOT RUN nodejs as root.
# *
$ authbind nodejs index.js
#
# web configuration
...
...
@@ -38,16 +38,16 @@
# * update object1 with object2 values
#
_merge
=
(
object1
,
object2
)
->
result
=
{}
for
p
of
object1
if
object2
.
hasOwnProperty
(
p
)
if
typeof
object1
[
p
]
is
"object"
and
typeof
object2
[
p
]
is
"object"
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
])
else
result
[
p
]
=
object2
[
p
]
else
result
[
p
]
=
object1
[
p
]
result
result
=
{}
for
p
of
object1
if
object2
.
hasOwnProperty
(
p
)
if
typeof
object1
[
p
]
is
"object"
and
typeof
object2
[
p
]
is
"object"
result
[
p
]
=
_merge
(
object1
[
p
],
object2
[
p
])
else
result
[
p
]
=
object2
[
p
]
else
result
[
p
]
=
object1
[
p
]
result
"use strict"
config
=
{}
config
.
host
=
"localhost"
...
...
@@ -87,8 +87,8 @@ config.web.preferences.file_fontsize = 13
config
.
web
.
preferences
.
debug
=
0
config
.
version
=
"0.6.0"
config
.
debomatic
.
excluded_files
=
[
"datestamp"
"json"
"datestamp"
"json"
]
config
.
events
=
{}
config
.
events
.
error
=
"server-error"
...
...
@@ -111,29 +111,29 @@ config.status.update = "update"
config
.
status
.
success
=
true
config
.
status
.
fail
=
false
try
Parser
=
require
(
"./parser"
)
parser
=
new
Parser
()
user_config
=
parser
.
getUserConfig
()
if
user_config
console
.
log
"Reading user configutation ..."
config
=
_merge
(
config
,
require
(
user_config
))
else
console
.
log
"No user config specified. Using global settings."
Parser
=
require
(
"./parser"
)
parser
=
new
Parser
()
user_config
=
parser
.
getUserConfig
()
if
user_config
console
.
log
"Reading user configutation ..."
config
=
_merge
(
config
,
require
(
user_config
))
else
console
.
log
"No user config specified. Using global settings."
catch
err
if
err
.
code
is
"MODULE_NOT_FOUND"
console
.
log
"File %s not found."
,
user_config
process
.
exit
1
else
console
.
error
"Error reading user configutation"
,
err
process
.
exit
1
if
err
.
code
is
"MODULE_NOT_FOUND"
console
.
log
"File %s not found."
,
user_config
process
.
exit
1
else
console
.
error
"Error reading user configutation"
,
err
process
.
exit
1
finally
# export some variable
config
.
web
.
paths
=
config
.
routes
config
.
web
.
events
=
config
.
events
config
.
web
.
status
=
config
.
status
config
.
web
.
host
=
config
.
host
# calculate pidfile
config
.
debomatic
.
pidfile
=
"/var/run/debomatic-"
+
require
(
"crypto"
).
createHash
(
"sha256"
).
update
(
config
.
debomatic
.
path
).
digest
(
"hex"
)
module
.
exports
=
config
# export some variable
config
.
web
.
paths
=
config
.
routes
config
.
web
.
events
=
config
.
events
config
.
web
.
status
=
config
.
status
config
.
web
.
host
=
config
.
host
# calculate pidfile
config
.
debomatic
.
pidfile
=
"/var/run/debomatic-"
+
require
(
"crypto"
).
createHash
(
"sha256"
).
update
(
config
.
debomatic
.
path
).
digest
(
"hex"
)
module
.
exports
=
config
debomatic-webui/lib/parser.coffee
View file @
18c0c552
#jshint multistr: true
Parser
=
->
args
=
process
.
argv
.
slice
(
2
)
help
=
->
console
.
log
"Usage: %s [-c config]
\n
-h print this help
\n
-c set user configuration file"
,
process
.
argv
[
1
].
split
(
"/"
).
pop
()
process
.
exit
0
return
args
=
process
.
argv
.
slice
(
2
)
help
=
->
console
.
log
"Usage: %s [-c config]
\n
-h print this help
\n
-c set user configuration file"
,
process
.
argv
[
1
].
split
(
"/"
).
pop
()
process
.
exit
0
return
@
getUserConfig
=
->
configFile
=
null
args
.
forEach
(
val
,
index
)
->
if
val
is
"-c"
configFile
=
args
[
index
+
1
]
return
if
configFile
process
.
cwd
()
+
"/"
+
configFile
else
null
@
getUserConfig
=
->
configFile
=
null
args
.
forEach
(
val
,
index
)
->
if
val
is
"-c"
configFile
=
args
[
index
+
1
]
help
()
if
val
is
"-h"
return
if
configFile
process
.
cwd
()
+
"/"
+
configFile
else
null
args
.
forEach
(
val
,
index
)
->
help
()
if
val
is
"-h"
return
return
"use strict"
module
.
exports
=
Parser
debomatic-webui/lib/tail.coffee
View file @
18c0c552
...
...
@@ -2,28 +2,28 @@
fs
=
require
(
"fs"
)
Tail
=
require
(
"tail"
).
Tail
Tail
::
watchEvent
=
(
e
)
->
_this
=
this
if
e
is
"change"
fs
.
stat
@
filename
,
(
err
,
stats
)
->
if
err
_this
.
emit
"error"
,
err
return
_this
.
pos
=
stats
.
size
if
stats
.
size
<
_this
.
pos
if
stats
.
size
>
_this
.
pos
_this
.
queue
.
push
start
:
_this
.
pos
end
:
stats
.
size
_this
=
this
if
e
is
"change"
fs
.
stat
@
filename
,
(
err
,
stats
)
->
if
err
_this
.
emit
"error"
,
err
return
_this
.
pos
=
stats
.
size
if
stats
.
size
<
_this
.
pos
if
stats
.
size
>
_this
.
pos
_this
.
queue
.
push
start
:
_this
.
pos
end
:
stats
.
size
_this
.
pos
=
stats
.
size
_this
.
internalDispatcher
.
emit
"next"
if
_this
.
queue
.
length
is
1
_this
.
pos
=
stats
.
size
_this
.
internalDispatcher
.
emit
"next"
if
_this
.
queue
.
length
is
1
else
if
e
is
"rename"
@
unwatch
()
_this
.
emit
"error"
,
"File "
+
@
filename
+
" deleted."
return
else
if
e
is
"rename"
@
unwatch
()
_this
.
emit
"error"
,
"File "
+
@
filename
+
" deleted."
return
Tail
::
close
=
->
@
unwatch
()
return
@
unwatch
()
return
module
.
exports
=
Tail
debomatic-webui/lib/utils.coffee
View file @
18c0c552
__errors_handler
=
(
from
,
err
,
socket
)
->
from
=
"NO SOCKET: "
+
from
unless
socket
console
.
error
from
,
err
.
message
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
return
from
=
"NO SOCKET: "
+
from
unless
socket
console
.
error
from
,
err
.
message
socket
.
emit
config
.
events
.
error
,
err
.
message
if
socket
return
__check_no_backward
=
(
backward_path
)
->
try
return
backward_path
.
indexOf
(
".."
)
<
0
catch
err
return
true
return
try
return
backward_path
.
indexOf
(
".."
)
<
0
catch
err
return
true
return
__check_data_distribution
=
(
data
)
->
__check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
__check_no_backward
(
data
)
and
__check_no_backward
(
data
.
distribution
)
and
__check_no_backward
(
data
.
distribution
.
name
)
__check_data_package
=
(
data
)
->
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__check_data_distribution
(
data
)
and
__check_no_backward
(
data
.
package
)
and
__check_no_backward
(
data
.
package
.
name
)
and
__check_no_backward
(
data
.
package
.
version
)
__check_data_file
=
(
data
)
->
__check_data_package
(
data
)
and
__check_no_backward
(
data
.
file
)
and
__check_no_backward
(
data
.
file
.
name
)
__check_data_package
(
data
)
and
__check_no_backward
(
data
.
file
)
and
__check_no_backward
(
data
.
file
.
name
)
__get_distribution_pool_path
=
(
data
)
->
path
.
join
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
path
.
join
config
.
debomatic
.
path
,
data
.
distribution
.
name
,
"pool"
__get_package_path
=
(
data
)
->
path
.
join
__get_distribution_pool_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
path
.
join
__get_distribution_pool_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
__get_file_path
=
(
data
)
->
path
.
join
__get_package_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
+
data
.
file
.
name
path
.
join
__get_package_path
(
data
),
data
.
package
.
name
+
"_"
+
data
.
package
.
version
+
"."
+
data
.
file
.
name
__get_files_list
=
(
dir
,
onlyDirectories
,
callback
)
->
fs
.
readdir
dir
,
(
err
,
files
)
->
result
=
[]
if
err
__errors_handler
"__get_files_list"
,
err
return
files
.
forEach
(
f
)
->
try
complete_path
=
path
.
join
(
dir
,
f
)
stat
=
fs
.
statSync
(
complete_path
)
if
onlyDirectories
result
.
push
f
if
stat
.
isDirectory
()
else
result
.
push
f
if
stat
.
isFile
()
catch
fs_error
__errors_handler
"__get_files_list:forEach"
,
fs_error
fs
.
readdir
dir
,
(
err
,
files
)
->
result
=
[]
if
err
__errors_handler
"__get_files_list"
,
err
return
files
.
forEach
(
f
)
->
try
complete_path
=
path
.
join
(
dir
,
f
)
stat
=
fs
.
statSync
(
complete_path
)
if
onlyDirectories
result
.
push
f
if
stat
.
isDirectory
()
else
result
.
push
f
if
stat
.
isFile
()
catch
fs_error
__errors_handler
"__get_files_list:forEach"
,
fs_error
return
return
callback
result
return
return
callback
result
return
return
__watch_path_onsocket
=
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
socket_watchers
=
socket
.
watchers
or
{}
try
watcher
=
socket_watchers
[
event_name
]
watcher
.
close
()
if
watcher
fs
.
stat
watch_path
,
(
err
,
stats
)
->
if
err
__errors_handler
"__watch_path_onsocket:fs.stat"
,
err
,
socket
socket_watchers
=
socket
.
watchers
or
{}
try
watcher
=
socket_watchers
[
event_name
]
watcher
.
close
()
if
watcher
fs
.
stat
watch_path
,
(
err
,
stats
)
->
if
err
__errors_handler
"__watch_path_onsocket:fs.stat"
,
err
,
socket
return
if
stats
.
isDirectory
()
watcher
=
fs
.
watch
(
watch_path
,
persistent
:
true
,
(
event
,
fileName
)
->
updater
event_name
,
socket
,
data
if
event
is
"rename"
return
)
else
if
stats
.
isFile
()
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
"line"
,
(
new_content
,
tailInfo
)
->
data
.
file
.
new_content
=
new_content
+
"
\n
"
updater
event_name
,
socket
,
data
return
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
return
socket_watchers
[
event_name
]
=
watcher
socket
.
watchers
=
socket_watchers
return
catch
err
__errors_handler
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
err
,
socket
return
if
stats
.
isDirectory
()
watcher
=
fs
.
watch
(
watch_path
,
persistent
:
true
,
(
event
,
fileName
)
->
updater
event_name
,
socket
,
data
if
event
is
"rename"
return
)
else
if
stats
.
isFile
()
watcher
=
new
Tail
(
watch_path
)
watcher
.
on
"line"
,
(
new_content
,
tailInfo
)
->
data
.
file
.
new_content
=
new_content
+
"
\n
"
updater
event_name
,
socket
,
data
return
watcher
.
on
"error"
,
(
msg
)
->
socket
.
emit
config
.
events
.
error
,
msg
return
socket_watchers
[
event_name
]
=
watcher
socket
.
watchers
=
socket_watchers
return
catch
err
__errors_handler
"__watch_path_onsocket <- "
+
arguments_
.
callee
.
caller
.
name
,
err
,
socket
return
return
__generic_handler_watcher
=
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
callback
event_name
,
socket
,
data
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
return
__send_distributions
=
(
socket
)
->
__get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
distributions
=
[]
directories
.
forEach
(
dir
)
->
data
=
{}
data
.
distribution
=
{}
data
.
distribution
.
name
=
dir
pool_path
=
__get_distribution_pool_path
(
data
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
return
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
callback
event_name
,
socket
,
data
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
callback
return
__send_distributions
=
(
socket
)
->
__get_files_list
config
.
debomatic
.
path
,
true
,
(
directories
)
->
distributions
=
[]
directories
.
forEach
(
dir
)
->
data
=
{}
data
.
distribution
=
{}
data
.
distribution
.
name
=
dir
pool_path
=
__get_distribution_pool_path
(
data
)
distributions
.
push
dir
if
fs
.
existsSync
(
pool_path
)
return
socket
.
emit
config
.
events
.
broadcast
.
distributions
,
distributions
return
return
return
"use strict"
path
=
require
(
"path"
)
fs
=
require
(
"fs"
)
config
=
require
(
"./config"
)
Tail
=
require
(
"./tail"
)
utils
=
check_data_distribution
:
(
data
)
->
__check_data_distribution
data
check_data_distribution
:
(
data
)
->
__check_data_distribution
data
check_data_package
:
(
data
)
->
__check_data_package
data
check_data_package
:
(
data
)
->
__check_data_package
data
check_data_file
:
(
data
)
->
__check_data_file
data
check_data_file
:
(
data
)
->
__check_data_file
data
get_distribution_pool_path
:
(
data
)
->
__get_distribution_pool_path
data
get_distribution_pool_path
:
(
data
)
->
__get_distribution_pool_path
data
get_package_path
:
(
data
)
->
__get_package_path
data
get_package_path
:
(
data
)
->
__get_package_path
data
get_file_path
:
(
data
)
->
__get_file_path
data
get_file_path
:
(
data
)
->
__get_file_path
data
get_files_list
:
(
dir
,
onlyDirectories
,
callback
)
->
__get_files_list
dir
,
onlyDirectories
,
callback
get_files_list
:
(
dir
,
onlyDirectories
,
callback
)
->
__get_files_list
dir
,
onlyDirectories
,
callback
watch_path_onsocket
:
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
updater
watch_path_onsocket
:
(
event_name
,
socket
,
data
,
watch_path
,
updater
)
->
__watch_path_onsocket
event_name
,
socket
,
data
,
watch_path
,
updater
generic_handler_watcher
:
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
__generic_handler_watcher
event_name
,
socket
,
data
,
watch_path
,
callback
generic_handler_watcher
:
(
event_name
,
socket
,
data
,
watch_path
,
callback
)
->
__generic_handler_watcher
event_name
,
socket
,
data
,
watch_path
,
callback
send_distributions
:
(
socket
)
->
__send_distributions
socket
send_distributions
:
(
socket
)
->
__send_distributions
socket
errors_handler
:
(
from
,
error
,
socket
)
->
__errors_handler
from
,
error
,
socket
errors_handler
:
(
from
,
error
,
socket
)
->
__errors_handler
from
,
error
,
socket
module
.
exports
=
utils
debomatic-webui/routes/index.coffee
View file @
18c0c552
"use strict"
config
=
require
(
"../lib/config"
)
exports
.
index
=
(
req
,
res
)
->
res
.
render
"index"
,
config
return
res
.
render
"index"
,
config
return
exports
.
distribution
=
(
req
,
res
)
->
res
.
render
"distribution"
,
config
return
res
.
render
"distribution"
,
config
return
exports
.
preferences
=
(
req
,
res
)
->
res
.
render
"preferences"
,
config
return
res
.
render
"preferences"
,
config
return
exports
.
commands
=
(
req
,
res
)
->
res
.
render
"commands"
,
config
return
res
.
render
"commands"
,
config
return
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment