diff options
Diffstat (limited to 'meta/recipes-core/initscripts')
-rwxr-xr-x | meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh index ab3af70430..c4bf70e5de 100755 --- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh +++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh | |||
@@ -8,10 +8,18 @@ | |||
8 | # Short-Description: Populate the volatile filesystem | 8 | # Short-Description: Populate the volatile filesystem |
9 | ### END INIT INFO | 9 | ### END INIT INFO |
10 | 10 | ||
11 | . /etc/default/rcS | 11 | # Get ROOT_DIR |
12 | 12 | DIRNAME=`dirname $0` | |
13 | CFGDIR="/etc/default/volatiles" | 13 | ROOT_DIR=`echo $DIRNAME | sed -ne 's:etc/.*::p'` |
14 | TMPROOT="/var/tmp" | 14 | |
15 | [ -e ${ROOT_DIR}/etc/default/rcS ] && . ${ROOT_DIR}/etc/default/rcS | ||
16 | # When running populate-volatile.sh at rootfs time, disable cache. | ||
17 | [ "$ROOT_DIR" != "/" ] && VOLATILE_ENABLE_CACHE=no | ||
18 | # If rootfs is read-only, disable cache. | ||
19 | [ "$ROOTFS_READ_ONLY" = "yes" ] && VOLATILE_ENABLE_CACHE=no | ||
20 | |||
21 | CFGDIR="${ROOT_DIR}/etc/default/volatiles" | ||
22 | TMPROOT="${ROOT_DIR}/var/tmp" | ||
15 | COREDEF="00_core" | 23 | COREDEF="00_core" |
16 | 24 | ||
17 | [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems." | 25 | [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems." |
@@ -27,7 +35,15 @@ create_file() { | |||
27 | [ -e "$1" ] && { | 35 | [ -e "$1" ] && { |
28 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." | 36 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." |
29 | } || { | 37 | } || { |
30 | eval $EXEC & | 38 | if [ "$ROOT_DIR" = "/" ]; then |
39 | eval $EXEC & | ||
40 | else | ||
41 | # Creating some files at rootfs time may fail and should fail, | ||
42 | # but these failures should not be logged to make sure the do_rootfs | ||
43 | # process doesn't fail. This does no harm, as this script will | ||
44 | # run on target to set up the correct files and directories. | ||
45 | eval $EXEC > /dev/null 2>&1 & | ||
46 | fi | ||
31 | } | 47 | } |
32 | } | 48 | } |
33 | 49 | ||
@@ -41,7 +57,13 @@ mk_dir() { | |||
41 | [ -e "$1" ] && { | 57 | [ -e "$1" ] && { |
42 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." | 58 | [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping." |
43 | } || { | 59 | } || { |
44 | eval $EXEC | 60 | if [ "$ROOT_DIR" = "/" ]; then |
61 | eval $EXEC | ||
62 | else | ||
63 | # For the same reason with create_file(), failures should | ||
64 | # not be logged. | ||
65 | eval $EXEC > /dev/null 2>&1 | ||
66 | fi | ||
45 | } | 67 | } |
46 | } | 68 | } |
47 | 69 | ||
@@ -49,11 +71,16 @@ link_file() { | |||
49 | EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" | 71 | EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1" |
50 | 72 | ||
51 | test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build | 73 | test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build |
52 | |||
53 | [ -e "$2" ] && { | 74 | [ -e "$2" ] && { |
54 | echo "Cannot create link over existing -${TNAME}-." >&2 | 75 | echo "Cannot create link over existing -${TNAME}-." >&2 |
55 | } || { | 76 | } || { |
56 | eval $EXEC & | 77 | if [ "$ROOT_DIR" = "/" ]; then |
78 | eval $EXEC & | ||
79 | else | ||
80 | # For the same reason with create_file(), failures should | ||
81 | # not be logged. | ||
82 | eval $EXEC > /dev/null 2>&1 & | ||
83 | fi | ||
57 | } | 84 | } |
58 | } | 85 | } |
59 | 86 | ||
@@ -63,7 +90,7 @@ check_requirements() { | |||
63 | rm "${TMP_DEFINED}" | 90 | rm "${TMP_DEFINED}" |
64 | rm "${TMP_COMBINED}" | 91 | rm "${TMP_COMBINED}" |
65 | } | 92 | } |
66 | 93 | ||
67 | CFGFILE="$1" | 94 | CFGFILE="$1" |
68 | [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0 | 95 | [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0 |
69 | 96 | ||
@@ -71,7 +98,7 @@ check_requirements() { | |||
71 | TMP_DEFINED="${TMPROOT}/tmpdefined.$$" | 98 | TMP_DEFINED="${TMPROOT}/tmpdefined.$$" |
72 | TMP_COMBINED="${TMPROOT}/tmpcombined.$$" | 99 | TMP_COMBINED="${TMPROOT}/tmpcombined.$$" |
73 | 100 | ||
74 | cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" | 101 | cat ${ROOT_DIR}/etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" |
75 | cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}" | 102 | cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}" |
76 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" | 103 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" |
77 | NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" | 104 | NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`" |
@@ -85,7 +112,7 @@ check_requirements() { | |||
85 | } | 112 | } |
86 | 113 | ||
87 | 114 | ||
88 | cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" | 115 | cat ${ROOT_DIR}/etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}" |
89 | cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}" | 116 | cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}" |
90 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" | 117 | cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}" |
91 | 118 | ||
@@ -116,6 +143,7 @@ apply_cfgfile() { | |||
116 | cat ${CFGFILE} | grep -v "^#" | \ | 143 | cat ${CFGFILE} | grep -v "^#" | \ |
117 | while read LINE; do | 144 | while read LINE; do |
118 | eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` | 145 | eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"` |
146 | TNAME=${ROOT_DIR}/${TNAME} | ||
119 | [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." | 147 | [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." |
120 | 148 | ||
121 | [ "${TTYPE}" = "l" ] && { | 149 | [ "${TTYPE}" = "l" ] && { |
@@ -168,19 +196,19 @@ do | |||
168 | done | 196 | done |
169 | exec 9>&- | 197 | exec 9>&- |
170 | 198 | ||
171 | if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" | 199 | if test -e ${ROOT_DIR}/etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0" |
172 | then | 200 | then |
173 | sh /etc/volatile.cache | 201 | sh ${ROOT_DIR}/etc/volatile.cache |
174 | else | 202 | else |
175 | rm -f /etc/volatile.cache /etc/volatile.cache.build | 203 | rm -f ${ROOT_DIR}/etc/volatile.cache ${ROOT_DIR}/etc/volatile.cache.build |
176 | for file in `ls -1 "${CFGDIR}" | sort`; do | 204 | for file in `ls -1 "${CFGDIR}" | sort`; do |
177 | apply_cfgfile "${CFGDIR}/${file}" | 205 | apply_cfgfile "${CFGDIR}/${file}" |
178 | done | 206 | done |
179 | 207 | ||
180 | [ -e /etc/volatile.cache.build ] && sync && mv /etc/volatile.cache.build /etc/volatile.cache | 208 | [ -e ${ROOT_DIR}/etc/volatile.cache.build ] && sync && mv ${ROOT_DIR}/etc/volatile.cache.build ${ROOT_DIR}/etc/volatile.cache |
181 | fi | 209 | fi |
182 | 210 | ||
183 | if test -f /etc/ld.so.cache -a ! -f /var/run/ld.so.cache | 211 | if [ "${ROOT_DIR}" = "/" ] && [ -f /etc/ld.so.cache ] && [ ! -f /var/run/ld.so.cache ] |
184 | then | 212 | then |
185 | ln -s /etc/ld.so.cache /var/run/ld.so.cache | 213 | ln -s /etc/ld.so.cache /var/run/ld.so.cache |
186 | fi | 214 | fi |