From c086fc55cca4483aaff1234e71fdb89f4e522c20 Mon Sep 17 00:00:00 2001
From: Dirk Sarpe <dirk.sarpe@idiv.de>
Date: Fri, 27 Sep 2019 15:19:33 +0200
Subject: [PATCH] add version checker for shiny server

---
 shiny_version_check.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100755 shiny_version_check.sh

diff --git a/shiny_version_check.sh b/shiny_version_check.sh
new file mode 100755
index 0000000..0c3e04e
--- /dev/null
+++ b/shiny_version_check.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+# check for new shiny version and download it if necessary
+
+#set -x
+#trap read debug
+
+rawstring=$(curl -s https://rstudio.com/products/shiny/download-server/ubuntu/ |grep "wget.*amd64.deb")
+prefix="<code>$ "
+suffix="</code><br />"
+noprefix=${rawstring#$prefix}
+nosuffix=${noprefix%$suffix}
+dlcommand="$nosuffix -q -P /home/monitoring/"
+cur_version=$(shiny-server --version | head -n1 | cut -d "v" -f 3)
+avail_version=$(cut -d "-" -f 4 <<< "$dlcommand")
+
+if [ "$avail_version" != "$cur_version" ]
+  then
+    if [ ! -e /home/monitoring/shiny-server-"${avail_version}"-amd64.deb ]
+      then
+        eval "$dlcommand"
+    fi
+    echo "Shiny version $avail_version available (in use $cur_version)"
+fi
+
-- 
GitLab