From: hschang Date: Wed, 2 Jul 2014 08:18:50 +0000 (+0900) Subject: [initscripts] update scripts X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_openvuplus_3.0;a=commitdiff_plain;h=e5a438ff6cffde1c483744ee17c9ebbcb34ed690 [initscripts] update scripts --- diff --git a/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/bootmisc.sh b/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/bootmisc.sh new file mode 100644 index 0000000..4f76cb4 --- /dev/null +++ b/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/bootmisc.sh @@ -0,0 +1,78 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: bootmisc +# Required-Start: $local_fs mountvirtfs +# Required-Stop: $local_fs +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Misc and other. +### END INIT INFO + +. /etc/default/rcS +# +# Put a nologin file in /etc to prevent people from logging in before +# system startup is complete. +# +if test "$DELAYLOGIN" = yes +then + echo "System bootup in progress - please wait" > /etc/nologin + cp /etc/nologin /etc/nologin.boot +fi + +# +# Set pseudo-terminal access permissions. +# +if test -c /dev/ttyp0 +then + chmod 666 /dev/tty[p-za-e][0-9a-f] + chown root:tty /dev/tty[p-za-e][0-9a-f] +fi + +# +# Apply /proc settings if defined +# +SYSCTL_CONF="/etc/sysctl.conf" +if [ -f "${SYSCTL_CONF}" ] +then + if [ -x "/sbin/sysctl" ] + then + /sbin/sysctl -p "${SYSCTL_CONF}" + else + echo "To have ${SYSCTL_CONF} applied during boot, install package ." + fi +fi + +# +# Update /etc/motd. +# +if test "$EDITMOTD" != no +then + uname -a > /etc/motd.tmp + sed 1d /etc/motd >> /etc/motd.tmp + mv /etc/motd.tmp /etc/motd +fi + +# +# This is as good a place as any for a sanity check +# /tmp should be a symlink to /var/tmp to cut down on the number +# of mounted ramdisks. +if test ! -L /tmp && test -d /var/tmp +then + rm -rf /tmp + ln -sf /var/tmp /tmp +fi + +# Set the system clock from hardware clock +# If the timestamp is more recent than the current time, +# use the timestamp instead. +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` + read TIMESTAMP < /etc/timestamp + if [ ${TIMESTAMP} -gt $SYSTEMDATE ]; then + date -u ${TIMESTAMP#????}${TIMESTAMP%????????} + test -x /etc/init.d/hwclock.sh && /etc/init.d/hwclock.sh stop + fi +fi +: exit 0 diff --git a/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh index c618629..442321a 100755 --- a/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +++ b/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh @@ -8,165 +8,186 @@ # Short-Description: Populate the volatile filesystem ### END INIT INFO -. /etc/default/rcS - -CFGDIR="/etc/default/volatiles" -TMPROOT="/var/tmp" +# Get ROOT_DIR +DIRNAME=`dirname $0` +ROOT_DIR=`echo $DIRNAME | sed -ne 's:/etc/.*::p'` + +[ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS +# When running populate-volatile.sh at rootfs time, disable cache. +[ -n "$ROOT_DIR" ] && VOLATILE_ENABLE_CACHE=no +# If rootfs is read-only, disable cache. +[ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no + +CFGDIR="${ROOT_DIR}/etc/default/volatiles" +TMPROOT="${ROOT_DIR}/var/volatile/tmp" COREDEF="00_core" [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems." create_file() { - EXEC=" - touch \"$1\"; - chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/ttyS0 2>&1; - chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/ttyS0 2>&1 " + EXEC=" + touch \"$1\"; + chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/ttyS0 2>&1; + chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/ttyS0 2>&1 " test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build [ -e "$1" ] && { - [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." + [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." } || { - eval $EXEC & + if [ -z "$ROOT_DIR" ]; then + eval $EXEC & + else + # Creating some files at rootfs time may fail and should fail, + # but these failures should not be logged to make sure the do_rootfs + # process doesn't fail. This does no harm, as this script will + # run on target to set up the correct files and directories. + eval $EXEC > /dev/null 2>&1 + fi } } mk_dir() { - EXEC=" - mkdir -p \"$1\"; - chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/ttyS0 2>&1; + EXEC=" + mkdir -p \"$1\"; + chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/ttyS0 2>&1; chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/ttyS0 2>&1 " test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build - [ -e "$1" ] && { - [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." + [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." } || { - eval $EXEC & + if [ -z "$ROOT_DIR" ]; then + eval $EXEC + else + # For the same reason with create_file(), failures should + # not be logged. + eval $EXEC > /dev/null 2>&1 + fi } } link_file() { - EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/ttyS0 2>&1" + EXEC=" + if [ -L \"$2\" ]; then + [ \"\$(readlink -f \"$2\")\" != \"\$(readlink -f \"$1\")\" ] && { rm -f \"$2\"; ln -sf \"$1\" \"$2\"; }; + elif [ -d \"$2\" ]; then + cp -a $2/* $1 2>/dev/null; + cp -a $2/.[!.]* $1 2>/dev/null; + rm -rf \"$2\"; + ln -sf \"$1\" \"$2\"; + else + ln -sf \"$1\" \"$2\"; + fi + " test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build - - [ -e "$2" ] && { - echo "Cannot create link over existing -${TNAME}-." >&2 - } || { - eval $EXEC & - } + + if [ -z "$ROOT_DIR" ]; then + eval $EXEC & + else + # For the same reason with create_file(), failures should + # not be logged. + eval $EXEC > /dev/null 2>&1 + fi } check_requirements() { + cleanup() { + rm "${TMP_INTERMED}" + rm "${TMP_DEFINED}" + rm "${TMP_COMBINED}" + } - cleanup() { - rm "${TMP_INTERMED}" - rm "${TMP_DEFINED}" - rm "${TMP_COMBINED}" - } - - CFGFILE="$1" - - [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0 - - TMP_INTERMED="${TMPROOT}/tmp.$$" - TMP_DEFINED="${TMPROOT}/tmpdefined.$$" - TMP_COMBINED="${TMPROOT}/tmpcombined.$$" - + CFGFILE="$1" + [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0 - cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" - cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}" - cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" + TMP_INTERMED="${TMPROOT}/tmp.$$" + TMP_DEFINED="${TMPROOT}/tmpdefined.$$" + TMP_COMBINED="${TMPROOT}/tmpcombined.$$" - NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" - NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`" + sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/passwd | sort | uniq > "${TMP_DEFINED}" + cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 2 > "${TMP_INTERMED}" + cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" + NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" + NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`" - [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && { - echo "Undefined users:" - diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" - cleanup - return 1 - } + [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && { + echo "Undefined users:" + diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" + cleanup + return 1 + } - cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" - cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}" - cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" + sed 's@\(^:\)*:.*@\1@' ${ROOT_DIR}/etc/group | sort | uniq > "${TMP_DEFINED}" + cat ${CFGFILE} | grep -v "^#" | cut -s -d " " -f 3 > "${TMP_INTERMED}" + cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" - NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`" - NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`" + NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`" + NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`" - [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && { - echo "Undefined groups:" - diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" - cleanup - return 1 - } + [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && { + echo "Undefined groups:" + diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>" + cleanup + return 1 + } - # Add checks for required directories here + # Add checks for required directories here - cleanup - return 0 - } + cleanup + return 0 +} apply_cfgfile() { + CFGFILE="$1" - CFGFILE="$1" - - check_requirements "${CFGFILE}" || { - echo "Skipping ${CFGFILE}" - return 1 - } - - cat ${CFGFILE} | grep -v "^#" | \ - while read LINE; do - - eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` - - [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." - - - [ "${TTYPE}" = "l" ] && { - TSOURCE="$TLTARGET" - [ -L "${TNAME}" ] || { - [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." - link_file "${TSOURCE}" "${TNAME}" & - } - continue - } - - [ -L "${TNAME}" ] && { - [ "${VERBOSE}" != "no" ] && echo "Found link." - NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'` - echo ${NEWNAME} | grep -v "^/" >/dev/null && { - TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}" - [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." - } || { - TNAME="${NEWNAME}" - [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-." - } - } - - case "${TTYPE}" in - "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-." - create_file "${TNAME}" & - ;; - "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-." - mk_dir "${TNAME}" & - # Add check to see if there's an entry in fstab to mount. - ;; - *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-." - continue - ;; - esac - - - done - - return 0 + check_requirements "${CFGFILE}" || { + echo "Skipping ${CFGFILE}" + return 1 + } - } + cat ${CFGFILE} | grep -v "^#" | \ + while read LINE; do + eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` + TNAME=${ROOT_DIR}${TNAME} + [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." + + [ "${TTYPE}" = "l" ] && { + TSOURCE="$TLTARGET" + [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." + link_file "${TSOURCE}" "${TNAME}" + continue + } + + [ -L "${TNAME}" ] && { + [ "${VERBOSE}" != "no" ] && echo "Found link." + NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'` + echo ${NEWNAME} | grep -v "^/" >/dev/null && { + TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}" + [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-." + } || { + TNAME="${NEWNAME}" + [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-." + } + } + + case "${TTYPE}" in + "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-." + create_file "${TNAME}" & + ;; + "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-." + mk_dir "${TNAME}" + # Add check to see if there's an entry in fstab to mount. + ;; + *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-." + continue + ;; + esac + done + return 0 +} clearcache=0 exec 9&- -if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" +if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" then - sh /etc/volatile.cache -else - rm -f /etc/volatile.cache /etc/volatile.cache.build + sh ${ROOT_DIR}/etc/volatile.cache +else + rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build for file in `ls -1 "${CFGDIR}" | sort`; do apply_cfgfile "${CFGDIR}/${file}" done - [ -e /etc/volatile.cache.build ] && sync && mv /etc/volatile.cache.build /etc/volatile.cache + [ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache fi -if test -f /etc/ld.so.cache -a ! -f /var/run/ld.so.cache +if [ -z "${ROOT_DIR}" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ] then ln -s /etc/ld.so.cache /var/run/ld.so.cache fi diff --git a/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/volatiles b/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/volatiles new file mode 100644 index 0000000..b2ae279 --- /dev/null +++ b/meta-openvuplus/recipes-core/initscripts/initscripts-1.0/volatiles @@ -0,0 +1,39 @@ +# This configuration file lists filesystem objects that should get verified +# during startup and be created if missing. +# +# Every line must either be a comment starting with # +# or a definition of format: +# +# where the items are separated by whitespace ! +# +# : d|f|l : (d)irectory|(f)ile|(l)ink +# +# A linking example: +# l root root 0777 /var/test /tmp/testfile +# f root root 0644 /var/test none +# +# Understanding links: +# When populate-volatile is to verify/create a directory or file, it will first +# check it's existence. If a link is found to exist in the place of the target, +# the path of the target is replaced with the target the link points to. +# Thus, if a link is in the place to be verified, the object will be created +# in the place the link points to instead. +# This explains the order of "link before object" as in the example above, where +# a link will be created at /var/test pointing to /tmp/testfile and due to this +# link the file defined as /var/test will actually be created as /tmp/testfile. +d root root 0755 /var/volatile/cache none +d root root 1777 /var/volatile/lock none +d root root 0755 /var/volatile/log none +d root root 0755 /var/volatile/run none +d root root 1777 /var/volatile/tmp none +l root root 0755 /var/cache /var/volatile/cache +l root root 1777 /var/lock /var/volatile/lock +l root root 0755 /var/log /var/volatile/log +l root root 0755 /var/run /var/volatile/run +l root root 1777 /var/tmp /var/volatile/tmp +d root root 0755 /var/lock/subsys none +f root root 0664 /var/log/wtmp none +f root root 0664 /var/run/utmp none +l root root 0644 /etc/resolv.conf /var/run/resolv.conf +f root root 0644 /var/run/resolv.conf none +