SimplePanoramaViewer/utility.sh

102 lines
2.1 KiB
Bash
Raw Normal View History

2018-11-18 16:35:34 +00:00
#!/bin/bash
print_help()
{
echo "SimplePanoramaViewer utility script"
echo
echo "Use:"
echo " bash utility.sh OPTION [PATH_TO_INSTALL_DIR]"
echo
echo "Options:"
echo " -i, --install Install SimplePanoramaViewer in PATH_TO_INSTALL_DIR"
2018-11-18 16:56:37 +00:00
echo " -u, --uninstall Uninstall SimplePanoramaViewer from PATH_TO_INSTALL_DIR"
echo " -p, --package Generate a package for SimplePanoramaViewer"
2018-11-18 16:35:34 +00:00
}
check_dir()
{
if [ -z "$1" ]; then
echo "You need to pass a directory"
exit
fi
}
install()
{
2018-11-20 21:21:19 +00:00
DESTDIR=$1
check_dir "$DESTDIR"
if [ -z "$2" ]; then
PREFIX=$DESTDIR
else
PREFIX="$2"
DESTDIR=$DESTDIR$PREFIX
echo $DESTDIR
fi
2018-11-18 16:35:34 +00:00
2018-11-20 21:21:19 +00:00
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"
2018-11-18 16:35:34 +00:00
echo "#!/bin/bash
2018-11-20 21:21:19 +00:00
$PREFIX/share/SimplePanoramaViewer/SimplePanoramaViewer \"\$@\"" > "$DESTDIR/bin/SimplePanoramaViewer"
chmod a+x "$DESTDIR/bin/SimplePanoramaViewer"
chmod -R a+r "$DESTDIR/share/SimplePanoramaViewer"
2018-11-18 16:35:34 +00:00
}
uninstall()
{
DIR=$1
check_dir "$DIR"
rm "$DIR/bin/SimplePanoramaViewer"
rm -r "$DIR/share/SimplePanoramaViewer/"
rm "$DIR/share/applications/SimplePanoramaViewer.desktop"
rm "$DIR/share/mime/image/pjpg.xml"
}
2018-11-18 16:56:37 +00:00
package()
{
DIR="/tmp/SimplePanoramaViewer"
mkdir "$DIR"
cp SimplePanoramaViewer "$DIR"
cp -r css "$DIR"
cp -r html "$DIR"
cp -r js "$DIR"
chmod a+x "$DIR/SimplePanoramaViewer"
mkdir -p dist
cd /tmp || exit
tar Jcvf "SimplePanoramaViewer.tar.xz" "SimplePanoramaViewer"
cd - || exit
cp -f "$DIR.tar.xz" dist
rm -r "$DIR"
rm "$DIR.tar.xz"
}
2018-11-18 16:35:34 +00:00
case "$1" in
"-h" | "--help")
print_help
;;
"-i" | "--install")
2018-11-20 21:21:19 +00:00
install "$2" "$3"
2018-11-18 16:35:34 +00:00
;;
"-u" | "--uninstall")
uninstall "$2"
;;
2018-11-18 16:56:37 +00:00
"-p" | "--package")
package
;;
2018-11-18 16:35:34 +00:00
*)
print_help
;;
esac