diff --git a/utility.sh b/utility.sh index 068b833..7dcf7ad 100755 --- a/utility.sh +++ b/utility.sh @@ -23,23 +23,30 @@ check_dir() install() { - DIR=$1 - check_dir "$DIR" + DESTDIR=$1 + check_dir "$DESTDIR" + if [ -z "$2" ]; then + PREFIX=$DESTDIR + else + PREFIX="$2" + DESTDIR=$DESTDIR$PREFIX + echo $DESTDIR + fi - mkdir -p "$DIR/share/SimplePanoramaViewer/" - mkdir -p "$DIR/bin/" - mkdir -p "$DIR/share/applications" - mkdir -p "$DIR/share/mime/image" - cp SimplePanoramaViewer "$DIR/share/SimplePanoramaViewer" - cp -r css "$DIR/share/SimplePanoramaViewer" - cp -r html "$DIR/share/SimplePanoramaViewer" - cp -r js "$DIR/share/SimplePanoramaViewer" - cp install/SimplePanoramaViewer.desktop "$DIR/share/applications" - cp install/pjpg.xml "$DIR/share/mime/image" + mkdir -p "$DESTDIR/share/SimplePanoramaViewer/" + mkdir -p "$DESTDIR/bin/" + mkdir -p "$DESTDIR/share/applications" + mkdir -p "$DESTDIR/share/mime/image" + cp SimplePanoramaViewer "$DESTDIR/share/SimplePanoramaViewer" + cp -r css "$DESTDIR/share/SimplePanoramaViewer" + cp -r html "$DESTDIR/share/SimplePanoramaViewer" + cp -r js "$DESTDIR/share/SimplePanoramaViewer" + cp install/SimplePanoramaViewer.desktop "$DESTDIR/share/applications" + cp install/pjpg.xml "$DESTDIR/share/mime/image" echo "#!/bin/bash - $DIR/share/SimplePanoramaViewer/SimplePanoramaViewer \"\$@\"" > "$DIR/bin/SimplePanoramaViewer" - chmod a+x "$DIR/bin/SimplePanoramaViewer" - sudo chmod -R a+r "$DIR/share/SimplePanoramaViewer" +$PREFIX/share/SimplePanoramaViewer/SimplePanoramaViewer \"\$@\"" > "$DESTDIR/bin/SimplePanoramaViewer" + chmod a+x "$DESTDIR/bin/SimplePanoramaViewer" + chmod -R a+r "$DESTDIR/share/SimplePanoramaViewer" } uninstall() @@ -80,7 +87,7 @@ case "$1" in print_help ;; "-i" | "--install") - install "$2" + install "$2" "$3" ;; "-u" | "--uninstall") uninstall "$2"