95 lines
1.9 KiB
Bash
Executable File
95 lines
1.9 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 from PATH_TO_INSTALL_DIR"
|
|
echo " -p, --package Generate a package for SimplePanoramaViewer"
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
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"
|
|
}
|
|
|
|
case "$1" in
|
|
"-h" | "--help")
|
|
print_help
|
|
;;
|
|
"-i" | "--install")
|
|
install "$2"
|
|
;;
|
|
"-u" | "--uninstall")
|
|
uninstall "$2"
|
|
;;
|
|
"-p" | "--package")
|
|
package
|
|
;;
|
|
*)
|
|
print_help
|
|
;;
|
|
esac
|