#! /bin/bash #---------------------------------------------------------------------------- # load-settings.sh - check existence of file 'settings.txt' and if not create # it out of 'settings.txt.default'. # # Creation : 2007-12-09 starwarsfan # Last Update: $Id$ # # Copyright (c) 2001-2009 the eisfair team, team(at)eisfair(dot)org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # --------------------------- # Include necessary functions . ${baseDir}/${trunkDir}/_ADMIN/functions/helpers.sh . ${baseDir}/${trunkDir}/_ADMIN/functions/set-property.sh . ${baseDir}/${trunkDir}/_ADMIN/package-states.txt # --------------------------------------------------------------------------- # loadSettings () # # return code: # 2 - Settingsfile not found. New one created out of default file but abort # of script is necessary to check the settings manually by the user. # 1 - Both settings files not found. Abort of script necessary. # 0 - Settingsfile successful loaded. # --------------------------------------------------------------------------- loadSettings () { # ------------------------------------------------------------ # Set locale. This is required to get identical output schemas # for instance on 'svn info ...' LANG=C # ----------------------------- # check if settings file exists if [ -f "${baseDir}/${trunkDir}/_ADMIN/settings.txt" ] then # ---------------------------------------------------------------- # This should be the normal case: settings.txt exists, so load it. . ${baseDir}/${trunkDir}/_ADMIN/settings.txt # ------------------------------------------------------------- # Setup the archive extension to use and reset it to gzip usage # if wrong value entered if [ "${archProg}" == "gzip" ] then archExtension='gz' elif [ "${archProg}" == "bzip2" ] then archExtension='bz2' elif [ "${archProg}" == "lzma" ] then archExtension='lzma' elif [ "${archProg}" == "xz" ] then archExtension='xz' else archProg='gzip' archExtension='gz' fi myecho "Settings loaded." elif [ -f "${baseDir}/${trunkDir}/_ADMIN/settings.default.txt" ] then echo "" echo "Settings file not existing. Creating new one out of default file" echo "and adding it to svn:ignore. So it is secured that personal settings" echo "are not commited to the repository." cp ${baseDir}/${trunkDir}/_ADMIN/settings.default.txt ${baseDir}/${trunkDir}/_ADMIN/settings.txt # ---------------------------------------------- # Go into the used directory, call setProperty() # and go back to where we came from. cd ${baseDir}/${trunkDir}/_ADMIN setProperty settings.txt setProperty settings.bak setProperty history.txt cd - > /dev/null echo "Settings file created. The script will be aborted here, please modify" echo "the settings to fit your needs. If the settings are OK, restart the" echo "script." echo "" exit 2 else # --------------------------------------------------------------------- # Thats odd: Not even 'settings.txt' nor 'settings.default.txt' exists! echo "" echo "ERROR: No settings file existing!" echo "The default file 'settings.default.txt' must exist on the folder" echo "'${baseDir}/${trunkDir}/_ADMIN/'. This file is used to create" echo "a personal settings file, which you can setup to your needs." echo "Please check for that and restart the script again." echo "" exit 1 fi # ---------------------------------------------------------- # Setup information which should be includet on file headers # # Global vars after this step: # - ${packageCreatorName} # - ${packageCopyrightNotice} # - ${packageCreatorEmail} # - ${packageInfoString} - This is the summary of the three vars above, # in the following schema: # ${packageCreatorName}, ${packageCopyrightNotice}, ${packageCreatorEmail} # # If the var ${packageCopyrightNotice} is empty, then is this schema: # ${packageCreatorName}, ${packageCreatorEmail} # if [ -z "${packageCreatorName}" -o "${packageCreatorName}" == 'whoami' ] then packageCreatorName=`whoami` fi if [ -z "${packageCopyrightNotice}" ] then packageCopyrightNotice='' packageInfoString="${packageCreatorName}, " else packageCopyrightNotice="${packageCopyrightNotice}, " packageInfoString="${packageCreatorName}, ${packageCopyrightNotice}" fi if [ -z "${packageCreatorEmail}" ] then packageCreatorEmail='' fi packageInfoString="${packageInfoString}${packageCreatorEmail}" # -------------------------------------------------------------- # Create the info string without potential existing "<" and ">". # This string is used at the package info file. packageInfoStringPlain=`echo "${packageInfoString}" | sed -e "s///g"` if [ -z "${indexTxtUrl}" ] then indexTxtUrl='http://www.pack-eis.de/index.txt' fi return 0 }