From 0005b3b5a2e7ceddedaff4196104d185c76d2923 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 2 Feb 2016 06:38:03 +0100
Subject: [PATCH] autoupdater: stop non-essential services before downloading
 the image

---
 .../usr/lib/autoupdater/abort.d/60gluon-alfred   |  6 ++++++
 .../lib/autoupdater/download.d/40gluon-alfred    |  6 ++++++
 .../files/lib/gluon/autoupdater/lib.sh           | 16 ++++++++++++++++
 .../lib/autoupdater/abort.d/90gluon-autoupdater  |  9 +++++++++
 .../autoupdater/download.d/10gluon-autoupdater   |  9 +++++++++
 .../usr/lib/autoupdater/abort.d/80gluon-radvd    |  6 ++++++
 .../usr/lib/autoupdater/download.d/20gluon-radvd |  6 ++++++
 .../usr/lib/autoupdater/abort.d/50gluon-respondd |  7 +++++++
 .../lib/autoupdater/download.d/50gluon-respondd  |  7 +++++++
 .../autoupdater/abort.d/70gluon-status-page-api  |  7 +++++++
 .../download.d/30gluon-status-page-api           |  7 +++++++
 11 files changed, 86 insertions(+)
 create mode 100755 package/gluon-alfred/files/usr/lib/autoupdater/abort.d/60gluon-alfred
 create mode 100755 package/gluon-alfred/files/usr/lib/autoupdater/download.d/40gluon-alfred
 create mode 100644 package/gluon-autoupdater/files/lib/gluon/autoupdater/lib.sh
 create mode 100755 package/gluon-autoupdater/files/usr/lib/autoupdater/abort.d/90gluon-autoupdater
 create mode 100755 package/gluon-autoupdater/files/usr/lib/autoupdater/download.d/10gluon-autoupdater
 create mode 100755 package/gluon-radvd/files/usr/lib/autoupdater/abort.d/80gluon-radvd
 create mode 100755 package/gluon-radvd/files/usr/lib/autoupdater/download.d/20gluon-radvd
 create mode 100755 package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd
 create mode 100755 package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd
 create mode 100755 package/gluon-status-page-api/files/usr/lib/autoupdater/abort.d/70gluon-status-page-api
 create mode 100755 package/gluon-status-page-api/files/usr/lib/autoupdater/download.d/30gluon-status-page-api

diff --git a/package/gluon-alfred/files/usr/lib/autoupdater/abort.d/60gluon-alfred b/package/gluon-alfred/files/usr/lib/autoupdater/abort.d/60gluon-alfred
new file mode 100755
index 000000000..621c09a09
--- /dev/null
+++ b/package/gluon-alfred/files/usr/lib/autoupdater/abort.d/60gluon-alfred
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+start_enabled alfred
diff --git a/package/gluon-alfred/files/usr/lib/autoupdater/download.d/40gluon-alfred b/package/gluon-alfred/files/usr/lib/autoupdater/download.d/40gluon-alfred
new file mode 100755
index 000000000..19427620d
--- /dev/null
+++ b/package/gluon-alfred/files/usr/lib/autoupdater/download.d/40gluon-alfred
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+stop alfred
diff --git a/package/gluon-autoupdater/files/lib/gluon/autoupdater/lib.sh b/package/gluon-autoupdater/files/lib/gluon/autoupdater/lib.sh
new file mode 100644
index 000000000..36ddd9719
--- /dev/null
+++ b/package/gluon-autoupdater/files/lib/gluon/autoupdater/lib.sh
@@ -0,0 +1,16 @@
+# Library to be sourced by download.d/abort.d scripts
+
+
+stop() {
+        if [ -x /etc/init.d/$1 ]; then
+                echo "Stopping $1..."
+                /etc/init.d/$1 stop
+        fi
+}
+
+start_enabled() {
+        if [ -x /etc/init.d/$1 ] && /etc/init.d/$1 enabled; then
+                echo "Starting $1..."
+                /etc/init.d/$1 start
+        fi
+}
diff --git a/package/gluon-autoupdater/files/usr/lib/autoupdater/abort.d/90gluon-autoupdater b/package/gluon-autoupdater/files/usr/lib/autoupdater/abort.d/90gluon-autoupdater
new file mode 100755
index 000000000..19def9505
--- /dev/null
+++ b/package/gluon-autoupdater/files/usr/lib/autoupdater/abort.d/90gluon-autoupdater
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+start_enabled cron
+start_enabled haveged
+start_enabled micrond
+start_enabled sysntpd
diff --git a/package/gluon-autoupdater/files/usr/lib/autoupdater/download.d/10gluon-autoupdater b/package/gluon-autoupdater/files/usr/lib/autoupdater/download.d/10gluon-autoupdater
new file mode 100755
index 000000000..6f2268fed
--- /dev/null
+++ b/package/gluon-autoupdater/files/usr/lib/autoupdater/download.d/10gluon-autoupdater
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+stop cron
+stop haveged
+stop micrond
+stop sysntpd
diff --git a/package/gluon-radvd/files/usr/lib/autoupdater/abort.d/80gluon-radvd b/package/gluon-radvd/files/usr/lib/autoupdater/abort.d/80gluon-radvd
new file mode 100755
index 000000000..5784fa5fc
--- /dev/null
+++ b/package/gluon-radvd/files/usr/lib/autoupdater/abort.d/80gluon-radvd
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+start_enabled gluon-radvd
diff --git a/package/gluon-radvd/files/usr/lib/autoupdater/download.d/20gluon-radvd b/package/gluon-radvd/files/usr/lib/autoupdater/download.d/20gluon-radvd
new file mode 100755
index 000000000..ade506166
--- /dev/null
+++ b/package/gluon-radvd/files/usr/lib/autoupdater/download.d/20gluon-radvd
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+stop gluon-radvd
diff --git a/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd b/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd
new file mode 100755
index 000000000..1a5e14e42
--- /dev/null
+++ b/package/gluon-respondd/files/usr/lib/autoupdater/abort.d/50gluon-respondd
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+start_enabled batman-adv-visdata
+start_enabled gluon-respondd
diff --git a/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd b/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd
new file mode 100755
index 000000000..05f56fae9
--- /dev/null
+++ b/package/gluon-respondd/files/usr/lib/autoupdater/download.d/50gluon-respondd
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+stop gluon-respondd
+stop batman-adv-visdata
diff --git a/package/gluon-status-page-api/files/usr/lib/autoupdater/abort.d/70gluon-status-page-api b/package/gluon-status-page-api/files/usr/lib/autoupdater/abort.d/70gluon-status-page-api
new file mode 100755
index 000000000..9afbeec5c
--- /dev/null
+++ b/package/gluon-status-page-api/files/usr/lib/autoupdater/abort.d/70gluon-status-page-api
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+start_enabled sse-multiplexd
+start_enabled uhttpd
diff --git a/package/gluon-status-page-api/files/usr/lib/autoupdater/download.d/30gluon-status-page-api b/package/gluon-status-page-api/files/usr/lib/autoupdater/download.d/30gluon-status-page-api
new file mode 100755
index 000000000..7db1d6b7d
--- /dev/null
+++ b/package/gluon-status-page-api/files/usr/lib/autoupdater/download.d/30gluon-status-page-api
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. /lib/gluon/autoupdater/lib.sh
+
+
+stop uhttpd
+stop sse-multiplexd
-- 
GitLab