#!/bin/bash # # install_bibble_plugins # http://volker.top.geek.nz/soft/script/install_bibble_plugins # # Install the bibble plugins from the current directory into bibble's system # directory. # Files are installed with permissions and ownerships as-is, so fix those first. # For information about bibble, see http://bibblelabs.com/ # # Copyright (C) by Volker Kuhlmann, http://volker.top.geek.nz/contact.html # All rights reserved. # Released under the terms of the GNU General Public License (GPL) Version 2. # See http://www.gnu.org/ for details. # # Volker Kuhlmann # 27 Jan; 17 Feb 2008 # # Install files from the following directories. dirlist=( plugins tools/Plugins webhelp ) # Install to the first one of these directories. targetlist=( "/usr/lib/bibblelabs/bibblepro" "/usr/lib/bibblelabs/bibblelite" ) die() { echo 1>&2 "$@" exit 1 } run() { if [ -n "$real" ]; then ( set -x; "$@"; ) else ( set -x; : "$@"; ) fi } # Check for dry-run or real. case "$1" in -real) real=1;; -n|--test) real=;; *) real=1 #echo "Run with -real to actually install files." echo " install_bibble_plugins V1.1 by Volker Kuhlmann Run $0 -real to actually install files. Run $0 -n to see what would happen. " exit 1 ;; esac # Check if running as root. test "`id -u`" -eq 0 || die "Bibble plugins must be installed by root." # Install plugins from where this script is located? #cd "${0%/*}" # Auto-detect bibble system root directory. bibbleroot="/usr/lib/bibblelabs/WHERE-IS-BIBBLE" for dir in "${targetlist[@]}"; do if [ -d "$dir" ]; then bibbleroot="$dir" break fi done for dir in "${dirlist[@]}"; do instdir="$bibbleroot/$dir" test -d "$dir" || die "Directory '$dir' does not exist!" test -d "$instdir" || die "Directory '$instdir' does not exist!" #pushd "$dir" || "Can't change to '$dir'!" for file in "$dir"/*; do instfile="$bibbleroot/$file" # Check if it is a file. if [ ! -f "$file" ]; then echo "Not a file (ignoring): '$file'" continue fi # Delete existing symlinks. if [ -L "$instfile" ]; then run rm "$instfile" fi # Back up existing files. # Can bibble handle .so with duplicate functionality? # For now, remove and copy, it's <1MB of disk space. if [ -f "$instfile" ]; then run rm "$instfile" fi # Install file. run cp -p "$file" "$instfile" done done