source: bootscripts/lfs/init.d/cleanfs@ edd83dc

ml-11.0 multilib
Last change on this file since edd83dc was edd83dc, checked in by Xℹ Ruoyao <xry111@…>, 3 years ago

Merge changes from trunk to multilib

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@12107 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.1 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin cleanfs
4#
5# Description : Clean file system
6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8# DJ Lucas - dj@linuxfromscratch.org
9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
10#
11# Version : LFS 7.0
12#
13########################################################################
14
15### BEGIN INIT INFO
16# Provides: cleanfs
17# Required-Start: $local_fs
18# Should-Start:
19# Required-Stop:
20# Should-Stop:
21# Default-Start: S
22# Default-Stop:
23# Short-Description: Cleans temporary directories early in the boot process.
24# Description: Cleans temporary directories /run, /var/lock, and
25# optionally, /tmp. cleanfs also creates /run/utmp
26# and any files defined in /etc/sysconfig/createfiles.
27# X-LFS-Provided-By: LFS
28### END INIT INFO
29
30. /lib/lsb/init-functions
31
32# Function to create files/directory on boot.
33create_files()
34{
35 # Input to file descriptor 9 and output to stdin (redirection)
36 exec 9>&0 < /etc/sysconfig/createfiles
37
38 while read name type perm usr grp dtype maj min junk
39 do
40 # Ignore comments and blank lines.
41 case "${name}" in
42 ""|\#*) continue ;;
43 esac
44
45 # Ignore existing files.
46 if [ ! -e "${name}" ]; then
47 # Create stuff based on its type.
48 case "${type}" in
49 dir)
50 mkdir "${name}"
51 ;;
52 file)
53 :> "${name}"
54 ;;
55 dev)
56 case "${dtype}" in
57 char)
58 mknod "${name}" c ${maj} ${min}
59 ;;
60 block)
61 mknod "${name}" b ${maj} ${min}
62 ;;
63 pipe)
64 mknod "${name}" p
65 ;;
66 *)
67 log_warning_msg "\nUnknown device type: ${dtype}"
68 ;;
69 esac
70 ;;
71 *)
72 log_warning_msg "\nUnknown type: ${type}"
73 continue
74 ;;
75 esac
76
77 # Set up the permissions, too.
78 chown ${usr}:${grp} "${name}"
79 chmod ${perm} "${name}"
80 fi
81 done
82
83 # Close file descriptor 9 (end redirection)
84 exec 0>&9 9>&-
85 return 0
86}
87
88case "${1}" in
89 start)
90 log_info_msg "Cleaning file systems:"
91
92 if [ "${SKIPTMPCLEAN}" = "" ]; then
93 log_info_msg2 " /tmp"
94 cd /tmp &&
95 find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1
96 fi
97
98 > /run/utmp
99
100 if grep -q '^utmp:' /etc/group ; then
101 chmod 664 /run/utmp
102 chgrp utmp /run/utmp
103 fi
104
105 (exit ${failed})
106 evaluate_retval
107
108 if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
109 log_info_msg "Creating files and directories... "
110 create_files # Always returns 0
111 evaluate_retval
112 fi
113
114 exit $failed
115 ;;
116 *)
117 echo "Usage: ${0} {start}"
118 exit 1
119 ;;
120esac
121
122# End cleanfs
Note: See TracBrowser for help on using the repository browser.