aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/package-update
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-10-01 11:51:47 +0200
committerClément Bénier <clement.benier@iot.bzh>2018-10-01 11:57:48 +0200
commit2e17a524738982174794370a2bb609872608a5ac (patch)
tree91eda98e97032493cf614a8a35a262500c916d99 /scripts/package-update
parent95293a7ee22cfff9c49a19bd7ae205529d812fa9 (diff)
update xds-server package in dockersandbox/benierc/xds-server-update-pkg
scripts/package-update: bash scripts to update xds-server package in docker monitor updates: default time is 24h, a update is tried at startup api/v1: 2 new requests: - get(updates): return various information about xds-server packages - post(updates): update xds-server packages Change-Id: I34613be916bb29c2cce13ca1cce1e384365872f7 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'scripts/package-update')
-rwxr-xr-xscripts/package-update/getXdsServerPackage31
-rwxr-xr-xscripts/package-update/restartXdsServer15
-rwxr-xr-xscripts/package-update/updateXdsServerPackage31
3 files changed, 77 insertions, 0 deletions
diff --git a/scripts/package-update/getXdsServerPackage b/scripts/package-update/getXdsServerPackage
new file mode 100755
index 0000000..e54d09e
--- /dev/null
+++ b/scripts/package-update/getXdsServerPackage
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+XDSSERVER="xds-server"
+PACKAGE_NAME="agl-${XDSSERVER}"
+
+#test if sudoers with NOPASSWD
+sudo -l | grep NOPASSWD &> /dev/null
+if [ ! $? -eq 0 ]; then
+ exit 1
+fi
+
+function getUpdateDebian() {
+ local policy="/tmp/policy"
+ sudo apt-get update &> /dev/null
+ apt-cache policy ${PACKAGE_NAME} > ${policy}
+ cat $policy | grep "Installed"
+ cat $policy | grep "Candidate"
+ rm -f $policy
+}
+
+if [ -f /etc/os-release ]; then
+ source /etc/os-release
+fi
+
+case $ID in
+ "debian")
+ getUpdateDebian;;
+ *)
+ exit 1;;
+esac
+
diff --git a/scripts/package-update/restartXdsServer b/scripts/package-update/restartXdsServer
new file mode 100755
index 0000000..40dfee9
--- /dev/null
+++ b/scripts/package-update/restartXdsServer
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+XDSSERVER="xds-server"
+
+function systemdRestartXdsServer() {
+ systemctl --user daemon-reload
+ systemctl --user restart ${XDSSERVER}
+ if [ ! $? -eq 0 ]; then
+ echo "Cannot restart $XDSSERVER"
+ exit 1
+ fi
+}
+
+systemdRestartXdsServer
+exit 0 \ No newline at end of file
diff --git a/scripts/package-update/updateXdsServerPackage b/scripts/package-update/updateXdsServerPackage
new file mode 100755
index 0000000..4f638b8
--- /dev/null
+++ b/scripts/package-update/updateXdsServerPackage
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+XDSSERVER="xds-server"
+PACKAGE_NAME="agl-${XDSSERVER}"
+
+#test if sudoers with NOPASSWD
+sudo -l | grep NOPASSWD
+if [ ! $? -eq 0 ]; then
+ exit 1
+fi
+
+
+function checkUpdateDebian() {
+ sudo apt-get update
+ apt list --upgradable | grep ${PACKAGE_NAME}
+ if [ $? -eq 0 ]; then
+ sudo apt-get install ${PACKAGE_NAME}
+ fi
+}
+
+if [ -f /etc/os-release ]; then
+ source /etc/os-release
+fi
+
+case $ID in
+ "debian")
+ res=$(checkUpdateDebian);;
+ *)
+ exit 1;;
+esac
+