source: bootscripts-standard/clfs/init.d/cleanfs@ 7355219

Last change on this file since 7355219 was 7df280d, checked in by Joe Ciccone <jciccone@…>, 17 years ago

Change /bin/sh to /bin/bash in the bootscripts because the bootscripts use bashisms. Having ash linked to sh will cause errors. Thanks to Bigdassaved for providing the diff and Copper for bring up the issue.

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[7df280d]1#!/bin/bash
[7125722]2########################################################################
3# Begin $rc_base/init.d/cleanfs
4#
5# Description : Clean file system
6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8#
9# Version : 00.00
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
18# Function to create files/directory on boot.
19create_files() {
20 # Read in the configuration file.
21 exec 9>&0 < /etc/sysconfig/createfiles
22 while read name type perm usr grp dtype maj min junk
23 do
24
25 # Ignore comments and blank lines.
26 case "${name}" in
27 ""|\#*) continue ;;
28 esac
29
30 # Ignore existing files.
31 if [ ! -e "${name}" ]; then
32 # Create stuff based on its type.
33 case "${type}" in
34 dir)
35 mkdir "${name}"
36 ;;
37 file)
38 :> "${name}"
39 ;;
40 dev)
41 case "${dtype}" in
42 char)
43 mknod "${name}" c ${maj} ${min}
44 ;;
45 block)
46 mknod "${name}" b ${maj} ${min}
47 ;;
48 pipe)
49 mknod "${name}" p
50 ;;
51 *)
52 boot_mesg -n "\nUnknown device type: ${dtype}" ${WARNING}
53 boot_mesg "" ${NORMAL}
54 ;;
55 esac
56 ;;
57 *)
58 boot_mesg -n "\nUnknown type: ${type}" ${WARNING}
59 boot_mesg "" ${NORMAL}
60 continue
61 ;;
62 esac
63
64 # Set up the permissions, too.
65 chown ${usr}:${grp} "${name}"
66 chmod ${perm} "${name}"
67 fi
68 done
69 exec 0>&9 9>&-
70}
71
72case "${1}" in
73 start)
74 boot_mesg -n "Cleaning file systems:" ${INFO}
75
76 boot_mesg -n " /tmp" ${NORMAL}
77 cd /tmp &&
78 find . -xdev -mindepth 1 ! -name lost+found \
79 -delete || failed=1
80
81 boot_mesg -n " /var/lock" ${NORMAL}
82 cd /var/lock &&
83 find . -type f ! -newer /proc -exec rm -f {} \; || failed=1
84
85 boot_mesg " /var/run" ${NORMAL}
86 cd /var/run &&
87 find . ! -type d ! -name utmp ! -newer /proc \
88 -exec rm -f {} \; || failed=1
89 > /var/run/utmp
90 if grep -q '^utmp:' /etc/group ; then
91 chmod 664 /var/run/utmp
92 chgrp utmp /var/run/utmp
93 fi
94
95 (exit ${failed})
96 evaluate_retval
97
98 if [ -e /etc/sysconfig/createfiles ]; then
99 if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
100 boot_mesg "Creating files and directories..."
101 create_files
102 evaluate_retval
103 fi
104 fi
105 ;;
106 *)
107 echo "Usage: ${0} {start}"
108 exit 1
109 ;;
110esac
111
112# End $rc_base/init.d/cleanfs
Note: See TracBrowser for help on using the repository browser.