Blame Scripts/Modules/Render/Modules/Files/Modules/Symlink/symlink.sh

Alain Reguera Delgado 8daea6
#!/bin/bash
Alain Reguera Delgado 8daea6
######################################################################
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
#   symlink.sh -- This function provides an interface for ln command.
Alain Reguera Delgado 8daea6
#   It mainly exists to creates symbolic links based on information
Alain Reguera Delgado 8daea6
#   set in configuration files that have symlink as value to
Alain Reguera Delgado 8daea6
#   render-type option. In these sections, the render-from and
Alain Reguera Delgado 8daea6
#   link-target options are used to specify the link locations. The
Alain Reguera Delgado 8daea6
#   link-options option might be used to pass additional options to ln
Alain Reguera Delgado 8daea6
#   command.
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
#   Written by:
Alain Reguera Delgado 8daea6
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
# Copyright (C) 2009-2013 The CentOS Artwork SIG
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8daea6
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8daea6
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8daea6
# your option) any later version.
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8daea6
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8daea6
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8daea6
# General Public License for more details.
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8daea6
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8daea6
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8daea6
#
Alain Reguera Delgado 8daea6
######################################################################
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
function symlink {
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
    # Define absolute path to command used to create symbolic links.
Alain Reguera Delgado 8daea6
    local LN=/bin/ln
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
    # Retrieve command options (values are not required here). Just
Alain Reguera Delgado 8daea6
    # grant you are always creating symbolic links.
Alain Reguera Delgado 8daea6
    local LN_OPTIONS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "link-options")
Alain Reguera Delgado 8daea6
    LN_OPTIONS="-si ${LN_OPTIONS}"
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
    # Retrieve link source. This is the file you want to link. This
Alain Reguera Delgado 8daea6
    # file is generally inside the repository.
Alain Reguera Delgado 8daea6
    local LN_SOURCE=${RENDER_FROM}
Alain Reguera Delgado 8daea6
    tcar_checkFiles -ef ${LN_SOURCE}
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
    # Retrieve link target. This is the link you want to create. This
Alain Reguera Delgado 8daea6
    # link may be inside or outside the repository. The value passed
Alain Reguera Delgado 8daea6
    # to this value must be a directory because it is concatenated
Alain Reguera Delgado 8daea6
    # with the section name to build the final path where link will be
Alain Reguera Delgado 8daea6
    # created.
Alain Reguera Delgado 8daea6
    local LN_TARGET=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "link-target")
Alain Reguera Delgado 8daea6
    tcar_checkFiles -ed ${LN_TARGET}
Alain Reguera Delgado 8daea6
    LN_TARGET=${LN_TARGET}/${SECTION}
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
    # Print action message.
Alain Reguera Delgado 8daea6
    tcar_printMessage "${LN_TARGET}" --as-creating-line
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
    # Create link interactively.
Alain Reguera Delgado 8daea6
    ${LN} ${LN_OPTIONS} ${LN_SOURCE} ${LN_TARGET}
Alain Reguera Delgado 8daea6
Alain Reguera Delgado 8daea6
}