rebuild-wekan.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 git curl wget
  65. curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
  66. elif [[ "$OSTYPE" == "darwin"* ]]; then
  67. echo "macOS";
  68. pause '1) Install XCode 2) Install Node 8.x from https://nodejs.org/en/ 3) Press [Enter] key to continue.'
  69. elif [[ "$OSTYPE" == "cygwin" ]]; then
  70. # POSIX compatibility layer and Linux environment emulation for Windows
  71. echo "TODO: Add Cygwin";
  72. exit;
  73. elif [[ "$OSTYPE" == "msys" ]]; then
  74. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  75. echo "TODO: Add msys on Windows";
  76. exit;
  77. elif [[ "$OSTYPE" == "win32" ]]; then
  78. # I'm not sure this can happen.
  79. echo "TODO: Add Windows";
  80. exit;
  81. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  82. echo "TODO: Add FreeBSD";
  83. exit;
  84. else
  85. echo "Unknown"
  86. echo ${OSTYPE}
  87. exit;
  88. fi
  89. ## Latest npm with Meteor 1.6
  90. npm_call -g install npm
  91. npm_call -g install node-gyp
  92. # Latest fibers for Meteor 1.6
  93. npm_call -g install fibers@2.0.0
  94. # Install Meteor, if it's not yet installed
  95. curl https://install.meteor.com | bash
  96. break
  97. ;;
  98. "Build Wekan")
  99. echo "Building Wekan."
  100. wekan_repo_check
  101. rm -rf packages
  102. mkdir packages
  103. cd packages
  104. git clone --depth 1 -b master https://github.com/wekan/flow-router.git kadira-flow-router
  105. git clone --depth 1 -b master https://github.com/meteor-useraccounts/core.git meteor-useraccounts-core
  106. git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-cas.git
  107. git clone --depth 1 -b master https://github.com/wekan/wekan-ldap.git
  108. git clone --depth 1 -b master https://github.com/wekan/wekan-scrollbar.git
  109. if [[ "$OSTYPE" == "darwin"* ]]; then
  110. echo "sed at macOS";
  111. sed -i '' 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  112. else
  113. echo "sed at ${OSTYPE}"
  114. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  115. fi
  116. cd ..
  117. rm -rf node_modules
  118. meteor npm install
  119. rm -rf .build
  120. meteor build .build --directory
  121. cp -f fix-download-unicode/cfs_access-point.txt .build/bundle/programs/server/packages/cfs_access-point.js
  122. #Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
  123. #https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
  124. #https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
  125. #cd ~/repos/wekan/.build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt
  126. #rm -rf node_modules/bcrypt
  127. #meteor npm install bcrypt
  128. cd .build/bundle/programs/server
  129. rm -rf node_modules
  130. meteor npm install
  131. #meteor npm install bcrypt
  132. cd ../../../..
  133. echo Done.
  134. break
  135. ;;
  136. "Quit")
  137. break
  138. ;;
  139. *) echo invalid option;;
  140. esac
  141. done