forked from wekan/wekan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rebuild-wekan.sh
executable file
·178 lines (162 loc) · 5.19 KB
/
rebuild-wekan.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
#!/bin/bash
echo "Note: If you use other locale than en_US.UTF-8 , you need to additionally install en_US.UTF-8"
echo " with 'sudo dpkg-reconfigure locales' , so that MongoDB works correctly."
echo " You can still use any other locale as your main locale."
X64NODE="https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.gz"
function pause(){
read -p "$*"
}
function cprec(){
if [[ -d "$1" ]]; then
if [[ ! -d "$2" ]]; then
sudo mkdir -p "$2"
fi
for i in $(ls -A "$1"); do
cprec "$1/$i" "$2/$i"
done
else
sudo cp "$1" "$2"
fi
}
# sudo npm doesn't work right, so this is a workaround
function npm_call(){
TMPDIR="/tmp/tmp_npm_prefix"
if [[ -d "$TMPDIR" ]]; then
rm -rf $TMPDIR
fi
mkdir $TMPDIR
NPM_PREFIX="$(npm config get prefix)"
npm config set prefix $TMPDIR
npm "$@"
npm config set prefix "$NPM_PREFIX"
echo "Moving files to $NPM_PREFIX"
for i in $(ls -A $TMPDIR); do
cprec "$TMPDIR/$i" "$NPM_PREFIX/$i"
done
rm -rf $TMPDIR
}
function wekan_repo_check(){
git_remotes="$(git remote show 2>/dev/null)"
res=""
for i in $git_remotes; do
res="$(git remote get-url $i | sed 's/.*wekan\/wekan.*/wekan\/wekan/')"
if [[ "$res" == "wekan/wekan" ]]; then
break
fi
done
if [[ "$res" != "wekan/wekan" ]]; then
echo "$PWD is not a wekan repository"
exit;
fi
}
echo
PS3='Please enter your choice: '
options=("Install Wekan dependencies" "Build Wekan" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Install Wekan dependencies")
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Linux";
if [ "$(grep -Ei 'buntu|mint' /etc/*release)" ]; then
sudo apt install -y build-essential git curl wget
# sudo apt -y install nodejs npm
# npm_call -g install n
# sudo n 8.12.0
fi
# if [ "$(grep -Ei 'debian' /etc/*release)" ]; then
# sudo apt install -y build-essential git curl wget
# echo "Debian, or Debian on Windows Subsystem for Linux"
# curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
# sudo apt install -y nodejs
# fi
# TODO: Add Sandstorm for version of Node.js install
#MACHINE_TYPE=`uname -m`
#if [ ${MACHINE_TYPE} == 'x86_64' ]; then
# # 64-bit stuff here
# wget ${X64NODE}
# sudo tar -C /usr/local --strip-components 1 -xzf ${X64NODE}
#elif [ ${MACHINE_TYPE} == '32bit' ]; then
# echo "TODO: 32-bit Linux install here"
# exit
#fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macOS";
pause '1) Install XCode 2) Install Node 8.x from https://nodejs.org/en/ 3) Press [Enter] key to continue.'
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
echo "TODO: Add Cygwin";
exit;
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
echo "TODO: Add msys on Windows";
exit;
elif [[ "$OSTYPE" == "win32" ]]; then
# I'm not sure this can happen.
echo "TODO: Add Windows";
exit;
elif [[ "$OSTYPE" == "freebsd"* ]]; then
echo "TODO: Add FreeBSD";
exit;
else
echo "Unknown"
echo ${OSTYPE}
exit;
fi
## Latest npm with Meteor 1.6
npm_call -g install npm
npm_call -g install node-gyp
# Latest fibers for Meteor 1.6
npm_call -g install fibers@2.0.0
# Install Meteor, if it's not yet installed
curl https://install.meteor.com | bash
# mkdir ~/repos
# cd ~/repos
# git clone https://github.com/wekan/wekan.git
# cd wekan
# git checkout devel
break
;;
"Build Wekan")
echo "Building Wekan."
wekan_repo_check
rm -rf packages
mkdir packages
cd packages
git clone --depth 1 -b master https://github.com/wekan/flow-router.git kadira-flow-router
git clone --depth 1 -b master https://github.com/meteor-useraccounts/core.git meteor-useraccounts-core
git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-cas.git
git clone --depth 1 -b master https://github.com/wekan/wekan-ldap.git
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "sed at macOS";
sed -i '' 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
else
echo "sed at ${OSTYPE}"
sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
fi
cd ..
rm -rf node_modules
meteor npm install
rm -rf .build
meteor build .build --directory
cp -f fix-download-unicode/cfs_access-point.txt .build/bundle/programs/server/packages/cfs_access-point.js
#Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
#https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
#https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
#cd ~/repos/wekan/.build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt
#rm -rf node_modules/bcrypt
#meteor npm install bcrypt
cd .build/bundle/programs/server
rm -rf node_modules
meteor npm install
#meteor npm install bcrypt
cd ../../../..
echo Done.
break
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done