diff options
author | Clément Bénier <clement.benier@iot.bzh> | 2018-10-01 11:51:47 +0200 |
---|---|---|
committer | Clément Bénier <clement.benier@iot.bzh> | 2018-10-01 11:57:48 +0200 |
commit | 2e17a524738982174794370a2bb609872608a5ac (patch) | |
tree | 91eda98e97032493cf614a8a35a262500c916d99 /scripts/package-update | |
parent | 95293a7ee22cfff9c49a19bd7ae205529d812fa9 (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-x | scripts/package-update/getXdsServerPackage | 31 | ||||
-rwxr-xr-x | scripts/package-update/restartXdsServer | 15 | ||||
-rwxr-xr-x | scripts/package-update/updateXdsServerPackage | 31 |
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 + |