rebuild-wekan.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #!/bin/bash
  2. echo "Note: If you use other locale than en_US.UTF-8 , you need to additionally install en_US.UTF-8"
  3. echo " with 'sudo dpkg-reconfigure locales' , so that MongoDB works correctly."
  4. echo " You can still use any other locale as your main locale."
  5. X64NODE="https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.gz"
  6. function pause(){
  7. read -p "$*"
  8. }
  9. function cprec(){
  10. if [[ -d "$1" ]]; then
  11. if [[ ! -d "$2" ]]; then
  12. sudo mkdir -p "$2"
  13. fi
  14. for i in $(ls -A "$1"); do
  15. cprec "$1/$i" "$2/$i"
  16. done
  17. else
  18. sudo cp "$1" "$2"
  19. fi
  20. }
  21. # sudo npm doesn't work right, so this is a workaround
  22. function npm_call(){
  23. TMPDIR="/tmp/tmp_npm_prefix"
  24. if [[ -d "$TMPDIR" ]]; then
  25. rm -rf $TMPDIR
  26. fi
  27. mkdir $TMPDIR
  28. NPM_PREFIX="$(npm config get prefix)"
  29. npm config set prefix $TMPDIR
  30. npm "$@"
  31. npm config set prefix "$NPM_PREFIX"
  32. echo "Moving files to $NPM_PREFIX"
  33. for i in $(ls -A $TMPDIR); do
  34. cprec "$TMPDIR/$i" "$NPM_PREFIX/$i"
  35. done
  36. rm -rf $TMPDIR
  37. }
  38. function wekan_repo_check(){
  39. git_remotes="$(git remote show 2>/dev/null)"
  40. res=""
  41. for i in $git_remotes; do
  42. res="$(git remote get-url $i | sed 's/.*wekan\/wekan.*/wekan\/wekan/')"
  43. if [[ "$res" == "wekan/wekan" ]]; then
  44. break
  45. fi
  46. done
  47. if [[ "$res" != "wekan/wekan" ]]; then
  48. echo "$PWD is not a wekan repository"
  49. exit;
  50. fi
  51. }
  52. echo
  53. PS3='Please enter your choice: '
  54. options=("Install Wekan dependencies" "Build Wekan" "Quit")
  55. select opt in "${options[@]}"
  56. do
  57. case $opt in
  58. "Install Wekan dependencies")
  59. if [[ "$OSTYPE" == "linux-gnu" ]]; then
  60. echo "Linux";
  61. if [ "$(grep -Ei 'buntu|mint' /etc/*release)" ]; then
  62. sudo apt install -y build-essential git curl wget
  63. # sudo apt -y install nodejs npm
  64. # npm_call -g install n
  65. # sudo n 8.12.0
  66. fi
  67. # if [ "$(grep -Ei 'debian' /etc/*release)" ]; then
  68. # sudo apt install -y build-essential git curl wget
  69. # echo "Debian, or Debian on Windows Subsystem for Linux"
  70. # curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  71. # sudo apt install -y nodejs
  72. # fi
  73. # TODO: Add Sandstorm for version of Node.js install
  74. #MACHINE_TYPE=`uname -m`
  75. #if [ ${MACHINE_TYPE} == 'x86_64' ]; then
  76. # # 64-bit stuff here
  77. # wget ${X64NODE}
  78. # sudo tar -C /usr/local --strip-components 1 -xzf ${X64NODE}
  79. #elif [ ${MACHINE_TYPE} == '32bit' ]; then
  80. # echo "TODO: 32-bit Linux install here"
  81. # exit
  82. #fi
  83. elif [[ "$OSTYPE" == "darwin"* ]]; then
  84. echo "macOS";
  85. pause '1) Install XCode 2) Install Node 8.x from https://nodejs.org/en/ 3) Press [Enter] key to continue.'
  86. elif [[ "$OSTYPE" == "cygwin" ]]; then
  87. # POSIX compatibility layer and Linux environment emulation for Windows
  88. echo "TODO: Add Cygwin";
  89. exit;
  90. elif [[ "$OSTYPE" == "msys" ]]; then
  91. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  92. echo "TODO: Add msys on Windows";
  93. exit;
  94. elif [[ "$OSTYPE" == "win32" ]]; then
  95. # I'm not sure this can happen.
  96. echo "TODO: Add Windows";
  97. exit;
  98. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  99. echo "TODO: Add FreeBSD";
  100. exit;
  101. else
  102. echo "Unknown"
  103. echo ${OSTYPE}
  104. exit;
  105. fi
  106. ## Latest npm with Meteor 1.6
  107. npm_call -g install npm
  108. npm_call -g install node-gyp
  109. # Latest fibers for Meteor 1.6
  110. npm_call -g install fibers@2.0.0
  111. # Install Meteor, if it's not yet installed
  112. curl https://install.meteor.com | bash
  113. # mkdir ~/repos
  114. # cd ~/repos
  115. # git clone https://github.com/wekan/wekan.git
  116. # cd wekan
  117. # git checkout devel
  118. break
  119. ;;
  120. "Build Wekan")
  121. echo "Building Wekan."
  122. wekan_repo_check
  123. rm -rf packages
  124. mkdir packages
  125. cd packages
  126. git clone --depth 1 -b master https://github.com/wekan/flow-router.git kadira-flow-router
  127. git clone --depth 1 -b master https://github.com/meteor-useraccounts/core.git meteor-useraccounts-core
  128. git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-cas.git
  129. git clone --depth 1 -b master https://github.com/wekan/wekan-ldap.git
  130. if [[ "$OSTYPE" == "darwin"* ]]; then
  131. echo "sed at macOS";
  132. sed -i '' 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  133. else
  134. echo "sed at ${OSTYPE}"
  135. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  136. fi
  137. cd ..
  138. rm -rf node_modules
  139. meteor npm install
  140. rm -rf .build
  141. meteor build .build --directory
  142. cp -f fix-download-unicode/cfs_access-point.txt .build/bundle/programs/server/packages/cfs_access-point.js
  143. #Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
  144. #https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
  145. #https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
  146. #cd ~/repos/wekan/.build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt
  147. #rm -rf node_modules/bcrypt
  148. #meteor npm install bcrypt
  149. cd .build/bundle/programs/server
  150. rm -rf node_modules
  151. meteor npm install
  152. #meteor npm install bcrypt
  153. cd ../../../..
  154. echo Done.
  155. break
  156. ;;
  157. "Quit")
  158. break
  159. ;;
  160. *) echo invalid option;;
  161. esac
  162. done