From f9a6c81c116e462e4abfd3973385f426eba70f7b Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Wed, 19 Jul 2017 00:47:40 +0200 Subject: [PATCH] rpcd-mod-attendedsysupgrade: add package add ubus call to perform a sysupgrade and acl file for the attended sysupgrade use case as well uci defaults. Package is a part of the GSoC 17 project implementing easy sysupgrade functionality. Signed-off-by: Paul Spooren --- utils/rpcd-mod-attendedsysupgrade/Makefile | 44 +++++++++++++++++++ .../files/attendedsysupgrade.acl | 26 +++++++++++ .../files/attendedsysupgrade.defaults | 13 ++++++ .../files/attendedsysupgrade.rpcd | 29 ++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 utils/rpcd-mod-attendedsysupgrade/Makefile create mode 100644 utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.acl create mode 100644 utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.defaults create mode 100755 utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.rpcd diff --git a/utils/rpcd-mod-attendedsysupgrade/Makefile b/utils/rpcd-mod-attendedsysupgrade/Makefile new file mode 100644 index 0000000000..ad9c8fca9f --- /dev/null +++ b/utils/rpcd-mod-attendedsysupgrade/Makefile @@ -0,0 +1,44 @@ +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=rpcd-mod-attendedsysupgrade +PKG_VERSION:=1 +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/rpcd-mod-attendedsysupgrade + SECTION:=utils + CATEGORY:=Base system + TITLE:=OpenWrt ubus RPC backend server (attendedsysupgrade) + MAINTAINER:=Paul Spooren + DEPENDS:=rpcd +cgi-io +rpcd-mod-packagelist +endef + +define Package/rpcd-mod-attendedsysupgrade/description + implements sysupgrade function with ubus + add uci settings and needed acls +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/rpcd-mod-attendedsysupgrade/install + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d/ + $(INSTALL_BIN) ./files/attendedsysupgrade.acl $(1)/usr/share/rpcd/acl.d/attendedsysupgrade.json + + $(INSTALL_DIR) $(1)/usr/libexec/rpcd/ + $(INSTALL_BIN) ./files/attendedsysupgrade $(1)/usr/libexec/rpcd/attendedsysupgrade + + $(INSTALL_DIR) $(1)/etc/uci-defaults/ + $(INSTALL_BIN) ./files/attendedsysupgrade.defaults $(1)/etc/uci-defaults/attendedsysupgrade +endef + +$(eval $(call BuildPackage,rpcd-mod-attendedsysupgrade)) diff --git a/utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.acl b/utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.acl new file mode 100644 index 0000000000..fdb05b7092 --- /dev/null +++ b/utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.acl @@ -0,0 +1,26 @@ +{ + "attendedsysupgrade": { + "description": "attended sysupgrade via rpcd", + "read": { + "ubus": { + "attendedsysupgrade": [ + "sysupgrade" + ], + "system": [ + "board" + ], + "uci": [ + "get" + ] + }, + "uci": [ + "*" + ] + }, + "write": { + "cgi-io": [ + "upload" + ] + } + } +} diff --git a/utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.defaults b/utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.defaults new file mode 100644 index 0000000000..772ec53f49 --- /dev/null +++ b/utils/rpcd-mod-attendedsysupgrade/files/attendedsysupgrade.defaults @@ -0,0 +1,13 @@ +#!/bin/sh + +[ -e /etc/config/attendedsysupgrade ] && exit 0 + +touch /etc/config/attendedsysupgrade + +uci -q batch <