Commit 2f6b236f authored by Štěpán Henek's avatar Štěpán Henek 🐻

turris-maintain: new package added

parent 0b0bfb88
#
## Copyright (C) 2017 CZ.NIC z.s.p.o. (http://www.nic.cz/)
#
## This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
# #
#
include $(TOPDIR)/rules.mk
PKG_NAME:=turris-maintain
PKG_VERSION:=1
PKG_MAINTAINER:=Stepan Henek <stepan.henek@nic.cz>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
TITLE:=$(PKG_NAME)
DEPENDS:=+uci
endef
define Package/$(PKG_NAME)/description
Contains a couple of scripts which are resposible for storing/restoring backups.
endef
# The built is empty. But as there's no makefile in the git repo, we need to
# override the default that runs "make".
define Build/Compile
true
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) files/config-backup.sh $(1)/usr/bin/maintain-config-backup
$(INSTALL_BIN) files/config-restore.sh $(1)/usr/bin/maintain-config-restore
$(INSTALL_BIN) files/reboot-needed.sh $(1)/usr/bin/maintain-reboot-needed
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
#!/bin/sh
# Copyright 2014,2016 CZ.NIC z.s.p.o. (http://www.nic.cz/)
#
# This file was part of NUCI configuration server.
#
# NUCI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUCI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUCI. If not, see <http://www.gnu.org/licenses/>.
set -e
DIR=/tmp/backup-$$
SRC=/etc/config
mkdir -p "$DIR"/etc
trap 'rm -rf "$DIR"' EXIT INT QUIT TERM ABRT
cd "$DIR"/etc
cp -a "$SRC" config
cd ..
uci -q -c "$DIR"/etc/config delete foris.auth.password || true
uci -c "$DIR"/etc/config commit
if [ -d /etc/updater ] ; then
# Back up the updater options (mostly lists of packages)
cp -a /etc/updater "$DIR"/etc
# But exclude things coming from packages not marked as configs
rm -rf "$DIR"/etc/updater/keys
rm -rf "$DIR"/etc/updater/hook_*
fi
uci -q -d '
' get backups.generate.dirs | while read dir ; do
DNAME=$(dirname "$dir")
mkdir -p "$DIR"/"$DNAME"
cp -a "$dir" "$DIR"/"$DNAME"/
done
tar c . | bzip2 -9c | base64
#!/bin/sh
# Copyright 2014, CZ.NIC z.s.p.o. (http://www.nic.cz/)
#
# This file was part of NUCI configuration server.
#
# NUCI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUCI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUCI. If not, see <http://www.gnu.org/licenses/>.
set -e
DIR=/tmp/restore-$$
mkdir -p "$DIR"
trap 'rm -rf "$DIR"' EXIT INT QUIT TERM ABRT
cd "$DIR"
base64 -d | bzip2 -cd | tar xp
# Here we have a special-case/hack for foris password. It was requested NOT to restore the
# password, as potentially confusing action. So we unpack the backed-up configuration,
# extract the current password and implant it into the configuration. Then we just copy
# the configs and overwrite the current ones.
PASSWD="$(uci -q -c "/etc/config" get foris.auth.password || echo -n)"
[ -z "$PASSWD" ] || uci -c "$DIR/etc/config" set foris.auth.password="$PASSWD"
uci -c "$DIR/etc/config" commit
cp -rf "$DIR/"* "/"
cd /
rm -rf "$DIR"
#!/bin/sh
# mark that a reboot is required for the router
# existence of this file will be verified from other program
touch /tmp/device-reboot-required
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment