From 222ffd25047d12699d01e68c1008b787cec5b273 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 21 Oct 2016 16:02:32 +0000 Subject: [PATCH] Fix uninstallation. --- packages/base/all/vendor-config-onl/PKG.yml | 2 +- .../all/vendor-config-onl/src/sbin/uninstall | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 packages/base/all/vendor-config-onl/src/sbin/uninstall diff --git a/packages/base/all/vendor-config-onl/PKG.yml b/packages/base/all/vendor-config-onl/PKG.yml index 3dc90ee8..0c0727bb 100644 --- a/packages/base/all/vendor-config-onl/PKG.yml +++ b/packages/base/all/vendor-config-onl/PKG.yml @@ -17,6 +17,6 @@ packages: - src/boot.d : /etc/boot.d - src/bin : /usr/bin - src/lib : /lib/vendor-config/onl - + - src/sbin : /sbin changelog: Changes diff --git a/packages/base/all/vendor-config-onl/src/sbin/uninstall b/packages/base/all/vendor-config-onl/src/sbin/uninstall new file mode 100755 index 00000000..8fe4742e --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/sbin/uninstall @@ -0,0 +1,59 @@ +#!/bin/sh +set -e + +uninstall_x86_64() +{ + # + # Set ONIE boot selection to uninstall + # + mkdir -p /mnt/onie-boot + mount -L ONIE-BOOT /mnt/onie-boot > /dev/null 2>&1 + + if [ "$1" = "factory" ]; then + /mnt/onie-boot/onie/tools/bin/onie-boot-mode -o uninstall + else + /mnt/onie-boot/onie/tools/bin/onie-boot-mode -o install + fi + + umount /mnt/onie-boot + + # + # Select ONIE as the boot default + # + onl-mounts mount boot --rw + echo "set default=ONIE" >> /mnt/onl/boot/grub/grub.cfg + onl-mounts mount boot +} + +uninstall_uboot() +{ + if [ "$1" = "factory" ]; then + fw_setenv onie_boot_reason uninstall + else + fw_setenv nos_bootcmd echo + fi +} + +uninstall() +{ + case `uname -m` in + x86_64) + uninstall_x86_64 $1 + ;; + ppc|armv7l) + uninstall_uboot $1 + ;; + *) + echo "Uninstall for the current architecture is not implemented. This is a bug." + exit 1 + ;; + esac +} + +############################################################ + +uninstall $1 +echo "The NOS will be removed at the next reboot." +exit 0 + +