2018-05-16 15:03:20 +00:00
|
|
|
#!/bin/bash
|
2018-07-16 20:45:36 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
|
|
|
|
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
|
2011-10-19 08:24:34 +02:00
|
|
|
|
2018-05-16 15:03:20 +00:00
|
|
|
# remove old machine-id file
|
|
|
|
|
[[ -f "/storage/.cache/machine-id" ]] && rm /storage/.cache/machine-id
|
2013-08-08 03:43:08 +02:00
|
|
|
|
2018-05-16 15:03:20 +00:00
|
|
|
# test systemd-machine-id exists and is 32 hex chars or generate a new uuid
|
|
|
|
|
MACHINEID="$(cat /storage/.cache/systemd-machine-id 2>/dev/null)"
|
|
|
|
|
[ "${#MACHINEID}" != "32" ] && MACHINEID=
|
|
|
|
|
[[ "${MACHINEID//[a-f0-9]/}" != "" ]] && MACHINEID=
|
|
|
|
|
[ -z "${MACHINEID}" ] && MACHINEID=$(/usr/bin/dbus-uuidgen)
|
2011-10-19 08:24:34 +02:00
|
|
|
|
2021-05-27 17:48:07 +02:00
|
|
|
# For first boot detection systemd may have overmounted the file
|
|
|
|
|
umount /storage/.cache/systemd-machine-id >/dev/null 2>&1
|
|
|
|
|
|
2018-05-16 15:03:20 +00:00
|
|
|
# persist uuid
|
|
|
|
|
mkdir -p /storage/.cache
|
|
|
|
|
echo "$MACHINEID" > /storage/.cache/systemd-machine-id
|