-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsinit.sh
266 lines (235 loc) · 7.1 KB
/
jsinit.sh
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
set -e
clear
if ! type "curl" > /dev/null; then
echo "curl is not installed, please install"
exit 1
fi
function valid () {
if [ $? -ne 0 ]; then
cat /tmp/lastcommandoutput.txt
if [ -z $1 ]; then
echo "Error in last step"
else
echo $1
fi
exit $?
fi
}
function osx_install {
if ! type "brew" > /dev/null; then
sudo echo "* Install Brew"
yes '' | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
set +e
sudo echo "* Unlink curl/python/git"
brew unlink curl > /tmp/lastcommandoutput.txt 2>&1
brew unlink python3 > /tmp/lastcommandoutput.txt 2>&1
brew unlink git > /tmp/lastcommandoutput.txt 2>&1
set -e
sudo echo "* Install Python"
brew install --overwrite python3 > /tmp/lastcommandoutput.txt 2>&1
valid
brew link --overwrite python3 > /tmp/lastcommandoutput.txt 2>&1
valid
sudo echo "* Install Git"
brew install git > /tmp/lastcommandoutput.txt 2>&1
valid
brew link --overwrite git > /tmp/lastcommandoutput.txt 2>&1
valid
sudo echo "* Install Curl"
brew install curl > /tmp/lastcommandoutput.txt 2>&1
valid
brew link --overwrite curl > /tmp/lastcommandoutput.txt 2>&1
valid
# brew install snappy
# sudo mkdir -p /optvar
# sudo chown -R $USER /optvar
# sudo mkdir -p /opt
# sudo chown -R $USER /opt
}
function alpine_install {
apk add git > /tmp/lastcommandoutput.txt 2>&1
apk add curl > /tmp/lastcommandoutput.txt 2>&1
apk add python3 > /tmp/lastcommandoutput.txt 2>&1
apk add tmux > /tmp/lastcommandoutput.txt 2>&1
# apk add wget
# apk add python3-dev
# apk add gcc
# apk add make
# apk add alpine-sdk
# apk add snappy-dev
# apk add py3-cffi
# apk add libffi
# apk add libffi-dev
# apk add openssl-dev
# apk add libexecinfo-dev
# apk add linux-headers
# apk add redis
}
function ubuntu_unstall {
locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
if [ "$dist" == "Ubuntu" ]; then
echo "found ubuntu"
apt-get install git
apt-get install curl git ssh python3 -y
# apt-get install python3-pip -y
# apt-get install libssl-dev -y
# apt-get install python3-dev -y
# apt-get install build-essential -y
# apt-get install libffi-dev -y
# apt-get install libsnappy-dev libsnappy1v5 -y
# rm -f /usr/bin/python
# rm -f /usr/bin/python3
# ln -s /usr/bin/python3.5 /usr/bin/python
# ln -s /usr/bin/python3.5 /usr/bin/python3
else
echo "ONLY ALPINE & UBUNTU LINUX SUPPORTED"
exit 1
fi
}
function cygwin_install {
# Do something under Windows NT platform
export LANG=C; export LC_ALL=C
lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin
apt-cyg install curl
# apt-cyg install python3-dev
# apt-cyg install build-essential
# apt-cyg install openssl-devel
# apt-cyg install libffi-dev
apt-cyg install python3
# apt-cyg install make
# apt-cyg install unzip
apt-cyg install git
ln -sf /usr/bin/python3 /usr/bin/python
}
function getcode {
cd $CODEDIR/github/jumpscale
if [ ! -e $CODEDIR/github/jumpscale/developer ]; then
set +e
git clone git@github.com:Jumpscale/developer.git
if [ ! $? -eq 0 ]; then
set -ex
git clone https://github.com/Jumpscale/developer.git
fi
set +e
else
cd $CODEDIR/github/jumpscale/developer
git pull
fi
if [ ! -e $CODEDIR/github/jumpscale/core9 ]; then
set +e
git clone git@github.com:Jumpscale/core9.git
if [ ! $? -eq 0 ]; then
set -ex
git clone https://github.com/Jumpscale/core9.git
fi
set +e
else
cd $CODEDIR/github/jumpscale/core9
git pull
fi
}
function getcode2 {
if [ ! -e $CODEDIR/github/jumpscale/lib9 ]; then
set +e
git clone git@github.com:Jumpscale/lib9.git
if [ ! $? -eq 0 ]; then
set -ex
git clone https://github.com/Jumpscale/lib9.git
fi
set +e
else
cd $CODEDIR/github/jumpscale/lib9
git pull
fi
if [ ! -e $CODEDIR/github/jumpscale/ays9 ]; then
set +e
git clone git@github.com:Jumpscale/ays9.git
if [ ! $? -eq 0 ]; then
set -ex
git clone https://github.com/Jumpscale/ays9.git
fi
set +e
else
cd $CODEDIR/github/jumpscale/ays9
git pull
fi
if [ ! -e $CODEDIR/github/jumpscale/rsal9 ]; then
set +e
git clone git@github.com:Jumpscale/rsal9.git
if [ ! $? -eq 0 ]; then
set -ex
git clone https://github.com/Jumpscale/rsal9.git
fi
set +e
else
cd $CODEDIR/github/jumpscale/rsal9
git pull
fi
if [ ! -e $CODEDIR/github/jumpscale/portal9 ]; then
set +e
git clone git@github.com:Jumpscale/portal9.git
if [ ! $? -eq 0 ]; then
set -ex
git clone https://github.com/Jumpscale/portal9.git
fi
set +e
else
cd $CODEDIR/github/jumpscale/portal9
git pull
fi
}
########MAIN BLOCK#############
sudo echo "* get mascot"
curl https://raw.githubusercontent.com/Jumpscale/developer/master/mascot?$RANDOM > ~/.mascot.txt
valid
clear
cat ~/.mascot.txt
echo
if [ "$(uname)" == "Darwin" ]; then
# Do something under Mac OS X platform
echo "* INSTALL homebrew, curl, python, git"
export LANG=C; export LC_ALL=C
osx_install
elif [ -e /etc/alpine-release ]; then
echo "* INSTALL curl, python, git"
alpine_install
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# export LC_ALL='C.UTF-8'
echo "* INSTALL curl, python, git"
ubuntu_unstall
elif [ "$(expr substr $(uname -s) 1 9)" == "CYGWIN_NT" ]; then
cygwin_install
fi
sudo echo "* get gig environment script"
curl https://raw.githubusercontent.com/Jumpscale/developer/master/jsenv.sh?$RANDOM > ~/.jsenv.sh
valid
echo "* include the gig environment script"
source ~/.jsenv.sh
echo "* create dir's"
mkdir -p $DATADIR > /tmp/lastcommandoutput.txt 2>&1
valid
mkdir -p $CODEDIR/github/jumpscale > /tmp/lastcommandoutput.txt 2>&1
valid
mkdir -p $CFGDIR > /tmp/lastcommandoutput.txt 2>&1
valid
rm -rf ~/.ssh/known_hosts
echo "* get core code for development scripts & jumpscale core"
getcode > /tmp/lastcommandoutput.txt 2>&1
valid
function linkcode {
echo "* link commands to local environment"
#link all our command lines relevant to jumpscale development env
rm -f /usr/local/bin/js*
rm -rf /usr/local/bin/cmds
find $CODEDIR/github/jumpscale/developer/cmds -exec ln -s {} "/usr/local/bin/" \;
rm -rf /usr/local/bin/cmds
find $CODEDIR/github/jumpscale/core9/cmds -exec ln -s {} "/usr/local/bin/" \;
rm -rf /usr/local/bin/cmds
}
linkcode > /tmp/lastcommandoutput.txt 2>&1
valid