Skip to content

Commit

Permalink
use .sh instead of .source suffix for file being sourced, issue a
Browse files Browse the repository at this point in the history
warning that .source is deprecated
  • Loading branch information
Thomas Lange committed Sep 23, 2015
1 parent 3068f4d commit de38f71
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
12 changes: 10 additions & 2 deletions bin/fai-class
Expand Up @@ -5,7 +5,7 @@
# fai-class - determine all classes a host belongs to
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2002-2009 by Thomas Lange, lange@informatik.uni-koeln.de
# (c) 2002-2015 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************
Expand Down Expand Up @@ -74,7 +74,7 @@ usage() {

ex=$1
cat <<-EOF
fai-class Copyright (C) 2002-2009 Thomas Lange
fai-class Copyright (C) 2002-2015 Thomas Lange
Usage: fai-class [OPTION] DIRECTORY CLASSFILE
Define classes using files and scripts in DIRECTORY
Expand Down Expand Up @@ -159,7 +159,15 @@ for f in $scripts ; do
export classes
case $f in
*~|*.bak) debugmsg "Skipping backup file $f" ;;
*.sh)
verbosemsg "Executing $classdir/$f."
# this script can define $newclasses
newclasses=
. $f
fc_check_status $f $?
echo $newclasses | addclass ;;
*.source)
echo "WARNING: The .source suffix is deprecated. Use .sh instead."
verbosemsg "Executing $classdir/$f."
# this script can define $newclasses
newclasses=
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/simple/class/DEBIAN.var
Expand Up @@ -4,7 +4,7 @@ KEYMAP=us-latin1
# MODULESLIST contains modules that will be loaded by the new system,
# not during installation these modules will be written to /etc/modules
# If you need a module during installation, add it to $kernelmodules
# in 20-hwdetect.source.
# in 20-hwdetect.sh.
MODULESLIST="usbhid psmouse"

# if you have enough RAM (>2GB) you may want to enable this line. It
Expand Down
File renamed without changes.
22 changes: 17 additions & 5 deletions lib/subroutines
Expand Up @@ -5,7 +5,7 @@
# subroutines -- useful subroutines for FAI
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2000-2014 by Thomas Lange, lange@informatik.uni-koeln.de
# (c) 2000-2015 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
# (c) 2001-2005 by Henning Glawe, glaweh@physik.fu-berlin.de
# Freie Universitaet Berlin
Expand Down Expand Up @@ -219,7 +219,7 @@ task() {
### BEGIN SUBROUTINE INFO
# Provides-Var:
# Required-Var: $classes $debug
# Short-Description: call a hook, hook.source can define additional variables
# Short-Description: call a hook, hook.sh can define additional variables
### END SUBROUTINE INFO

call_hook() {
Expand All @@ -236,18 +236,30 @@ call_hook() {
echo "WARNING: Skipping $hfile because it's not executable." >&2
continue
fi
if [ -f $hfile.source -a ! -x $hfile.source ]; then
echo "WARNING: Skipping $hfile.source because it's not executable." >&2
if [ -f $hfile.sh -a ! -x $hfile.sh ]; then
echo "WARNING: Skipping $hfile.sh because it's not executable." >&2
continue
fi
if [ -f $hfile.source ]; then
echo "WARNING: The suffix .source is deprecated. Use .sh instead." >&2
# continue
fi
if [ -x $hfile ]; then
echo "Calling hook: $hook.$cl"
sendmon "HOOK $hook.$cl"
# execute the hook
$hfile $dflag "$@"
check_status $hook.$cl $?
fi
if [ -x $hfile.source ]; then
if [ -x $hfile.sh ]; then
echo "Source hook: $hook.$cl.sh"
sendmon "HOOK $hook.$cl.sh"
# source this hook
. $hfile.sh $dflag "$@"
check_status $hook.$cl.sh $?
fi
# deprecated
if [ -x $hfile.source ]; then
echo "Source hook: $hook.$cl.source"
sendmon "HOOK $hook.$cl.source"
# source this hook
Expand Down
4 changes: 2 additions & 2 deletions man/fai-class.1
Expand Up @@ -11,7 +11,7 @@
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.TH "fai-class" "1" "4 October 2011" "FAI 4" ""
.TH "fai-class" "1" "23 September 2015" "FAI 4" ""
.SH "NAME"
fai\-class \- define classes using files and scripts.
.SH "SYNOPSIS"
Expand All @@ -28,7 +28,7 @@ the names of the classes to stdout. Classes can be separated by spaces
or written one on a line. All lines that start with a "#" are comment
lines and are ignored.

Shell scripts that end in ".source" are sourced and can define classes
Shell scripts that end in ".sh" are sourced and can define classes
by setting the variable $newclasses. This is useful for scripts where
you can't control stdout. Variables that are defined in these scripts
are available to other scripts in DIRECTORY, but they are not exported
Expand Down

0 comments on commit de38f71

Please sign in to comment.