Browse Source

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.
Jonathan Warner 7 months ago
parent
commit
22a9e783c9
4 changed files with 33 additions and 11 deletions
  1. 6 6
      rebuild-wekan.sh
  2. 22 4
      start-wekan.sh
  3. 3 1
      status-wekan.sh
  4. 2 0
      stop-wekan.sh

+ 6 - 6
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
 		;;

+ 22 - 4
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

+ 3 - 1
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"

+ 2 - 0
stop-wekan.sh

@@ -1 +1,3 @@
+#!/bin/sh
+
 pkill -f "node main.js"