This repository has been archived by the owner on May 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathserver
executable file
·103 lines (83 loc) · 2 KB
/
server
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# make sure we're in the project's root
cd "$(dirname "$0")/.."
source ./lib/common.sh
export NO_EM_RESTART=1
server_darwin()
{
NAME="$(config App Name)"
XUL="build/$NAME.app/Contents/MacOS/xulrunner"
if [[ ! -x "$XUL" ]]; then
warn "You don't have an .app bundle built for development"
read -p "Build it now? [y] "
if [[ "$REPLY" == "" || "$REPLY" == "y" || "$REPLY" == "Y" ]]; then
$(dirname $0)/../bootstrap || exit $?
else
die "Cannot run server without an .app bundle"
fi
fi
logfile=$(logfile_from_arguments "$@")
if [[ -z "$logfile" ]]; then
PROFILES="$HOME/Library/Application Support/$(config App Name)/Profiles"
for profile in "$PROFILES"/*.default
do
logfile="$profile/wuff_log.txt"
break
done
fi
run_and_tail "$XUL" "$logfile" "$@"
}
server_linux()
{
vendor="$(config App Vendor | tr '[A-Z]' '[a-z]')"
appname="$(config App Name | tr '[A-Z]' '[a-z]')"
logfile=$(logfile_from_arguments "$@")
if [[ -z "$logfile" ]]; then
PROFILES="$HOME/.$vendor/$appname"
for profile in "$PROFILES"/*.default
do
logfile="$profile/wuff_log.txt"
break
done
fi
run_and_tail xulrunner "$logfile" application/application.ini "$@"
}
logfile_from_arguments()
{
local next_is_profile=false
for arg in "$@"
do
if [[ "$next_is_profile" == "true" ]]; then
echo "$arg/wuff_log.txt"
return 0
fi
if [[ "$arg" == "-profile" ]]; then
next_is_profile=true
fi
done
return 1
}
run_and_tail()
{
XUL=$1
shift
logfile=$1
shift
"$XUL" "$@" &
if [[ -e "$logfile" ]]; then
tail -n 0 -f "$logfile" &
trap "kill %1 2>/dev/null; kill %2 2>/dev/null; exit" INT TERM EXIT
wait %1
exit
else
warn "Expected log file at $logfile, but it wasn't found"
warn "File logging won't happen automatically"
trap "kill %1 2>/dev/null; exit" INT TERM EXIT
wait %1
fi
}
if [[ `uname` == "Darwin" ]]; then
server_darwin "$@"
else
server_linux "$@"
fi