-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunme.coffee
executable file
·80 lines (60 loc) · 1.68 KB
/
runme.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env coffee
###
#
# Unofficial setup pet script. Don't use if in doubt.
# Run (after git clone) in the project directory as superuser.
#
###
sh = require '/usr/lib/node_modules/shelljs'
tm = require('terminal-kit').terminal
path = require 'path'
isRoot = require 'is-root'
# Callbacks never called?
process.on 'SIGINT',
->
tm.red.bold "Aborted by user?\n"
process.exit()
process.on 'uncaughtException',
(err) ->
tm.red.bold "Permission denied?\n"
process.exit()
exePath = '/usr/bin/'
lks = {
cmd: {target: path.join(sh.pwd(), 'src/pcn.coffee'), linkPath: exePath, linkName: 'pcf'}
srv: {target: path.join(sh.pwd(), 'src/procrserver.py'), linkPath: exePath, linkName: 'procrserver'}
}
overWarn = do ->
###
Delivers the warning once in a lifetime
###
flw = -1
->
flw++
if not flw
tm.brightWhite "\nThe following entities on the system will be overwritten:\n\n"
return
# Overwrite warnings
for k, v of lks
link = path.join v.linkPath, v.linkName
if sh.which(v.linkName) is link
overWarn()
sh.exec "ls -l \"#{link}\""
tm.brightWhite "\nThe following symlinks\n\n"
# Symlinks to be created
for k, v of lks
tm.brightCyan path.join v.linkPath, v.linkName
tm " -> "
tm.brightGreen "#{v.target}\n"
tm.brightWhite "\nare going to be created. Are you sure? "; tm.white "[Y|n]\n"
tm.yesOrNo {yes: ['y', 'ENTER'], no: ['n']},
(error, result) ->
if result
if not isRoot()
tm.brightRed "Permission denied.\n"
tm.white '\n'
process.exit()
# Creating symlinks
for k, v of lks
sh.ln '-sf', v.target, path.join v.linkPath, v.linkName
process.exit()
return