-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.rc
More file actions
130 lines (108 loc) · 3.79 KB
/
setup.rc
File metadata and controls
130 lines (108 loc) · 3.79 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# sysconf install script for sysconf profile for textree -*- shell-script -*-
#
# Uses: NodeJS and memcached
#
. /usr/lib/sysconf.base/common.sh
_packages=
# Runtime deps:
_packages="$_packages ca-certificates memcached"
# Install-time deps:
_packages="$_packages build-essential python software-properties-common"
if [ "$SYSCONF_TEXTREE_ENABLE_NGINX" != no ]; then
# NginX
_packages="$_packages nginx"
_packages="$_packages bind9-host dnsutils"
fi
sysconf_require_packages $_packages
if ! [ -r /etc/apt/sources.list.d/ubuntu-toolchain-r-test-trusty.list ]; then
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
sysconf_require_packages libstdc++-4.9-dev
fi
if ! [ -x /usr/bin/nodejs ]; then
sh nodejs.install.sh \
|| nef_fatal "could not install npm"
sysconf_require_packages nodejs
fi
[ -x /usr/bin/node ] \
|| ln -s nodejs /usr/bin/node
[ -f /etc/nginx/sites-enabled/default ] \
&& rm -f /etc/nginx/sites-enabled/default
# Install NPM
if [ ! -x /usr/bin/npm ]; then
nef_log "Installing NPM..."
sh npmjs.install.sh \
|| nef_fatal "could not install npm"
# npm -g install npm@latest
fi
# npm config set proxy $http_proxy
# npm config set https-proxy $shttp_proxy
# npm config set strict-ssl=false
if ! npm list textream -g >/dev/null; then
npm install textream -g \
|| nef_fatal "could not install NPM module: Textream"
fi
###
# START doing things in share/textree
# _actual_pwd=$PWD
# cd /tmp
# git clone https://github.com/request/tunnel-agent.git
# cp tunnel-agent/index.js $_actual_pwd/tree/usr/share/textree/node_modules/request/tunnel.js
# cd $_actual_pwd/tree/usr/share/textree
# 'forever' come from NPM and provide NodeJS process management
if ! npm list forever -g >/dev/null; then
nef_log "Installing NPM modules..."
npm install forever -g
# BUILD_ONLY=true npm install --unsafe-perm \
# npm install \
# || nef_fatal "could not install npm modules for textree"
# _nodegit_so=$_actual_pwd/resource/nodegit.node
# # nef_log "Fixing module nodegit with pre-built: $_nodegit_so"
# # cp $_nodegit_so node_modules/nodegit/build/Release/nodegit.node \
# # || nef_fatal "copy failed"
fi
## These commented lines were for building the binary node-git library.
## As we had problems with it, it's included in resource/nodegit.node
#
# npm install --unsafe-perm --verbose http://registry.npmjs.org/nodegit/-/nodegit-0.1.4.tgz \
# || nef_fatal "could not build and install nodegit-0.1.4"
# nef_log "Building and installing nodegit (which is really tricky)..."
# (
# cd node_modules
# rm -rf nodegit
# export PATH=$PATH:$PWD/nodegit/node_modules/.bin
# mkdir nodegit \
# && curl http://registry.npmjs.org/nodegit/-/nodegit-0.1.4.tgz \
# | tar xz --strip-components=1 -C ./nodegit \
# && cd nodegit \
# && npm --unsafe-perm install ejs \
# && npm --unsafe-perm run codegen \
# && npm --unsafe-perm install \
# && node install
# ) || nef_log "failed to build and install nodegit"
# cd $_actual_pwd
# END doing things in share/textree
###
# Setting branch "textree" by default as head content for the textree server
if ! [ -r /var/lib/textree/HEAD ]; then
mkdir -p /var/lib/textree
echo textree >/var/lib/textree/HEAD
fi
# Manage the textree service
if [ 0 -eq $(find /etc/rc*.d -name '*[0-9]textree' | wc -l) ]; then
update-rc.d textree defaults
fi
if service textree status >/dev/null; then
service textree restart \
|| nef_fatal "could not restart textree"
else
service textree start \
|| nef_fatal "could not start textree"
fi
if [ "$SYSCONF_TEXTREE_ENABLE_NGINX" != no ]; then
if ps x | grep " nginx:" | grep -vq grep; then
service nginx reload
else
service nginx start
fi
fi