rebuild-wekan.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. #Below script installs newest node 8.x for Debian/Ubuntu/Mint.
  6. #NODE_VERSION=8.14.1
  7. #X64NODE="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz"
  8. function pause(){
  9. read -p "$*"
  10. }
  11. function cprec(){
  12. if [[ -d "$1" ]]; then
  13. if [[ ! -d "$2" ]]; then
  14. sudo mkdir -p "$2"
  15. fi
  16. for i in $(ls -A "$1"); do
  17. cprec "$1/$i" "$2/$i"
  18. done
  19. else
  20. sudo cp "$1" "$2"
  21. fi
  22. }
  23. # sudo npm doesn't work right, so this is a workaround
  24. function npm_call(){
  25. TMPDIR="/tmp/tmp_npm_prefix"
  26. if [[ -d "$TMPDIR" ]]; then
  27. rm -rf $TMPDIR
  28. fi
  29. mkdir $TMPDIR
  30. NPM_PREFIX="$(npm config get prefix)"
  31. npm config set prefix $TMPDIR
  32. npm "$@"
  33. npm config set prefix "$NPM_PREFIX"
  34. echo "Moving files to $NPM_PREFIX"
  35. for i in $(ls -A $TMPDIR); do
  36. cprec "$TMPDIR/$i" "$NPM_PREFIX/$i"
  37. done
  38. rm -rf $TMPDIR
  39. }
  40. function wekan_repo_check(){
  41. git_remotes="$(git remote show 2>/dev/null)"
  42. res=""
  43. for i in $git_remotes; do
  44. res="$(git remote get-url $i | sed 's/.*wekan\/wekan.*/wekan\/wekan/')"
  45. if [[ "$res" == "wekan/wekan" ]]; then
  46. break
  47. fi
  48. done
  49. if [[ "$res" != "wekan/wekan" ]]; then
  50. echo "$PWD is not a wekan repository"
  51. exit;
  52. fi
  53. }
  54. echo
  55. PS3='Please enter your choice: '
  56. options=("Install Wekan dependencies" "Build Wekan" "Quit")
  57. select opt in "${options[@]}"
  58. do
  59. case $opt in
  60. "Install Wekan dependencies")
  61. if [[ "$OSTYPE" == "linux-gnu" ]]; then
  62. echo "Linux";
  63. # Debian, Ubuntu, Mint
  64. sudo apt-get install -y build-essential gcc g++ make git curl wget
  65. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  66. sudo apt-get install -y nodejs
  67. elif [[ "$OSTYPE" == "darwin"* ]]; then
  68. echo "macOS";
  69. pause '1) Install XCode 2) Install Node 8.x from https://nodejs.org/en/ 3) Press [Enter] key to continue.'
  70. elif [[ "$OSTYPE" == "cygwin" ]]; then
  71. # POSIX compatibility layer and Linux environment emulation for Windows
  72. echo "TODO: Add Cygwin";
  73. exit;
  74. elif [[ "$OSTYPE" == "msys" ]]; then
  75. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  76. echo "TODO: Add msys on Windows";
  77. exit;
  78. elif [[ "$OSTYPE" == "win32" ]]; then
  79. # I'm not sure this can happen.
  80. echo "TODO: Add Windows";
  81. exit;
  82. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  83. echo "TODO: Add FreeBSD";
  84. exit;
  85. else
  86. echo "Unknown"
  87. echo ${OSTYPE}
  88. exit;
  89. fi
  90. ## Latest npm with Meteor 1.6
  91. npm_call -g install npm
  92. npm_call -g install node-gyp
  93. # Latest fibers for Meteor 1.6
  94. npm_call -g install fibers@2.0.0
  95. # Install Meteor, if it's not yet installed
  96. curl https://install.meteor.com | bash
  97. break
  98. ;;
  99. "Build Wekan")
  100. echo "Building Wekan."
  101. wekan_repo_check
  102. rm -rf packages/kadira-flow-router packages/meteor-useraccounts-core packages/meteor-accounts-cas packages/wekan-ldap packages/wekan-ldap packages/wekan-scrfollbar packages/meteor-accounts-oidc packages/markdown
  103. mkdir packages
  104. cd packages
  105. git clone --depth 1 -b master https://github.com/wekan/flow-router.git kadira-flow-router
  106. git clone --depth 1 -b master https://github.com/meteor-useraccounts/core.git meteor-useraccounts-core
  107. git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-cas.git
  108. git clone --depth 1 -b master https://github.com/wekan/wekan-ldap.git
  109. git clone --depth 1 -b master https://github.com/wekan/wekan-scrollbar.git
  110. git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-oidc.git
  111. git clone --depth 1 -b master --recurse-submodules https://github.com/wekan/markdown.git
  112. mv meteor-accounts-oidc/packages/switch_accounts-oidc wekan_accounts-oidc
  113. mv meteor-accounts-oidc/packages/switch_oidc wekan_oidc
  114. rm -rf meteor-accounts-oidc
  115. if [[ "$OSTYPE" == "darwin"* ]]; then
  116. echo "sed at macOS";
  117. sed -i '' 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  118. else
  119. echo "sed at ${OSTYPE}"
  120. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  121. fi
  122. cd ..
  123. rm -rf node_modules
  124. meteor npm install
  125. rm -rf .build
  126. meteor build .build --directory
  127. cp -f fix-download-unicode/cfs_access-point.txt .build/bundle/programs/server/packages/cfs_access-point.js
  128. #Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
  129. #https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
  130. #https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
  131. #cd ~/repos/wekan/.build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt
  132. #rm -rf node_modules/bcrypt
  133. #meteor npm install bcrypt
  134. cd .build/bundle/programs/server
  135. rm -rf node_modules
  136. meteor npm install
  137. #meteor npm install bcrypt
  138. cd ../../../..
  139. echo Done.
  140. break
  141. ;;
  142. "Quit")
  143. break
  144. ;;
  145. *) echo invalid option;;
  146. esac
  147. done