cvs commit: LFS/bootscripts/lfs/init.d cleanfs

nathan at linuxfromscratch.org nathan at linuxfromscratch.org
Tue Mar 23 16:24:52 PST 2004


nathan      04/03/23 17:24:52

  Modified:    bootscripts CHANGELOG
               bootscripts/lfs/init.d cleanfs
  Log:
  cleanfs can now create files and directories, based upon contents of
  /etc/sysconfig/createfiles [Temporary name]
  
  Revision  Changes    Path
  1.37      +3 -0      LFS/bootscripts/CHANGELOG
  
  Index: CHANGELOG
  ===================================================================
  RCS file: /home/cvsroot/LFS/bootscripts/CHANGELOG,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- CHANGELOG	23 Mar 2004 23:05:42 -0000	1.36
  +++ CHANGELOG	24 Mar 2004 00:24:52 -0000	1.37
  @@ -1,6 +1,9 @@
   n/a - March 23, 2004
   
   	* Cleaned the /tmp directory on bootup.  find command supplied by Zack
  +	* Added a script which can automatically create files and directories
  +	  on startup.  [Handles files/directories, permissions, and user/group].
  +	  Created by Zack
   
   n/a - March 20, 2004
   
  
  
  
  1.4       +36 -1     LFS/bootscripts/lfs/init.d/cleanfs
  
  Index: cleanfs
  ===================================================================
  RCS file: /home/cvsroot/LFS/bootscripts/lfs/init.d/cleanfs,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- cleanfs	23 Mar 2004 23:05:42 -0000	1.3
  +++ cleanfs	24 Mar 2004 00:24:52 -0000	1.4
  @@ -6,6 +6,34 @@
   . /etc/sysconfig/rc
   . $rc_functions
   
  +# Function to create files/directory on boot.
  +create_files() {
  +	# Read in the configuration file.
  +	exec 9>&0 < /etc/sysconfig/createfiles
  +		while read type owner group perms name ; do
  +			# Ignore comments and blank lines.
  +			case "$type" in
  +				""|\#*) continue ;;
  +			esac
  +
  +			# Ignore existing files.
  +			if [ ! -e "$name" ]; then
  +				# Create stuff based on its type.
  +				case "$type" in
  +					dir)	mkdir "$name"	;;
  +					file)	:> "$name"	;;
  +					*)	echo "Unknown type: $type" >&2
  +						continue	;;
  +				esac
  +
  +				# Set up the permissions, too.
  +				chown $owner:$group "$name"
  +				chmod $perms "$name"
  +			fi
  +		done
  +	exec 0>&9 9>&-
  +}
  +
   case "$1" in
   	start)
   		echo "Removing /var/run/* and /var/lock/*"
  @@ -21,8 +49,15 @@
   		evaluate_retval
   
   		echo "Removing /tmp/*"
  -		( cd /tmp ; find -xdev -depth ! -name . ! -name lost+found -exec rm -rf {} \; )
  +		( cd /tmp ; find -xdev -depth ! -name . ! -name lost+found \
  +				-exec rm -rf {} \; )
   		evaluate_retval
  +
  +		if [ -r /etc/sysconfig/createfiles ]; then
  +			echo "Creating files and directories..."
  +			create_files
  +			evaluate_retval
  +		fi
   		;;
   	*)
   		echo "Usage: $0 {start}"
  
  
  



More information about the lfs-book mailing list