mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
commit
857fd73aec
@ -224,11 +224,13 @@ enable_service () {
|
||||
local target_dir=$INSTALL
|
||||
|
||||
[ -f "$target_dir/$unit_dir/$unit" ] || exit 1
|
||||
[ -z "$target" ] && target=`grep '^WantedBy' $target_dir/$unit_dir/$unit | cut -f2 -d=`
|
||||
|
||||
if [ -n "$target" ]; then
|
||||
mkdir -p ${target_dir}/$unit_dir/${target}.wants
|
||||
ln -sf ../${unit} ${target_dir}/$unit_dir/${target}.wants/
|
||||
if [ -z "$target" ] ; then
|
||||
for target in `grep '^WantedBy' $target_dir/$unit_dir/$unit | cut -f2 -d=` ; do
|
||||
if [ -n "$target" ]; then
|
||||
mkdir -p ${target_dir}/$unit_dir/${target}.wants
|
||||
ln -sf ../${unit} ${target_dir}/$unit_dir/${target}.wants/
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
50
packages/sysutils/entropy/package.mk
Normal file
50
packages/sysutils/entropy/package.mk
Normal file
@ -0,0 +1,50 @@
|
||||
################################################################################
|
||||
# This file is part of OpenELEC - http://www.openelec.tv
|
||||
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
|
||||
#
|
||||
# OpenELEC 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,
|
||||
# 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/>.
|
||||
################################################################################
|
||||
|
||||
PKG_NAME="entropy"
|
||||
PKG_VERSION="0"
|
||||
PKG_REV="1"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE=""
|
||||
PKG_URL=""
|
||||
PKG_DEPENDS_TARGET="toolchain"
|
||||
PKG_PRIORITY="optional"
|
||||
PKG_SECTION="system"
|
||||
PKG_SHORTDESC="A simple way to add entropy at boot"
|
||||
PKG_LONGDESC="A simple way to add entropy at boot"
|
||||
|
||||
PKG_IS_ADDON="no"
|
||||
PKG_AUTORECONF="no"
|
||||
|
||||
make_target(){
|
||||
:
|
||||
}
|
||||
|
||||
makeinstall_target() {
|
||||
mkdir -p $INSTALL/usr/lib/entropy
|
||||
cp add-entropy $INSTALL/usr/lib/entropy
|
||||
cp add-random-at-shutdown $INSTALL/usr/lib/entropy
|
||||
|
||||
chmod +x $INSTALL/usr/lib/entropy/*
|
||||
}
|
||||
|
||||
post_install() {
|
||||
enable_service add-entropy.service
|
||||
enable_service add-random-at-shutdown.service
|
||||
}
|
24
packages/sysutils/entropy/sources/add-entropy
Normal file
24
packages/sysutils/entropy/sources/add-entropy
Normal file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import struct
|
||||
|
||||
RNDADDENTROPY = 0x40085203
|
||||
import fcntl
|
||||
|
||||
def add_entropy(fd, data):
|
||||
add = struct.pack('ii', len(data)*8, len(data)) + data
|
||||
fcntl.ioctl(fd, RNDADDENTROPY, add)
|
||||
|
||||
if not os.path.isfile("/storage/.cache/random.data"):
|
||||
os.system("dd if=/dev/urandom of=/storage/.cache/random.data count=4 >/dev/null")
|
||||
|
||||
cache=os.open("/storage/.cache/random.data", os.O_RDONLY)
|
||||
|
||||
rnd=os.open("/dev/random", os.O_RDWR)
|
||||
|
||||
while True:
|
||||
data=os.read(cache, 512)
|
||||
if len(data) == 0:
|
||||
break
|
||||
add_entropy(rnd, data)
|
2
packages/sysutils/entropy/sources/add-random-at-shutdown
Normal file
2
packages/sysutils/entropy/sources/add-random-at-shutdown
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
dd if=/dev/urandom of=/storage/.cache/random.data count=4
|
13
packages/sysutils/entropy/system.d/add-entropy.service
Normal file
13
packages/sysutils/entropy/system.d/add-entropy.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Add random entropy from file
|
||||
DefaultDependencies=no
|
||||
After=systemd-tmpfiles-setup.service
|
||||
Before=systemd-udevd.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/entropy/add-entropy
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Save random entropy at shutdown
|
||||
DefaultDependencies=no
|
||||
Before=systemd-poweroff.service systemd-reboot.service systemd-halt.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/entropy/add-random-at-shutdown
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=poweroff.target reboot.target halt.target
|
@ -23,7 +23,7 @@ PKG_ARCH="any"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="http://www.freedesktop.org/wiki/Software/systemd"
|
||||
PKG_URL="https://github.com/systemd/systemd/archive/v$PKG_VERSION.tar.gz"
|
||||
PKG_DEPENDS_TARGET="toolchain libcap kmod util-linux"
|
||||
PKG_DEPENDS_TARGET="toolchain libcap kmod util-linux entropy"
|
||||
PKG_PRIORITY="required"
|
||||
PKG_SECTION="system"
|
||||
PKG_SHORTDESC="systemd: a system and session manager"
|
||||
|
Loading…
x
Reference in New Issue
Block a user