summaryrefslogtreecommitdiffstats
path: root/meta/packages/initscripts/initscripts-1.0/populate-volatile.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/initscripts/initscripts-1.0/populate-volatile.sh')
-rwxr-xr-xmeta/packages/initscripts/initscripts-1.0/populate-volatile.sh83
1 files changed, 58 insertions, 25 deletions
diff --git a/meta/packages/initscripts/initscripts-1.0/populate-volatile.sh b/meta/packages/initscripts/initscripts-1.0/populate-volatile.sh
index 99a469d576..3bb3d94de6 100755
--- a/meta/packages/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/packages/initscripts/initscripts-1.0/populate-volatile.sh
@@ -8,6 +8,47 @@ COREDEF="00_core"
8 8
9[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems." 9[ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
10 10
11create_file() {
12 EXEC="
13 touch \"$1\";
14 chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
15 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
16
17 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache
18
19 [ -e "$1" ] && {
20 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
21 } || {
22 eval $EXEC &
23 }
24}
25
26mk_dir() {
27 EXEC="
28 mkdir -p \"$1\";
29 chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/tty0 2>&1;
30 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/tty0 2>&1 "
31
32 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache
33
34 [ -e "$1" ] && {
35 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
36 } || {
37 eval $EXEC &
38 }
39}
40
41link_file() {
42 EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/tty0 2>&1"
43
44 test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache
45
46 [ -e "$2" ] && {
47 echo "Cannot create link over existing -${TNAME}-." >&2
48 } || {
49 eval $EXEC &
50 }
51}
11 52
12check_requirements() { 53check_requirements() {
13 54
@@ -72,21 +113,17 @@ apply_cfgfile() {
72 113
73 cat ${CFGFILE} | grep -v "^#" | \ 114 cat ${CFGFILE} | grep -v "^#" | \
74 while read LINE; do 115 while read LINE; do
75 TTYPE=`echo ${LINE} | cut -d " " -f 1` 116
76 TUSER=`echo ${LINE} | cut -d " " -f 2` 117 eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
77 TGROUP=`echo ${LINE} | cut -d " " -f 3`
78 TMODE=`echo ${LINE} | cut -d " " -f 4`
79 TNAME=`echo ${LINE} | cut -d " " -f 5`
80 118
81 [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-." 119 [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
82 120
121
83 [ "${TTYPE}" = "l" ] && { 122 [ "${TTYPE}" = "l" ] && {
84 [ -e "${TNAME}" ] && { 123 TSOURCE="$TLTARGET"
85 echo "Cannot create link over existing -${TNAME}-." >&2 124 [ -L "${TNAME}" ] || {
86 } || {
87 TSOURCE=`echo ${LINE} | cut -d " " -f 6`
88 [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-." 125 [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
89 ln -s "${TSOURCE}" "${TNAME}" 126 link_file "${TSOURCE}" "${TNAME}" &
90 } 127 }
91 continue 128 continue
92 } 129 }
@@ -103,17 +140,12 @@ apply_cfgfile() {
103 } 140 }
104 } 141 }
105 142
106 [ -e "${TNAME}" ] && {
107 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
108 continue
109 }
110
111 case "${TTYPE}" in 143 case "${TTYPE}" in
112 "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-." 144 "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
113 touch "${TNAME}" 145 create_file "${TNAME}" &
114 ;; 146 ;;
115 "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-." 147 "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
116 mkdir -p "${TNAME}" 148 mk_dir "${TNAME}" &
117 # Add check to see if there's an entry in fstab to mount. 149 # Add check to see if there's an entry in fstab to mount.
118 ;; 150 ;;
119 *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-." 151 *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
@@ -121,9 +153,6 @@ apply_cfgfile() {
121 ;; 153 ;;
122 esac 154 esac
123 155
124 chown ${TUSER} ${TNAME} || echo "Failed to set owner -${TUSER}- for -${TNAME}-." >&2
125 chgrp ${TGROUP} ${TNAME} || echo "Failed to set group -${TGROUP}- for -${TNAME}-." >&2
126 chmod ${TMODE} ${TNAME} || echo "Failed to set mode -${TMODE}- for -${TNAME}-." >&2
127 156
128 done 157 done
129 158
@@ -131,8 +160,12 @@ apply_cfgfile() {
131 160
132 } 161 }
133 162
134 163if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate"
135for file in `ls -1 "${CFGDIR}" | sort`; do 164then
136 apply_cfgfile "${CFGDIR}/${file}" 165 sh /etc/volatile.cache
137 done 166else
138 167 rm -f /etc/volatile.cache
168 for file in `ls -1 "${CFGDIR}" | sort`; do
169 apply_cfgfile "${CFGDIR}/${file}"
170 done
171fi