#!/bin/sh
# lite-time-date-helper — privileged wrapper for timedatectl operations.
# Pinned by /usr/share/polkit-1/actions/org.linuxlite.lite-time-date.policy
# so the polkit auth dialog gets Linux Lite branding and auth_admin_keep.
# Always uses timedatectl — never edits /etc/localtime, /etc/timezone, or
# any zoneinfo files directly.

set -e

export PATH=/usr/bin:/bin:/usr/sbin:/sbin
export LANG=C.UTF-8
export LC_ALL=C.UTF-8

while [ "$#" -gt 0 ]; do
    case "$1" in
        --tz)
            [ -n "$2" ] || { echo "missing value for --tz" >&2; exit 2; }
            timedatectl set-timezone "$2"
            shift 2
            ;;
        --ntp)
            case "$2" in
                yes|no) ;;
                *) echo "--ntp expects yes or no" >&2; exit 2 ;;
            esac
            timedatectl set-ntp "$2"
            shift 2
            ;;
        *)
            echo "unknown argument: $1" >&2
            exit 2
            ;;
    esac
done

exit 0
