* [PATCH 1/5] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE
2014-07-16 20:59 [PATCH 0/5] Various fixes and improvements to initscripts Ben Shelton
@ 2014-07-16 20:59 ` Ben Shelton
2014-07-16 22:10 ` Saul Wold
2014-07-16 20:59 ` [PATCH 2/5] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Ben Shelton @ 2014-07-16 20:59 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
busybox sysctl may lack the "-q" setting, so simulate it with redirects.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 3b5a47f..5211824 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -36,7 +36,12 @@ if [ -f "${SYSCTL_CONF}" ]
then
if [ -x "/sbin/sysctl" ]
then
- /sbin/sysctl -p "${SYSCTL_CONF}"
+ # busybox sysctl does not support -q
+ VERBOSE_REDIR="1>/dev/null"
+ if [ "${VERBOSE}" != "no" ]; then
+ VERBOSE_REDIR="1>&1"
+ fi
+ eval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIR
else
echo "To have ${SYSCTL_CONF} applied during boot, install package <procps>."
fi
--
2.0.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/5] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE
2014-07-16 20:59 ` [PATCH 1/5] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
@ 2014-07-16 22:10 ` Saul Wold
2014-07-17 15:02 ` Ben Shelton
0 siblings, 1 reply; 10+ messages in thread
From: Saul Wold @ 2014-07-16 22:10 UTC (permalink / raw)
To: Ben Shelton, openembedded-core
On 07/16/2014 01:59 PM, Ben Shelton wrote:
> From: Richard Tollerton <rich.tollerton@ni.com>
>
> busybox sysctl may lack the "-q" setting, so simulate it with redirects.
>
> Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
> Signed-off-by: Ben Shelton <ben.shelton@ni.com>
> ---
> meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 3b5a47f..5211824 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -36,7 +36,12 @@ if [ -f "${SYSCTL_CONF}" ]
> then
> if [ -x "/sbin/sysctl" ]
> then
> - /sbin/sysctl -p "${SYSCTL_CONF}"
> + # busybox sysctl does not support -q
Will this work if procps's sysctl is used instead, I think it will but
wanted to verify it.
Sau!
> + VERBOSE_REDIR="1>/dev/null"
> + if [ "${VERBOSE}" != "no" ]; then
> + VERBOSE_REDIR="1>&1"
> + fi
> + eval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIR
> else
> echo "To have ${SYSCTL_CONF} applied during boot, install package <procps>."
> fi
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 1/5] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE
2014-07-16 22:10 ` Saul Wold
@ 2014-07-17 15:02 ` Ben Shelton
0 siblings, 0 replies; 10+ messages in thread
From: Ben Shelton @ 2014-07-17 15:02 UTC (permalink / raw)
To: Saul Wold; +Cc: openembedded-core
On 07/16, Saul Wold wrote:
> On 07/16/2014 01:59 PM, Ben Shelton wrote:
> >From: Richard Tollerton <rich.tollerton@ni.com>
> >
> >busybox sysctl may lack the "-q" setting, so simulate it with redirects.
> >
> >Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
> >Signed-off-by: Ben Shelton <ben.shelton@ni.com>
> >---
> > meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> >diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> >index 3b5a47f..5211824 100755
> >--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> >+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> >@@ -36,7 +36,12 @@ if [ -f "${SYSCTL_CONF}" ]
> > then
> > if [ -x "/sbin/sysctl" ]
> > then
> >- /sbin/sysctl -p "${SYSCTL_CONF}"
> >+ # busybox sysctl does not support -q
>
> Will this work if procps's sysctl is used instead, I think it will
> but wanted to verify it.
>
> Sau!
>
Yes, it will work. I just installed the procps package on an ARM target
and verified that the output is as expected for both settings of
VERBOSE.
Best,
Ben
> >+ VERBOSE_REDIR="1>/dev/null"
> >+ if [ "${VERBOSE}" != "no" ]; then
> >+ VERBOSE_REDIR="1>&1"
> >+ fi
> >+ eval /sbin/sysctl -p "${SYSCTL_CONF}" $VERBOSE_REDIR
> > else
> > echo "To have ${SYSCTL_CONF} applied during boot, install package <procps>."
> > fi
> >
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/5] initscripts: save /etc/timestamp with seconds accuracy
2014-07-16 20:59 [PATCH 0/5] Various fixes and improvements to initscripts Ben Shelton
2014-07-16 20:59 ` [PATCH 1/5] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
@ 2014-07-16 20:59 ` Ben Shelton
2014-07-16 22:05 ` Saul Wold
2014-07-16 20:59 ` [PATCH 3/5] initscripts: parametrize random seed file location Ben Shelton
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Ben Shelton @ 2014-07-16 20:59 UTC (permalink / raw)
To: openembedded-core
From: Blair Elliott <blair.elliott@ni.com>
Currently, /etc/timestamp is saved with minutes accuracy. To increase
the accuracy, modify the save-rtc.sh and bootmisc.sh scripts to save and
read /etc/timestamp respectively with seconds accuracy.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 +++--
meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
index 5211824..ccc7f9f 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
@@ -66,10 +66,11 @@ fi
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
if test -e /etc/timestamp
then
- SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M`
+ SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
read TIMESTAMP < /etc/timestamp
if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
- date -u ${TIMESTAMP#????}${TIMESTAMP%????????}
+ # format the timestamp as date expects it (2m2d2H2M4Y.2S)
+ date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
fi
fi
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh b/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
index 1f804e2..b038fc5 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
@@ -10,4 +10,4 @@
### END INIT INFO
# Update the timestamp
-date -u +%4Y%2m%2d%2H%2M > /etc/timestamp
+date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp
--
2.0.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 2/5] initscripts: save /etc/timestamp with seconds accuracy
2014-07-16 20:59 ` [PATCH 2/5] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
@ 2014-07-16 22:05 ` Saul Wold
2014-07-17 15:00 ` Ben Shelton
0 siblings, 1 reply; 10+ messages in thread
From: Saul Wold @ 2014-07-16 22:05 UTC (permalink / raw)
To: Ben Shelton, openembedded-core
On 07/16/2014 01:59 PM, Ben Shelton wrote:
> From: Blair Elliott <blair.elliott@ni.com>
>
> Currently, /etc/timestamp is saved with minutes accuracy. To increase
> the accuracy, modify the save-rtc.sh and bootmisc.sh scripts to save and
> read /etc/timestamp respectively with seconds accuracy.
>
We also initialize it in the image.bbclass, you may want to tweak that one.
Since we deal with readonly it's possible it won't get updated after the
image creation.
Sau!
> Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
> Signed-off-by: Ben Shelton <ben.shelton@ni.com>
> ---
> meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh | 5 +++--
> meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh | 2 +-
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> index 5211824..ccc7f9f 100755
> --- a/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/bootmisc.sh
> @@ -66,10 +66,11 @@ fi
> test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh start
> if test -e /etc/timestamp
> then
> - SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M`
> + SYSTEMDATE=`date -u +%4Y%2m%2d%2H%2M%2S`
> read TIMESTAMP < /etc/timestamp
> if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then
> - date -u ${TIMESTAMP#????}${TIMESTAMP%????????}
> + # format the timestamp as date expects it (2m2d2H2M4Y.2S)
> + date -u ${TIMESTAMP:4:8}${TIMESTAMP:0:4}.${TIMESTAMP:(-2)}
> test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop
> fi
> fi
> diff --git a/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh b/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
> index 1f804e2..b038fc5 100644
> --- a/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
> +++ b/meta/recipes-core/initscripts/initscripts-1.0/save-rtc.sh
> @@ -10,4 +10,4 @@
> ### END INIT INFO
>
> # Update the timestamp
> -date -u +%4Y%2m%2d%2H%2M > /etc/timestamp
> +date -u +%4Y%2m%2d%2H%2M%2S > /etc/timestamp
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 2/5] initscripts: save /etc/timestamp with seconds accuracy
2014-07-16 22:05 ` Saul Wold
@ 2014-07-17 15:00 ` Ben Shelton
0 siblings, 0 replies; 10+ messages in thread
From: Ben Shelton @ 2014-07-17 15:00 UTC (permalink / raw)
To: Saul Wold; +Cc: openembedded-core
On 07/16, Saul Wold wrote:
> On 07/16/2014 01:59 PM, Ben Shelton wrote:
> >From: Blair Elliott <blair.elliott@ni.com>
> >
> >Currently, /etc/timestamp is saved with minutes accuracy. To increase
> >the accuracy, modify the save-rtc.sh and bootmisc.sh scripts to save and
> >read /etc/timestamp respectively with seconds accuracy.
> >
>
> We also initialize it in the image.bbclass, you may want to tweak that one.
>
> Since we deal with readonly it's possible it won't get updated after
> the image creation.
>
> Sau!
>
Good catch -- I'll make the fix and resubmit the patchset.
Thanks,
Ben
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/5] initscripts: parametrize random seed file location
2014-07-16 20:59 [PATCH 0/5] Various fixes and improvements to initscripts Ben Shelton
2014-07-16 20:59 ` [PATCH 1/5] initscripts: bootmisc.sh: Make sysctl -p honor VERBOSE Ben Shelton
2014-07-16 20:59 ` [PATCH 2/5] initscripts: save /etc/timestamp with seconds accuracy Ben Shelton
@ 2014-07-16 20:59 ` Ben Shelton
2014-07-16 20:59 ` [PATCH 4/5] initscripts: Use current date as an additional source of entropy Ben Shelton
2014-07-16 20:59 ` [PATCH 5/5] initscripts: make hostname.sh coreutils-compatible Ben Shelton
4 siblings, 0 replies; 10+ messages in thread
From: Ben Shelton @ 2014-07-16 20:59 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
Currently, the random seed file location is hardcoded to
/var/lib/urandom/random-seed. Refactor it to a parameter
(RANDOM_SEED_FILE) so the file location is defined in only one place.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/urandom | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/urandom b/meta/recipes-core/initscripts/initscripts-1.0/urandom
index eb3a7c3..a0549de 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/urandom
+++ b/meta/recipes-core/initscripts/initscripts-1.0/urandom
@@ -12,6 +12,9 @@
### END INIT INFO
test -c /dev/urandom || exit 0
+
+RANDOM_SEED_FILE=/var/lib/urandom/random-seed
+
. /etc/default/rcS
case "$1" in
@@ -19,13 +22,13 @@ case "$1" in
test "$VERBOSE" != no && echo "Initializing random number generator..."
# Load and then save 512 bytes,
# which is the size of the entropy pool
- if test -f /var/lib/urandom/random-seed
+ if test -f "$RANDOM_SEED_FILE"
then
- cat /var/lib/urandom/random-seed >/dev/urandom
+ cat "$RANDOM_SEED_FILE" >/dev/urandom
fi
- rm -f /var/lib/urandom/random-seed
+ rm -f "$RANDOM_SEED_FILE"
umask 077
- dd if=/dev/urandom of=/var/lib/urandom/random-seed count=1 \
+ dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
>/dev/null 2>&1 || echo "urandom start: failed."
umask 022
;;
@@ -34,7 +37,7 @@ case "$1" in
# see documentation in linux/drivers/char/random.c
test "$VERBOSE" != no && echo "Saving random seed..."
umask 077
- dd if=/dev/urandom of=/var/lib/urandom/random-seed count=1 \
+ dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
>/dev/null 2>&1 || echo "urandom stop: failed."
;;
*)
--
2.0.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] initscripts: Use current date as an additional source of entropy
2014-07-16 20:59 [PATCH 0/5] Various fixes and improvements to initscripts Ben Shelton
` (2 preceding siblings ...)
2014-07-16 20:59 ` [PATCH 3/5] initscripts: parametrize random seed file location Ben Shelton
@ 2014-07-16 20:59 ` Ben Shelton
2014-07-16 20:59 ` [PATCH 5/5] initscripts: make hostname.sh coreutils-compatible Ben Shelton
4 siblings, 0 replies; 10+ messages in thread
From: Ben Shelton @ 2014-07-16 20:59 UTC (permalink / raw)
To: openembedded-core
From: Ken Sharp <ken.sharp@ni.com>
If the seed file is empty or does not exist, the date is an extremely
poor backup source of entropy, but it is better than nothing.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/urandom | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/urandom b/meta/recipes-core/initscripts/initscripts-1.0/urandom
index a0549de..ec4ef61 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/urandom
+++ b/meta/recipes-core/initscripts/initscripts-1.0/urandom
@@ -20,12 +20,11 @@ RANDOM_SEED_FILE=/var/lib/urandom/random-seed
case "$1" in
start|"")
test "$VERBOSE" != no && echo "Initializing random number generator..."
- # Load and then save 512 bytes,
- # which is the size of the entropy pool
- if test -f "$RANDOM_SEED_FILE"
- then
- cat "$RANDOM_SEED_FILE" >/dev/urandom
- fi
+ # Load and then save 512 bytes, which is the size of the entropy
+ # pool. Also load the current date, in case the seed file is
+ # empty.
+ ( date +%s.%N; [ -f "$RANDOM_SEED_FILE" ] && cat "$RANDOM_SEED_FILE" ) \
+ >/dev/urandom
rm -f "$RANDOM_SEED_FILE"
umask 077
dd if=/dev/urandom of=$RANDOM_SEED_FILE count=1 \
--
2.0.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 5/5] initscripts: make hostname.sh coreutils-compatible
2014-07-16 20:59 [PATCH 0/5] Various fixes and improvements to initscripts Ben Shelton
` (3 preceding siblings ...)
2014-07-16 20:59 ` [PATCH 4/5] initscripts: Use current date as an additional source of entropy Ben Shelton
@ 2014-07-16 20:59 ` Ben Shelton
4 siblings, 0 replies; 10+ messages in thread
From: Ben Shelton @ 2014-07-16 20:59 UTC (permalink / raw)
To: openembedded-core
From: Richard Tollerton <rich.tollerton@ni.com>
inetutils and busybox hostname utils support `hostname -F`; coreutils
hostname doesn't. So just use `cat` instead.
Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
meta/recipes-core/initscripts/initscripts-1.0/hostname.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh b/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh
index 78fb91c..95287cc 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/hostname.sh
@@ -16,7 +16,7 @@ fi
# Busybox hostname doesn't support -b so we need implement it on our own
if [ -f /etc/hostname ];then
- hostname -F /etc/hostname
+ hostname `cat /etc/hostname`
elif [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" -o ! -z "`echo $HOSTNAME | sed -n '/^[0-9]*\.[0-9].*/p'`" ] ; then
hostname localhost
fi
--
2.0.1
^ permalink raw reply related [flat|nested] 10+ messages in thread