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

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 arm bdubbs/gcc13 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 a44ae577 was a44ae577, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove spaces at end of lines - bootscripts

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[1c48007]1#!/bin/sh
2########################################################################
[0cda898]3# Begin cleanfs
[1c48007]4#
5# Description : Clean file system
6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
[f874424]8# DJ Lucas - dj@linuxfromscratch.org
[0cda898]9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
[1c48007]10#
[0cda898]11# Version : LFS 7.0
[1c48007]12#
13########################################################################
14
[0cda898]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.
[02776dff]24# Description: Cleans temporary directories /run, /var/lock, and
[a44ae577]25# optionally, /tmp. cleanfs also creates /run/utmp
[0cda898]26# and any files defined in /etc/sysconfig/createfiles.
27# X-LFS-Provided-By: LFS
28### END INIT INFO
29
[f874424]30. /lib/lsb/init-functions
[1c48007]31
32# Function to create files/directory on boot.
[a44ae577]33create_files()
[f874424]34{
35 # Input to file descriptor 9 and output to stdin (redirection)
[5bc19fc]36 exec 9>&0 < /etc/sysconfig/createfiles
[f874424]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 ;;
[a44ae577]66 *)
67 log_warning_msg "\nUnknown device type: ${dtype}"
[f874424]68 ;;
69 esac
70 ;;
71 *)
[a44ae577]72 log_warning_msg "\nUnknown type: ${type}"
[f874424]73 continue
74 ;;
[5bc19fc]75 esac
[1c48007]76
[f874424]77 # Set up the permissions, too.
78 chown ${usr}:${grp} "${name}"
79 chmod ${perm} "${name}"
80 fi
81 done
[1c48007]82
[f874424]83 # Close file descriptor 9 (end redirection)
[5bc19fc]84 exec 0>&9 9>&-
[f874424]85 return 0
[1c48007]86}
87
88case "${1}" in
[5bc19fc]89 start)
[a44ae577]90 log_info_msg "Cleaning file systems:"
[1c48007]91
[0cda898]92 if [ "${SKIPTMPCLEAN}" = "" ]; then
[a44ae577]93 log_info_msg2 " /tmp"
[5bc19fc]94 cd /tmp &&
95 find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1
[0cda898]96 fi
[1c48007]97
[02776dff]98 > /run/utmp
[d61a33f]99
[5bc19fc]100 if grep -q '^utmp:' /etc/group ; then
[02776dff]101 chmod 664 /run/utmp
102 chgrp utmp /run/utmp
[5bc19fc]103 fi
[1c48007]104
[5bc19fc]105 (exit ${failed})
106 evaluate_retval
[1c48007]107
[5bc19fc]108 if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
[f874424]109 log_info_msg "Creating files and directories... "
110 create_files # Always returns 0
[5bc19fc]111 evaluate_retval
112 fi
[f874424]113
114 exit $failed
[5bc19fc]115 ;;
116 *)
117 echo "Usage: ${0} {start}"
118 exit 1
119 ;;
[1c48007]120esac
121
[0cda898]122# End cleanfs
Note: See TracBrowser for help on using the repository browser.