source: bootscripts/contrib/lsb-v3/etc/init.d/cleanfs@ dc55fb5e

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 dc55fb5e was dc55fb5e, checked in by DJ Lucas <dj@…>, 13 years ago

Changes per thread starting at http://archive.linuxfromscratch.org/mail-archives/lfs-dev/2011-May/064677.html

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9532 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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