source: bootscripts/lfs/init.d/cleanfs@ 5bc19fc

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 5bc19fc was 5bc19fc, checked in by Bruce Dubbs <bdubbs@…>, 13 years ago

Update to linux-3.0.4 and util-linux-2.20.
Fix minor bootscript problems.

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