Blame Automation/Modules/Cli/Scripts/cli_printCopyrightInfo.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 615395
######################################################################
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 615395
#   cli_printCopyrightInfo.sh -- This function standardizes the
Alain Reguera Delgado 615395
#   copyright information printed on content produced by centos-art.sh
Alain Reguera Delgado 615395
#   script.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 615395
#   As far as I understand, the copyright exists to make people create
Alain Reguera Delgado 615395
#   more.  The copyright gives creators the legal power over their
Alain Reguera Delgado 615395
#   creations and so the freedom to distribute them under the ethical
Alain Reguera Delgado 615395
#   terms the creator considers better.  At this moment I don't feel
Alain Reguera Delgado 615395
#   very confident about this legal affairs and their legal
Alain Reguera Delgado 615395
#   implications, but I need to decide what copyright information the
Alain Reguera Delgado 615395
#   centos-art.sh script will print out when it be requested about it.
Alain Reguera Delgado 615395
#   So, in that sake, I'll assume the same copyright information used
Alain Reguera Delgado 615395
#   by The CentOS Wiki (http://wiki.centos.org/) as reference.
Alain Reguera Delgado 615395
#
Alain Reguera Delgado 615395
#   Written by: 
Alain Reguera Delgado 615395
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado 615395
#     Key fingerprint = D67D 0F82 4CBD 90BC 6421  DF28 7CCE 757C 17CA 3951
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 615395
######################################################################
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function cli_printCopyrightInfo {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 615395
    case "${1}" in
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --license )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            # Print the license name. 
Alain Reguera Delgado 8f60cb
            echo "`gettext "Creative Common Attribution-ShareAlike 3.0 License"`"
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --license-url )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            # Print the url related to license name.
Alain Reguera Delgado 8f60cb
            cli_printUrl --cc-sharealike
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --first-year )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            # The former year when I (as collaborator of The CentOS
Alain Reguera Delgado 8f60cb
            # Project) started to consolidate The CentOS Project
Alain Reguera Delgado 8f60cb
            # Corporate Visual Identity through the CentOS Artwork
Alain Reguera Delgado 8f60cb
            # Repository.
Alain Reguera Delgado 8f60cb
            echo '2009'
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --year|--last-year)
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            # The last year when The CentOS Project stopped working in
Alain Reguera Delgado 8f60cb
            # its Corporate Visual Identity through the CentOS Artwork
Alain Reguera Delgado 8f60cb
            # Repository. That is something that I hope never happens,
Alain Reguera Delgado 8f60cb
            # so assume the current year as last working year.
Alain Reguera Delgado 8f60cb
            date +%Y
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --years-range )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            local FIRST_YEAR=$(cli_printCopyrightInfo --first-year)
Alain Reguera Delgado 8f60cb
            local LAST_YEAR=$(cli_printCopyrightInfo --last-year)
Alain Reguera Delgado 8f60cb
            echo "${FIRST_YEAR}-${LAST_YEAR}"
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --years-list )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            local FIRST_YEAR=$(cli_printCopyrightInfo --first-year)
Alain Reguera Delgado 8f60cb
            local LAST_YEAR=$(cli_printCopyrightInfo --last-year)
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            # Define full copyright year string based on first and
Alain Reguera Delgado 8f60cb
            # last year.
Alain Reguera Delgado 8f60cb
            local FULL_YEAR=$(\
Alain Reguera Delgado 8f60cb
                while [[ ${FIRST_YEAR} -le ${LAST_YEAR} ]];do
Alain Reguera Delgado 8f60cb
                    echo -n "${FIRST_YEAR}, "
Alain Reguera Delgado 615395
                    FIRST_YEAR=$((${FIRST_YEAR} + 1))
Alain Reguera Delgado 8f60cb
                done)
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            # Prepare full copyright year string and print it out. 
Alain Reguera Delgado 8f60cb
            echo "${FULL_YEAR}" | sed 's!, *$!!'
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
    
Alain Reguera Delgado 8f60cb
        --holder )
Alain Reguera Delgado 8f60cb
            
Alain Reguera Delgado 8f60cb
            # Print centos-art.sh script default copyright holder.
Alain Reguera Delgado 8f60cb
            echo "The CentOS Project"
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        --holder-predicate )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            local HOLDER=$(cli_printCopyrightInfo --holder)
Alain Reguera Delgado 8f60cb
            echo "${HOLDER}. `gettext "All rights reserved."`"
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        * )
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
            local YEAR=$(cli_printCopyrightInfo --last-year)
Alain Reguera Delgado 8f60cb
            local HOLDER=$(cli_printCopyrightInfo --holder)
Alain Reguera Delgado 8f60cb
            echo "Copyright © ${YEAR} ${HOLDER}"
Alain Reguera Delgado 8f60cb
            ;;
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    esac
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}