mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
systemd: change uuid generation
This commit is contained in:
parent
59788e2c1e
commit
a8026292bb
@ -159,7 +159,7 @@ makeinstall_target() {
|
||||
touch $INSTALL/etc/fstab
|
||||
|
||||
# /etc/machine-id, needed by systemd and dbus
|
||||
ln -sf /storage/.cache/machine-id $INSTALL/etc/machine-id
|
||||
ln -sf /storage/.cache/systemd-machine-id $INSTALL/etc/machine-id
|
||||
|
||||
# /etc/mtab is needed by udisks etc...
|
||||
ln -sf /proc/self/mounts $INSTALL/etc/mtab
|
||||
|
@ -1,42 +1,32 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
|
||||
# This file is part of LibreELEC - https://libreelec.tv
|
||||
# Copyright (C) 2018-present Team LibreELEC
|
||||
# Copyright (C) 2009-2014 Stephan Raue
|
||||
#
|
||||
# OpenELEC is free software: you can redistribute it and/or modify
|
||||
# LibreELEC 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 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# OpenELEC is distributed in the hope that it will be useful,
|
||||
# LibreELEC 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 OpenELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################################
|
||||
|
||||
# Creates a unique machine-id based on a local MAC address which persists over
|
||||
# reboots, upgrades and reinstallation. For systems with slow loading network
|
||||
# drivers (no MAC's available) dbus-uuidgen is used which persists over reboot
|
||||
# and upgrades but not reinstallation. If a MAC is used it is hashed to make it
|
||||
# anonymous. The machine-id is used by dbus and systemd, and to collect basic
|
||||
# active-installation statistics on LibreELEC users.
|
||||
# remove old machine-id file
|
||||
[[ -f "/storage/.cache/machine-id" ]] && rm /storage/.cache/machine-id
|
||||
|
||||
if [ -e "/storage/.cache/machine-id" ]; then
|
||||
MACHINEID=`cat /storage/.cache/machine-id`
|
||||
elif [ -e "/sys/class/net/eth0/address" ]; then
|
||||
MAC_ADDRESS=`cat /sys/class/net/eth0/address`
|
||||
elif [ -e "/sys/class/net/wlan0/address" ]; then
|
||||
MAC_ADDRESS=`cat /sys/class/net/wlan0/address`
|
||||
else
|
||||
MAC_ADDRESS=`/usr/bin/dbus-uuidgen`
|
||||
fi
|
||||
# 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)
|
||||
|
||||
if [ -z "$MACHINEID" ]; then
|
||||
MACHINEID=`echo $MAC_ADDRESS | md5sum | cut -f1 -d" "`
|
||||
mkdir -p /storage/.cache
|
||||
fi
|
||||
|
||||
echo "$MACHINEID" > /storage/.cache/machine-id
|
||||
# persist uuid
|
||||
mkdir -p /storage/.cache
|
||||
echo "$MACHINEID" > /storage/.cache/systemd-machine-id
|
||||
|
Loading…
x
Reference in New Issue
Block a user