4 # Required-Start: $local_fs
5 # Required-Stop: $local_fs
8 # Short-Description: Populate the volatile filesystem
13 CFGDIR="/etc/default/volatiles"
17 [ "${VERBOSE}" != "no" ] && echo "Populating volatile Filesystems."
22 chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/ttyS0 2>&1;
23 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/ttyS0 2>&1 "
25 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
28 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
37 chown ${TUSER}.${TGROUP} $1 || echo \"Failed to set owner -${TUSER}- for -$1-.\" >/dev/ttyS0 2>&1;
38 chmod ${TMODE} $1 || echo \"Failed to set mode -${TMODE}- for -$1-.\" >/dev/ttyS0 2>&1 "
40 test "$VOLATILE_ENABLE_CACHE" = yes && echo "$EXEC" >> /etc/volatile.cache.build
43 [ "${VERBOSE}" != "no" ] && echo "Target already exists. Skipping."
50 EXEC="test -e \"$2\" -o -L $2 || ln -s \"$1\" \"$2\" >/dev/ttyS0 2>&1"
52 test "$VOLATILE_ENABLE_CACHE" = yes && echo " $EXEC" >> /etc/volatile.cache.build
55 echo "Cannot create link over existing -${TNAME}-." >&2
61 check_requirements() {
71 [ `basename "${CFGFILE}"` = "${COREDEF}" ] && return 0
73 TMP_INTERMED="${TMPROOT}/tmp.$$"
74 TMP_DEFINED="${TMPROOT}/tmpdefined.$$"
75 TMP_COMBINED="${TMPROOT}/tmpcombined.$$"
78 cat /etc/passwd | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
79 cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 2 > "${TMP_INTERMED}"
80 cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
82 NR_DEFINED_USERS="`cat "${TMP_DEFINED}" | wc -l`"
83 NR_COMBINED_USERS="`cat "${TMP_COMBINED}" | wc -l`"
85 [ "${NR_DEFINED_USERS}" -ne "${NR_COMBINED_USERS}" ] && {
86 echo "Undefined users:"
87 diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
93 cat /etc/group | sed 's@\(^:\)*:.*@\1@' | sort | uniq > "${TMP_DEFINED}"
94 cat ${CFGFILE} | grep -v "^#" | cut -d " " -f 3 > "${TMP_INTERMED}"
95 cat "${TMP_DEFINED}" "${TMP_INTERMED}" | sort | uniq > "${TMP_COMBINED}"
97 NR_DEFINED_GROUPS="`cat "${TMP_DEFINED}" | wc -l`"
98 NR_COMBINED_GROUPS="`cat "${TMP_COMBINED}" | wc -l`"
100 [ "${NR_DEFINED_GROUPS}" -ne "${NR_COMBINED_GROUPS}" ] && {
101 echo "Undefined groups:"
102 diff "${TMP_DEFINED}" "${TMP_COMBINED}" | grep "^>"
107 # Add checks for required directories here
117 check_requirements "${CFGFILE}" || {
118 echo "Skipping ${CFGFILE}"
122 cat ${CFGFILE} | grep -v "^#" | \
125 eval `echo "$LINE" | sed -n "s/\(.*\)\ \(.*\) \(.*\)\ \(.*\)\ \(.*\)\ \(.*\)/TTYPE=\1 ; TUSER=\2; TGROUP=\3; TMODE=\4; TNAME=\5 TLTARGET=\6/p"`
127 [ "${VERBOSE}" != "no" ] && echo "Checking for -${TNAME}-."
130 [ "${TTYPE}" = "l" ] && {
132 [ -L "${TNAME}" ] || {
133 [ "${VERBOSE}" != "no" ] && echo "Creating link -${TNAME}- pointing to -${TSOURCE}-."
134 link_file "${TSOURCE}" "${TNAME}" &
139 [ -L "${TNAME}" ] && {
140 [ "${VERBOSE}" != "no" ] && echo "Found link."
141 NEWNAME=`ls -l "${TNAME}" | sed -e 's/^.*-> \(.*\)$/\1/'`
142 echo ${NEWNAME} | grep -v "^/" >/dev/null && {
143 TNAME="`echo ${TNAME} | sed -e 's@\(.*\)/.*@\1@'`/${NEWNAME}"
144 [ "${VERBOSE}" != "no" ] && echo "Converted relative linktarget to absolute path -${TNAME}-."
147 [ "${VERBOSE}" != "no" ] && echo "Using absolute link target -${TNAME}-."
152 "f") [ "${VERBOSE}" != "no" ] && echo "Creating file -${TNAME}-."
153 create_file "${TNAME}" &
155 "d") [ "${VERBOSE}" != "no" ] && echo "Creating directory -${TNAME}-."
157 # Add check to see if there's an entry in fstab to mount.
159 *) [ "${VERBOSE}" != "no" ] && echo "Invalid type -${TTYPE}-."
176 *clearcache*) clearcache=1
184 if test -e /etc/volatile.cache -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
186 sh /etc/volatile.cache
188 rm -f /etc/volatile.cache /etc/volatile.cache.build
189 for file in `ls -1 "${CFGDIR}" | sort`; do
190 apply_cfgfile "${CFGDIR}/${file}"
193 [ -e /etc/volatile.cache.build ] && sync && mv /etc/volatile.cache.build /etc/volatile.cache
196 if test -f /etc/ld.so.cache -a ! -f /var/run/ld.so.cache
198 ln -s /etc/ld.so.cache /var/run/ld.so.cache