Browse Source

Implemented sde copy config

misl/sde-wrapper
Minto van der Sluis 17 years ago
parent
commit
e19e8d5dc2
1 changed files with 67 additions and 1 deletions
  1. +67
    -1
      lib/sde-copy/config.in

+ 67
- 1
lib/sde-copy/config.in

@ -16,5 +16,71 @@
#Description: When no item name is specified, 'default' will be used.
#Alias: cfg
echo_abort 1 "Not yet implemented"
# Parse commandline arguments.
force=
sourcename=
destinationname=
quiet=
verbose=
while [ "$1" ] ; do
case "$1" in
-f|--force)
force=$1 ;;
-q|--quiet)
quiet=$1 ;;
-v|--verbose)
verbose=$1 ;;
-*)
echo_abort 1 "Option $1 not recognized" ;;
*)
# Only source and destination should be remain now.
case "$#" in
1)
sourcename=default
destinationname=$1 ;;
2)
sourcename=$1; shift
destinationname=$1 ;;
*)
echo_abort 1 "Only 2 arguments allowed not $#: $@" ;;
esac
break ;;
esac
shift
done
# Check for mutually exclusive options.
if [ -n "$verbose" -a -n "$quiet" ]; then
# No source config no action.
echo_abort 1 "Options '$verbose' and '$quiet' are mutually exclusive"
fi
# Determine locations where source and destination config info should go.
srclocation=$(sde_config_dir $sourcename)
dstlocation=$(sde_config_dir $destinationname)
# Check if the source config really exists.
if [ ! -d $srclocation ]; then
# No source config no action.
echo_abort 1 "Source config $sourcename does not exist"
fi
# Determine if the there already exists a config under the new name.
if [ -d $dstlocation -a -z "$force" ]; then
# Yes, the destination already exists and we are not
# allowed to overwrite it.
echo_abort 1 "Destination config $destinationname already exists"
fi
# If destinatin name already exists remove it.
if [ -d $dstlocation ]; then
# Given destination already exists. Remove it first.
sde clean config $force $quiet $verbose $destinationname
fi
# Now we can safely copy the source config to the destination
echo_msg "Copying config from $sourcename to $destinationname"
cp -R $verbose $srclocation $dstlocation
# TODO: Make sure the new config gets the right config id.
# TODO: SDECFG_ID in $dstlocation/config

Loading…
Cancel
Save