Blame Scripts/centos-art/Functions/Tuneup/Shell/shell_doTopComment.sh

be7de3
#!/bin/bash
be7de3
#
1991ca
# shell_doTopComment.sh -- This function standardizes the top comment
1991ca
# section inside shell scripts (*.sh) using a predefined template.
be7de3
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
be7de3
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
be7de3
# General Public License for more details.
be7de3
#
be7de3
# You should have received a copy of the GNU General Public License
be7de3
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
be7de3
# ----------------------------------------------------------------------
be7de3
# $Id$
be7de3
# ----------------------------------------------------------------------
be7de3
1991ca
function shell_doTopComment {
be7de3
be7de3
    # Define absolute path to template file.
79f9ac
    local TEMPLATE="${TUNEUP_CONFIG_DIR}/topcomment.sed"
be7de3
be7de3
    # Check template file existence.
cd9f5a
    cli_checkFiles $TEMPLATE
be7de3
be7de3
    # Define file name to template instance.
be7de3
    local INSTANCE=$(cli_getTemporalFile $TEMPLATE)
be7de3
be7de3
    # Create template instance.
be7de3
    cp $TEMPLATE $INSTANCE
be7de3
be7de3
    # Check template instance. We cannot continue if template instance
be7de3
    # couldn't be created.
cd9f5a
    cli_checkFiles $INSTANCE
be7de3
be7de3
    # Expand translation markers in template instance.
54cb18
    cli_expandTMarkers $INSTANCE
be7de3
be7de3
    # Apply template instance to file.
be7de3
    sed -r -i -f $INSTANCE $FILE
be7de3
be7de3
    # Remove template instance.
be7de3
    if [[ -f ${INSTANCE} ]];then
be7de3
        rm ${INSTANCE} 
be7de3
    fi
be7de3
be7de3
}