diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-25 23:56:37 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-06-26 00:30:16 -0600 |
commit | acc687b3a74e3c8d750630c323d223f1c63599db (patch) | |
tree | da55f9a30ffebc005d3a0157d70ca8d997afa959 /rvs/wrapper/rvs.sh | |
parent | bddd6fb07906e660260ef0fced05440ecac8d9e9 (diff) |
mkdir rvs; mv * rvs
Diffstat (limited to 'rvs/wrapper/rvs.sh')
-rw-r--r-- | rvs/wrapper/rvs.sh | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/rvs/wrapper/rvs.sh b/rvs/wrapper/rvs.sh new file mode 100644 index 0000000..a515f2d --- /dev/null +++ b/rvs/wrapper/rvs.sh @@ -0,0 +1,110 @@ +#!@SHELL@ +name='@name@' +ver='0.8r61' +# Copyright (C) 2009 Luke Shumaker +# +# This file is part of rvs. +# +# rvs 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, or (at your option) any later version. +# +# rvs is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with rvs; see the file COPYING. +# If not, write to the Free Software Foundation, +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +RVS="$0" #RVS="@rvs@" +libexecdir="@libexecdir@/$name" + +_error() { + echo "$RVS: $1" >> /dev/stderr + exit 1 +} + +_repo() { + repo=".$name" + pwd=`pwd` + owd="$pwd" + + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + echo "`pwd`/$repo" + else + _error "no $name repository found" + fi + cd "$owd" +} + +_init() { + repo=`_repo 2> /dev/null` + if [ -z "$repo" ]; then + repo=".$name" + install -d "$repo" + install -m644 -T $libexecdir/plugins $repo/plugins + while read plugin; do + echo "initializing plugin \`$plugin'" + install -d "$repo/$plugin" + export REPO=.rvs/$plugin + if [ -e "$libexecdir/$plugin/init" ]; then + "$libexecdir/$plugin/init" + fi + done < $repo/plugins + else + _error "repository already exists at \`$repo'" + fi +} + +_install() { + id=$1 + dir=${2-$id} + name=`echo $id | sed 's/-.*$//'` + if (grep "^$name-" "$libexecdir/plugins" &> /dev/null); then + # an entry for this plugin already exists, though possibly a + # different version + sed -i "s/^$name-.*$/$id/" "$libexecdir/plugins" + else + echo "$id" >> "$libexecdir/plugins" + fi + rm -rf "$libexecdir/$id" + cp -rpT "$dir" "$libexecdir/$id" +} + +_uninstall() { + id=$1 + sed -i "/^$id$/ d" "$libexecdir/plugins" + rm -rf "$libexecdir/$id" +} + +# START OPTION HANDLING # +com=$1; +# END OPTION HANDLING # +case "$com" in + '') _error 'no command specified';; + # 'repo') _repo; exit $?;; + 'init') _init; exit $?;; + 'install') shift; _install $@; exit $?;; + 'uninstall') shift; _uninstall $@; exit $?;; + *) REPO=`_repo` + if [ "$?" = '0' ]; then + export RVS libexecdir REPO + "$libexecdir/runcom" $@ < $REPO/plugins + exit $? + else + _error "cannot find an existing repository" + fi + :;; +esac + +# Copy/Paste Virus 1.3c Please copy and paste this text anywhere. Track +# its progress by searching for this MD5#f7eac285ebfe21c4587bfebb9582f90d + |