#!/bin/bash
# -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# vim: et sts=4 sw=4

#  SPDX-License-Identifier: LGPL-2.1+
#
#  Copyright © 2019,2021 Collabora Ltd.
#  Copyright © 2019,2021 Valve Corporation.
#
#  This file is part of steamos-customizations.
#
#  steamos-customizations is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation; either version 2.1 of the License,
#  or (at your option) any later version.

set -eu;

# FIXME - get rid of basically all of this

case "${1:-}" in
    halt|poweroff) mode="shutdown";;
    reboot)        mode="reboot";;
    *)
        echo "Usage: $0 <halt|poweroff|reboot>" >&2
        exit 1
        ;;
esac

if [[ -f "/run/steamos/reboot-other" ]]
then
        mount /esp
        mount /efi
        trap "umount /esp; umount /efi" 0
        steamos-bootconf set-mode reboot-other
fi
