[oe] [PATCH 3/7] Add custom init dropbear script and image for Visstrim_M10.

Javier Martin javier.martin at vista-silicon.com
Wed Feb 9 09:37:13 UTC 2011


Custom init script is needed since "/" is mounted as read-only
but "/etc" is mounted as read-write in Visstrim_M10 boards.
This case is not supported by default init script.

Signed-off-by: Javier Martin <javier.martin at vista-silicon.com>
---
 recipes/dropbear/dropbear/visstrim_m10/init |   91 +++++++++++++++++++++++++++
 recipes/images/micro-image-visstrim.bb      |   48 ++++++++++++++
 2 files changed, 139 insertions(+), 0 deletions(-)
 create mode 100644 recipes/dropbear/dropbear/visstrim_m10/init
 create mode 100644 recipes/images/micro-image-visstrim.bb

diff --git a/recipes/dropbear/dropbear/visstrim_m10/init b/recipes/dropbear/dropbear/visstrim_m10/init
new file mode 100644
index 0000000..72ca918
--- /dev/null
+++ b/recipes/dropbear/dropbear/visstrim_m10/init
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# Do not configure this file. Edit /etc/default/dropbear instead!
+#
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/dropbear
+NAME=dropbear
+DESC="Dropbear SSH server"
+PIDFILE=/var/run/dropbear.pid
+
+DROPBEAR_PORT=22
+DROPBEAR_EXTRA_ARGS=
+NO_START=0
+
+test ! -r /etc/default/dropbear || . /etc/default/dropbear
+test "$NO_START" = "0" || exit 0
+test -x "$DAEMON" || exit 0
+test ! -h /var/service/dropbear || exit 0
+
+# Allows comma-separated list of addresses/ports
+DROPBEAR_PORT=`echo $DROPBEAR_PORT | sed "s/,/ -p /g"`
+DROPBEAR_RSAKEY_DEFAULT="/etc/dropbear/dropbear_rsa_host_key"
+DROPBEAR_DSSKEY_DEFAULT="/etc/dropbear/dropbear_dss_host_key"
+
+
+test -z "$DROPBEAR_BANNER" || \
+  DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER"
+test -n "$DROPBEAR_RSAKEY" || \
+  DROPBEAR_RSAKEY=$DROPBEAR_RSAKEY_DEFAULT
+test -n "$DROPBEAR_DSSKEY" || \
+  DROPBEAR_DSSKEY=$DROPBEAR_DSSKEY_DEFAULT
+test -n "$DROPBEAR_KEYTYPES" || \
+  DROPBEAR_KEYTYPES="rsa"
+
+gen_keys() {
+for t in $DROPBEAR_KEYTYPES; do
+  case $t in
+    rsa)
+	if [ ! -f $DROPBEAR_RSAKEY ]; then
+	    echo "Creating $DESC RSA host key."
+	    dropbearkey -t rsa -f $DROPBEAR_RSAKEY
+	fi
+	;;
+    dsa)
+	if [ ! -f $DROPBEAR_DSSKEY ]; then
+	    echo "Creating $DESC DSA host key."
+	    dropbearkey -t dss -f $DROPBEAR_DSSKEY
+	fi
+	;;
+  esac
+done
+}
+
+case "$1" in
+  start)
+	gen_keys
+	echo -n "Starting $DESC: "
+	KEY_ARGS=""
+	test -f $DROPBEAR_DSSKEY && KEY_ARGS="$KEY_ARGS -d $DROPBEAR_DSSKEY"
+	test -f $DROPBEAR_RSAKEY && KEY_ARGS="$KEY_ARGS -r $DROPBEAR_RSAKEY"
+	start-stop-daemon -S -p $PIDFILE \
+	  -x "$DAEMON" -- $KEY_ARGS \
+	    -p $DROPBEAR_PORT $DROPBEAR_EXTRA_ARGS
+	echo "$NAME."
+	;;
+  stop)
+	echo -n "Stopping $DESC: "
+	start-stop-daemon -K -x "$DAEMON" -p $PIDFILE
+	echo "$NAME."
+	;;
+  restart|force-reload)
+	echo -n "Restarting $DESC: "
+	start-stop-daemon -K -x "$DAEMON" -p $PIDFILE
+	sleep 1
+	KEY_ARGS=""
+	test -f $DROPBEAR_DSSKEY && KEY_ARGS="$KEY_ARGS -d $DROPBEAR_DSSKEY"
+	test -f $DROPBEAR_RSAKEY && KEY_ARGS="$KEY_ARGS -r $DROPBEAR_RSAKEY"
+	start-stop-daemon -S -p $PIDFILE \
+	  -x "$DAEMON" -- $KEY_ARGS \
+	    -p $DROPBEAR_PORT $DROPBEAR_EXTRA_ARGS
+	echo "$NAME."
+	;;
+  *)
+	N=/etc/init.d/$NAME
+	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/recipes/images/micro-image-visstrim.bb b/recipes/images/micro-image-visstrim.bb
new file mode 100644
index 0000000..a53b076
--- /dev/null
+++ b/recipes/images/micro-image-visstrim.bb
@@ -0,0 +1,48 @@
+# micro-image-visstrim
+#
+# This image is based on micro-image and contains basic packages that are needed
+# to boot Visstrim_M10 boards and use jffs2+squashfs power cut safe schema.
+#
+# The image is tested to build and run succesfully with the following machines:
+#
+#	* visstrim_m10
+#
+# Maintainer: Javier Martin <javier.martin at vista-silicon.com>
+#
+
+DISTRO_SSH_DAEMON ?= "dropbear"
+
+# Install basic files only
+IMAGE_INSTALL = "base-files \
+		 visstrim-m10-utils \
+		 base-passwd \
+		 netbase \
+                 u-boot-utils \
+		 ${DISTRO_SSH_DAEMON}"
+
+IMAGE_LINGUAS = ""
+
+# Use busybox as login manager
+IMAGE_LOGIN_MANAGER = "busybox"
+
+# Include minimum init and init scripts
+IMAGE_DEV_MANAGER = ""
+IMAGE_INIT_MANAGER = "sysvinit sysvinit-pidof"
+IMAGE_INITSCRIPTS = ""
+
+inherit image
+
+fso_rootfs_postprocess() {
+	curdir=$PWD
+	cd ${DEPLOY_DIR_IMAGE}
+	mkdir -p tmp/config0
+	mkdir -p tmp/config1
+	cp -a ${IMAGE_ROOTFS}/etc tmp/config0/
+	cp -a ${IMAGE_ROOTFS}/etc tmp/config1/
+	mkfs.jffs2 -r ./tmp -s 0x800 -e 0x20000 -o ${MACHINE}-config.jffs2 --pad=0x200000
+	rm -rf ./tmp
+	cd $curdir
+}
+
+ROOTFS_POSTPROCESS_COMMAND += "fso_rootfs_postprocess"
+
-- 
1.7.0.4





More information about the Openembedded-devel mailing list