rebuild-wekan.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #!/bin/bash
  2. echo "Recommended for development: Newest Ubuntu or Debian amd64, directly to SSD disk or dual boot, not VM. Works fast."
  3. echo "Note1: If you use other locale than en_US.UTF-8 , you need to additionally install en_US.UTF-8"
  4. echo " with 'sudo dpkg-reconfigure locales' , so that MongoDB works correctly."
  5. echo " You can still use any other locale as your main locale."
  6. echo "Note2: Console output is also logged to ../wekan-log.txt"
  7. #Below script installs newest node 8.x for Debian/Ubuntu/Mint.
  8. function pause(){
  9. read -p "$*"
  10. }
  11. echo
  12. PS3='Please enter your choice: '
  13. options=("Install Wekan dependencies" "Build Wekan" "Run Meteor for dev on http://localhost:4000" "Run Meteor for dev on http://localhost:4000 with trace warnings, and warnings using old Meteor API that will not exist in Meteor 3.0" "Run Meteor for dev on http://localhost:4000 with bundle visualizer" "Run Meteor for dev on http://CURRENT-IP-ADDRESS:4000" "Run Meteor for dev on http://CURRENT-IP-ADDRESS:4000 with MONGO_URL=mongodb://127.0.0.1:27019/wekan" "Run Meteor for dev on http://CUSTOM-IP-ADDRESS:PORT" "Save Meteor dependency chain to ../meteor-deps.txt" "Quit")
  14. select opt in "${options[@]}"
  15. do
  16. case $opt in
  17. "Install Wekan dependencies")
  18. if [[ "$OSTYPE" == "linux-gnu" ]]; then
  19. echo "Linux";
  20. # Debian, Ubuntu, Mint
  21. sudo apt install -y build-essential gcc g++ make git curl wget p7zip-full zip unzip unp npm p7zip-full
  22. #curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
  23. #sudo apt-get install -y nodejs
  24. #sudo apt-get install -y npm
  25. # Volta Node and NPM install manager, made with Rust https://volta.sh
  26. # Volta uses home directory also with "npm -g install", no sudo needed.
  27. # Volta install script is broken, so using n.
  28. #curl https://get.volta.sh | bash
  29. #export VOLTA_HOME="$HOME/.volta"
  30. #export PATH="$VOLTA_HOME/bin:$PATH"
  31. #volta install node@14
  32. # npm nodejs
  33. #curl -0 -L https://npmjs.org/install.sh | sudo sh
  34. #sudo chown -R $(id -u):$(id -g) $HOME/.npm
  35. sudo npm -g install n
  36. # Using custom Node.js mirror with n Node.js version manager
  37. # - Custom source: https://github.com/tj/n#custom-source
  38. # - sudo -E uses existing environment variables, so that this can be used in build script:
  39. # https://github.com/tj/n/issues/584#issuecomment-523640742
  40. export N_NODE_MIRROR=https://github.com/wekan/node-v14-esm/releases/download
  41. sudo -E n 14.21.4
  42. sudo npm -g uninstall node-pre-gyp
  43. # Latest fibers for Meteor sudo mkdir -p /usr/local/lib/node_modules/fibers/.node-gyp sudo npm -g install fibers
  44. sudo npm -g install @mapbox/node-pre-gyp
  45. # Install Meteor, if it's not yet installed
  46. sudo npm -g install meteor --unsafe-perm
  47. #sudo chown -R $(id -u):$(id -g) $HOME/.npm $HOME/.meteor
  48. elif [[ "$OSTYPE" == "darwin"* ]]; then
  49. echo "macOS";
  50. brew install npm
  51. npm -g install n
  52. export N_NODE_MIRROR=https://github.com/wekan/node-v14-esm/releases/download
  53. n 14.21.4
  54. npm -g uninstall node-pre-gyp
  55. npm -g install @mapbox/node-pre-gyp
  56. npm -g install meteor
  57. elif [[ "$OSTYPE" == "cygwin" ]]; then
  58. # POSIX compatibility layer and Linux environment emulation for Windows
  59. echo "TODO: Add Cygwin";
  60. exit;
  61. elif [[ "$OSTYPE" == "msys" ]]; then
  62. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  63. echo "TODO: Add msys on Windows";
  64. exit;
  65. elif [[ "$OSTYPE" == "win32" ]]; then
  66. # I'm not sure this can happen.
  67. echo "TODO: Add Windows";
  68. exit;
  69. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  70. echo "TODO: Add FreeBSD";
  71. exit;
  72. else
  73. echo "Unknown"
  74. echo ${OSTYPE}
  75. exit;
  76. fi
  77. break
  78. ;;
  79. "Build Wekan")
  80. echo "Building Wekan."
  81. #if [[ "$OSTYPE" == "darwin"* ]]; then
  82. # echo "sed at macOS";
  83. # sed -i '' 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  84. #else
  85. # echo "sed at ${OSTYPE}"
  86. # sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  87. #fi
  88. #cd ..
  89. #sudo chown -R $(id -u):$(id -g) $HOME/.npm $HOME/.meteor
  90. rm -rf .build/bundle node_modules .meteor/local .build
  91. meteor npm install
  92. meteor build .build --directory --platforms=web.browser
  93. rm -rf .build/bundle/programs/web.browser.legacy
  94. (cd .build/bundle/programs/server && rm -rf node_modules && chmod u+w *.json && meteor npm install)
  95. (cd .build/bundle/programs/server/node_modules/fibers && node build.js)
  96. (cd .build/bundle/programs/server/npm/node_modules/meteor/accounts-password && meteor npm remove bcrypt && meteor npm install bcrypt)
  97. # Cleanup
  98. cd .build/bundle
  99. find . -type d -name '*-garbage*' | xargs rm -rf
  100. find . -name '*phantom*' | xargs rm -rf
  101. find . -name '.*.swp' | xargs rm -f
  102. find . -name '*.swp' | xargs rm -f
  103. cd ../..
  104. # Add fibers multi arch
  105. #cd .build/bundle/programs/server/node_modules/fibers/bin
  106. #curl https://releases.wekan.team/fibers-multi.7z -o fibers-multi.7z
  107. #7z x fibers-multi.7z
  108. #rm fibers-multi.7z
  109. #cd ../../../../../../..
  110. echo Done.
  111. break
  112. ;;
  113. "Run Meteor for dev on http://localhost:4000")
  114. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  115. #---------------------------------------------------------------------
  116. # Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  117. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  118. WRITABLE_PATH=.. WITH_API=true RICHER_CARD_COMMENT_EDITOR=false ROOT_URL=http://localhost:4000 meteor run --exclude-archs web.browser.legacy,web.cordova --port 4000 2>&1 | tee ../wekan-log.txt
  119. #---------------------------------------------------------------------
  120. break
  121. ;;
  122. "Run Meteor for dev on http://localhost:4000 with trace warnings, and warnings using old Meteor API that will not exist in Meteor 3.0")
  123. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  124. #---------------------------------------------------------------------
  125. # Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  126. WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings" WRITABLE_PATH=.. WITH_API=true RICHER_CARD_COMMENT_EDITOR=false ROOT_URL=http://localhost:4000 meteor run --exclude-archs web.browser.legacy,web.cordova --port 4000 2>&1 | tee ../wekan-log.txt
  127. #---------------------------------------------------------------------
  128. break
  129. ;;
  130. "Run Meteor for dev on http://localhost:4000 with bundle visualizer")
  131. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  132. #---------------------------------------------------------------------
  133. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  134. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  135. WRITABLE_PATH=.. WITH_API=true RICHER_CARD_COMMENT_EDITOR=false ROOT_URL=http://localhost:4000 meteor run --exclude-archs web.browser.legacy,web.cordova --port 4000 --extra-packages bundle-visualizer --production 2>&1 | tee ../wekan-log.txt
  136. #---------------------------------------------------------------------
  137. break
  138. ;;
  139. "Run Meteor for dev on http://CURRENT-IP-ADDRESS:4000")
  140. if [[ "$OSTYPE" == "darwin"* ]]; then
  141. IPADDRESS=$(ifconfig | grep broadcast | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  142. else
  143. IPADDRESS=$(ip a | grep 'noprefixroute' | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  144. fi
  145. echo "Your IP address is $IPADDRESS"
  146. #---------------------------------------------------------------------
  147. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  148. #---------------------------------------------------------------------
  149. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  150. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  151. WRITABLE_PATH=.. WITH_API=true RICHER_CARD_COMMENT_EDITOR=false ROOT_URL=http://$IPADDRESS:4000 meteor run --exclude-archs web.browser.legacy,web.cordova --port 4000 2>&1 | tee ../wekan-log.txt
  152. #---------------------------------------------------------------------
  153. break
  154. ;;
  155. "Run Meteor for dev on http://CURRENT-IP-ADDRESS:4000 with MONGO_URL=mongodb://127.0.0.1:27019/wekan")
  156. if [[ "$OSTYPE" == "darwin"* ]]; then
  157. IPADDRESS=$(ifconfig | grep broadcast | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  158. else
  159. IPADDRESS=$(ip a | grep 'noprefixroute' | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  160. fi
  161. echo "Your IP address is $IPADDRESS"
  162. #---------------------------------------------------------------------
  163. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  164. #---------------------------------------------------------------------
  165. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  166. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  167. MONGO_URL=mongodb://127.0.0.1:27019/wekan WRITABLE_PATH=.. WITH_API=true RICHER_CARD_COMMENT_EDITOR=false ROOT_URL=http://$IPADDRESS:4000 meteor run --exclude-archs web.browser.legacy,web.cordova --port 4000 2>&1 | tee ../wekan-log.txt
  168. #---------------------------------------------------------------------
  169. break
  170. ;;
  171. "Run Meteor for dev on http://CUSTOM-IP-ADDRESS:PORT")
  172. ip address
  173. echo "From above list, what is your IP address?"
  174. read IPADDRESS
  175. echo "On what port you would like to run Wekan?"
  176. read PORT
  177. echo "ROOT_URL=http://$IPADDRESS:$PORT"
  178. #---------------------------------------------------------------------
  179. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  180. #---------------------------------------------------------------------
  181. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  182. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  183. WRITABLE_PATH=.. WITH_API=true RICHER_CARD_COMMENT_EDITOR=false ROOT_URL=http://$IPADDRESS:$PORT meteor run --exclude-archs web.browser.legacy,web.cordova --port $PORT 2>&1 | tee ../wekan-log.txt
  184. #---------------------------------------------------------------------
  185. break
  186. ;;
  187. "Save Meteor dependency chain to ../meteor-deps.txt")
  188. meteor list --tree > ../meteor-deps.txt
  189. echo "Saved Meteor dependency chain to ../meteor-deps.txt"
  190. #---------------------------------------------------------------------
  191. break
  192. ;;
  193. "Quit")
  194. break
  195. ;;
  196. *) echo invalid option;;
  197. esac
  198. done