diff --git a/packages/sysutils/busybox/package.mk b/packages/sysutils/busybox/package.mk index 601074ca24..871e95065e 100644 --- a/packages/sysutils/busybox/package.mk +++ b/packages/sysutils/busybox/package.mk @@ -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 diff --git a/packages/sysutils/systemd/scripts/systemd-machine-id-setup b/packages/sysutils/systemd/scripts/systemd-machine-id-setup index 4f7142d183..cdfd3d6392 100755 --- a/packages/sysutils/systemd/scripts/systemd-machine-id-setup +++ b/packages/sysutils/systemd/scripts/systemd-machine-id-setup @@ -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 . +# along with LibreELEC. If not, see . ################################################################################ -# 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