From d4e75165dde4977f8354170d4367a4c5213b122c Mon Sep 17 00:00:00 2001 From: Jonathan Warner Date: Mon, 12 Nov 2018 03:49:13 -0700 Subject: Revised rebuild-wekan.sh to work correctly with npm The use of sudo npm is bugged. This is a workaround patch. Fixes issue #2001 --- rebuild-wekan.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/rebuild-wekan.sh b/rebuild-wekan.sh index c1f9f4a0..03586489 100755 --- a/rebuild-wekan.sh +++ b/rebuild-wekan.sh @@ -10,6 +10,55 @@ function pause(){ read -p "$*" } +function cprec(){ + if [[ -d "$1" ]]; then + if [[ ! -d "$2" ]]; then + sudo mkdir -p "$2" + fi + + for i in $(ls -A "$1"); do + cprec "$1/$i" "$2/$i" + done + else + sudo cp "$1" "$2" + fi +} + +# sudo npm doesn't work right, so this is a workaround +function npm_call(){ + TMPDIR="/tmp/tmp_npm_prefix" + if [[ -d "$TMPDIR" ]]; then + rm -rf $TMPDIR + fi + mkdir $TMPDIR + NPM_PREFIX="$(npm config get prefix)" + npm config set prefix $TMPDIR + npm "$@" + npm config set prefix "$NPM_PREFIX" + + echo "Moving files to $NPM_PREFIX" + for i in $(ls -A $TMPDIR); do + cprec "$TMPDIR/$i" "$NPM_PREFIX/$i" + done + rm -rf $TMPDIR +} + +function wekan_repo_check(){ + git_remotes="$(git remote show 2>/dev/null)" + res="" + for i in $git_remotes; do + res="$(git remote get-url $i | sed 's/.*wekan\/wekan.*/wekan\/wekan/')" + if [[ "$res" == "wekan/wekan" ]]; then + break + fi + done + + if [[ "$res" != "wekan/wekan" ]]; then + echo "$PWD is not a wekan repository" + exit; + fi +} + echo PS3='Please enter your choice: ' options=("Install Wekan dependencies" "Build Wekan" "Quit") @@ -24,7 +73,7 @@ do if [ "$(grep -Ei 'buntu|mint' /etc/*release)" ]; then sudo apt install -y build-essential git curl wget # sudo apt -y install nodejs npm -# sudo npm -g install n +# npm_call -g install n # sudo n 8.12.0 fi @@ -70,10 +119,10 @@ do fi ## Latest npm with Meteor 1.6 - sudo npm -g install npm - sudo npm -g install node-gyp + npm_call -g install npm + npm_call -g install node-gyp # Latest fibers for Meteor 1.6 - sudo npm -g install fibers@2.0.0 + npm_call -g install fibers@2.0.0 # Install Meteor, if it's not yet installed curl https://install.meteor.com | bash # mkdir ~/repos -- cgit v1.2.3-1-g7c22 From 22a9e783c99b56db688793ad3736bd1e3fc20f40 Mon Sep 17 00:00:00 2001 From: Jonathan Warner Date: Mon, 12 Nov 2018 03:51:44 -0700 Subject: Revised shell scripts to check for wekan repository The scripts used to assume that ~/repos/wekan was a local wekan repo. They now check that the active directory is a wekan repo. --- rebuild-wekan.sh | 12 ++++++------ start-wekan.sh | 26 ++++++++++++++++++++++---- status-wekan.sh | 4 +++- stop-wekan.sh | 2 ++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/rebuild-wekan.sh b/rebuild-wekan.sh index 03586489..42364515 100755 --- a/rebuild-wekan.sh +++ b/rebuild-wekan.sh @@ -134,10 +134,10 @@ do ;; "Build Wekan") echo "Building Wekan." - cd ~/repos/wekan + wekan_repo_check rm -rf packages - mkdir -p ~/repos/wekan/packages - cd ~/repos/wekan/packages + mkdir packages + cd packages git clone --depth 1 -b master https://github.com/wekan/flow-router.git kadira-flow-router git clone --depth 1 -b master https://github.com/meteor-useraccounts/core.git meteor-useraccounts-core git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-cas.git @@ -150,7 +150,7 @@ do sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' ~/repos/wekan/packages/meteor-useraccounts-core/package.js fi - cd ~/repos/wekan + cd .. rm -rf node_modules meteor npm install rm -rf .build @@ -162,11 +162,11 @@ do #cd ~/repos/wekan/.build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt #rm -rf node_modules/bcrypt #meteor npm install bcrypt - cd ~/repos/wekan/.build/bundle/programs/server + cd .build/bundle/programs/server rm -rf node_modules meteor npm install #meteor npm install bcrypt - cd ~/repos + cd ../../../.. echo Done. break ;; diff --git a/start-wekan.sh b/start-wekan.sh index 6006fb92..3584ac6d 100755 --- a/start-wekan.sh +++ b/start-wekan.sh @@ -1,7 +1,25 @@ -# If you want to restart even on crash, uncomment while and done lines. +#!/bin/bash + +function wekan_repo_check(){ + git_remotes="$(git remote show 2>/dev/null)" + res="" + for i in $git_remotes; do + res="$(git remote get-url $i | sed 's/.*wekan\/wekan.*/wekan\/wekan/')" + if [[ "$res" == "wekan/wekan" ]]; then + break + fi + done + if [[ "$res" != "wekan/wekan" ]]; then + echo "$PWD is not a wekan repository" + exit; + fi +} + +# If you want to restart even on crash, uncomment while and done lines. #while true; do - cd ~/repos/wekan/.build/bundle + wekan_repo_check + cd .build/bundle #export MONGO_URL='mongodb://127.0.0.1:27019/wekantest' #export MONGO_URL='mongodb://127.0.0.1:27019/wekan' export MONGO_URL='mongodb://127.0.0.1:27019/wekantest' @@ -18,6 +36,6 @@ export PORT=2000 #export LDAP_ENABLE=true node main.js - # & >> ~/repos/wekan.log - cd ~/repos + # & >> ../../wekan.log + cd ../.. #done diff --git a/status-wekan.sh b/status-wekan.sh index 2b815f4a..3b0f232d 100755 --- a/status-wekan.sh +++ b/status-wekan.sh @@ -1,5 +1,7 @@ +#!/bin/sh + echo -e "\nWekan node.js:" ps aux | grep "node main.js" | grep -v grep echo -e "\nWekan mongodb:" ps aux | grep mongo | grep -v grep -echo -e "\nWekan logs are at /home/wekan/repos/wekan.log\n" +echo -e "\nWekan logs are at $PWD/wekan.log\n" diff --git a/stop-wekan.sh b/stop-wekan.sh index a7adf03b..8865a83a 100755 --- a/stop-wekan.sh +++ b/stop-wekan.sh @@ -1 +1,3 @@ +#!/bin/sh + pkill -f "node main.js" -- cgit v1.2.3-1-g7c22