SimplePanoramaViewer/utility.sh

69 lines
1.5 KiB
Bash
Executable File

#!/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"
echo " -u, --uninstall Uninstall SimplePanoramaViewer frome PATH_TO_INSTALL_DIR"
}
check_dir()
{
if [ -z "$1" ]; then
echo "You need to pass a directory"
exit
fi
}
install()
{
DIR=$1
check_dir "$DIR"
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"
echo "#!/bin/bash
$DIR/share/SimplePanoramaViewer/SimplePanoramaViewer \"\$@\"" > "$DIR/bin/SimplePanoramaViewer"
chmod a+x "$DIR/bin/SimplePanoramaViewer"
sudo chmod -R a+r "$DIR/share/SimplePanoramaViewer"
}
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"
}
case "$1" in
"-h" | "--help")
print_help
;;
"-i" | "--install")
install "$2"
;;
"-u" | "--uninstall")
uninstall "$2"
;;
*)
print_help
;;
esac