rebuild-wekan.sh 11 KB

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