|
#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-install
|
|
# Copyright (C) 2006 - 2008 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# 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; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
#Description: Install the `sde` wrapper on $HOME/bin/
|
|
|
|
set -e
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. $SDEROOT/lib/libsde.in
|
|
|
|
install_usage() {
|
|
cat <<EOT
|
|
Usage: sde install
|
|
Installs a symlink of the sde wrapper at \$HOME/bin/,
|
|
which is supposed to be on \$PATH
|
|
EOT
|
|
}
|
|
|
|
if [ -n "$SUDO_USER" -a "$SUDO_USER" != "$USER" ]; then
|
|
BINDIR="/usr/local/bin"
|
|
else
|
|
BINDIR="$HOME/bin"
|
|
fi
|
|
|
|
# what action was requested?
|
|
if [ $# -ne 0 ]; then
|
|
install_usage
|
|
elif [ -L "$BINDIR/sde" ]; then
|
|
if [ "$( readlink -f $BINDIR/sde )" = "$SDEROOT/bin/sde" ]; then
|
|
echo_warning "the same sde wrapper is already installed, skip."
|
|
else
|
|
echo_warning "sde wrapper already installed [$( readlink -f $BINDIR/sde )]"
|
|
ln -sf "$SDEROOT/bin/sde" "$BINDIR/sde"
|
|
echo_info "sde wrapper reinstalled at $BINDIR/"
|
|
fi
|
|
elif [ -e "$BINDIR/sde" ]; then
|
|
echo_abort 1 "Something is already at '$BINDIR/sde', this is not supported."
|
|
else
|
|
mkdir -p "$BINDIR/"
|
|
ln -s "$SDEROOT/bin/sde" "$BINDIR/sde"
|
|
echo_info "sde wrapper installed at $BINDIR/"
|
|
fi
|