Browse Source

Merge branch 'options' of matteozeccolimarazzini/zoomctl into master

Matteo Zeccoli Marazzini 2 years ago
parent
commit
dff9cfa134
1 changed files with 36 additions and 14 deletions
  1. 36 14
      zoomctl

+ 36 - 14
zoomctl

@@ -1,19 +1,41 @@
 #!/bin/bash
 
-# Start zoom user session on zoom machine
-# Cinnamon for the zoom user is configured to
-# automatically start the Zoom conference with aula.calcolo
-ssh zoom@zoom startx &
+case "${1}" in
+"start")
+	# Start zoom user session on zoom machine
+	# Cinnamon for the zoom user is configured to
+	# automatically start the Zoom conference with aula.calcolo
+	ssh zoom@zoom startx &
 
-# Start xfreerdp and keep it alive restarting it every 30 seconds if necessary,
-# for 3h 35m (i.e. 430 times)
-for i in $(seq 430); do
-	/usr/local/bin/xfreerdpctl start -a & > /dev/null
-	sleep 30s > /dev/null
-done
+	# Start xfreerdp and keep it alive restarting it every 30 seconds if necessary.
+	# This is an infinite loop: stop it with zoomctl stop.
+	while true; do
+		/usr/local/bin/xfreerdpctl start -a & > /dev/null
+		sleep 30s > /dev/null
+	done
+	;;
 
-# Stop xfreerdp
-/usr/local/bin/xfreerdpctl stop -a
+"stop")
+	# Stop zoomctl
+	kill $(ps a | grep -v grep | grep "zoomctl start" | cut --field=2 --delim=' ')
 
-# Stop zoom
-ssh zoom@zoom pkill -u zoom
+	# Stop xfreerdp
+	/usr/local/bin/xfreerdpctl stop -a
+
+	# Stop zoom
+	ssh zoom@zoom pkill -u zoom
+	;;
+
+"status")
+	if ps a | grep -v grep | grep --quiet "zoomctl start"; then
+		echo "zoomctl is running"
+	else
+		echo "zoomctl is not running"
+	fi
+	;;
+
+*)
+	echo "Usage: ${0} {start|stop|status}." >&2
+	exit 1
+	;;
+esac