rebuild-wekan.sh 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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" "Show Meteor dependency chain" "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. sudo n 14.21.3
  37. sudo npm -g install npm
  38. #sudo npm -g install npm
  39. ## Latest npm with Meteor 2.2
  40. sudo npm -g uninstall node-pre-gyp
  41. sudo npm -g install @mapbox/node-pre-gyp
  42. # Latest fibers for Meteor 2.2
  43. #sudo mkdir -p /usr/local/lib/node_modules/fibers/.node-gyp
  44. #sudo npm -g install fibers
  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. pause '1) Install XCode 2) Install Node 14.x from https://nodejs.org/en/ 3) Press [Enter] key to continue.'
  51. elif [[ "$OSTYPE" == "cygwin" ]]; then
  52. # POSIX compatibility layer and Linux environment emulation for Windows
  53. echo "TODO: Add Cygwin";
  54. exit;
  55. elif [[ "$OSTYPE" == "msys" ]]; then
  56. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  57. echo "TODO: Add msys on Windows";
  58. exit;
  59. elif [[ "$OSTYPE" == "win32" ]]; then
  60. # I'm not sure this can happen.
  61. echo "TODO: Add Windows";
  62. exit;
  63. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  64. echo "TODO: Add FreeBSD";
  65. exit;
  66. else
  67. echo "Unknown"
  68. echo ${OSTYPE}
  69. exit;
  70. fi
  71. break
  72. ;;
  73. "Build Wekan")
  74. echo "Building Wekan."
  75. #if [[ "$OSTYPE" == "darwin"* ]]; then
  76. # echo "sed at macOS";
  77. # sed -i '' 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  78. #else
  79. # echo "sed at ${OSTYPE}"
  80. # sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js
  81. #fi
  82. #cd ..
  83. #sudo chown -R $(id -u):$(id -g) $HOME/.npm $HOME/.meteor
  84. rm -rf .build/bundle node_modules .meteor/local .build
  85. meteor npm install
  86. meteor build .build --directory --platforms=web.browser
  87. rm -rf .build/bundle/programs/web.browser.legacy
  88. (cd .build/bundle/programs/server && rm -rf node_modules && chmod u+w *.json && meteor npm install)
  89. (cd .build/bundle/programs/server/node_modules/fibers && node build.js)
  90. (cd .build/bundle/programs/server/npm/node_modules/meteor/accounts-password && meteor npm remove bcrypt && meteor npm install bcrypt)
  91. # Cleanup
  92. cd .build/bundle
  93. find . -type d -name '*-garbage*' | xargs rm -rf
  94. find . -name '*phantom*' | xargs rm -rf
  95. find . -name '.*.swp' | xargs rm -f
  96. find . -name '*.swp' | xargs rm -f
  97. cd ../..
  98. # Add fibers multi arch
  99. #cd .build/bundle/programs/server/node_modules/fibers/bin
  100. #curl https://releases.wekan.team/fibers-multi.7z -o fibers-multi.7z
  101. #7z x fibers-multi.7z
  102. #rm fibers-multi.7z
  103. #cd ../../../../../../..
  104. echo Done.
  105. break
  106. ;;
  107. "Run Meteor for dev on http://localhost:4000")
  108. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  109. #---------------------------------------------------------------------
  110. # Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  111. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  112. 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
  113. #---------------------------------------------------------------------
  114. break
  115. ;;
  116. "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")
  117. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  118. #---------------------------------------------------------------------
  119. # Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  120. 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
  121. #---------------------------------------------------------------------
  122. break
  123. ;;
  124. "Run Meteor for dev on http://localhost:4000 with bundle visualizer")
  125. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  126. #---------------------------------------------------------------------
  127. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  128. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  129. 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
  130. #---------------------------------------------------------------------
  131. break
  132. ;;
  133. "Run Meteor for dev on http://CURRENT-IP-ADDRESS:4000")
  134. if [[ "$OSTYPE" == "darwin"* ]]; then
  135. IPADDRESS=$(ifconfig | grep broadcast | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  136. else
  137. IPADDRESS=$(ip a | grep 'noprefixroute' | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  138. fi
  139. echo "Your IP address is $IPADDRESS"
  140. #---------------------------------------------------------------------
  141. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  142. #---------------------------------------------------------------------
  143. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  144. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  145. 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
  146. #---------------------------------------------------------------------
  147. break
  148. ;;
  149. "Run Meteor for dev on http://CURRENT-IP-ADDRESS:4000 with MONGO_URL=mongodb://127.0.0.1:27019/wekan")
  150. if [[ "$OSTYPE" == "darwin"* ]]; then
  151. IPADDRESS=$(ifconfig | grep broadcast | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  152. else
  153. IPADDRESS=$(ip a | grep 'noprefixroute' | grep 'inet ' | cut -d: -f2 | awk '{ print $2}' | cut -d '/' -f 1 | grep '192.')
  154. fi
  155. echo "Your IP address is $IPADDRESS"
  156. #---------------------------------------------------------------------
  157. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  158. #---------------------------------------------------------------------
  159. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  160. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  161. 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
  162. #---------------------------------------------------------------------
  163. break
  164. ;;
  165. "Run Meteor for dev on http://CUSTOM-IP-ADDRESS:PORT")
  166. ip address
  167. echo "From above list, what is your IP address?"
  168. read IPADDRESS
  169. echo "On what port you would like to run Wekan?"
  170. read PORT
  171. echo "ROOT_URL=http://$IPADDRESS:$PORT"
  172. #---------------------------------------------------------------------
  173. #Not in use, could increase RAM usage: NODE_OPTIONS="--max_old_space_size=4096"
  174. #---------------------------------------------------------------------
  175. #Logging of terminal output to console and to ../wekan-log.txt at end of this line: 2>&1 | tee ../wekan-log.txt
  176. #WARN_WHEN_USING_OLD_API=true NODE_OPTIONS="--trace-warnings"
  177. 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
  178. #---------------------------------------------------------------------
  179. break
  180. ;;
  181. "Show Meteor dependency chain")
  182. meteor list --tree | more
  183. #---------------------------------------------------------------------
  184. break
  185. ;;
  186. "Quit")
  187. break
  188. ;;
  189. *) echo invalid option;;
  190. esac
  191. done