#!/bin/bash JVTV_PATH="/usr/local/share" JVTV_BIN="/usr/local/bin" JVTV_SETFOLDER="$HOME/.jvtv" SCRIPTNAME=`echo $0 |sed 's/.*\///'` #echo $SCRIPTNAME cd `echo $0 | sed 's/setup.sh//'` # Test uid and command line options if (( $# == 2 )); then JVTV_PATH=$1 JVTV_BIN=$2 fi if (( UID == 0 )); then echo echo "Start install as root..." echo else if (( $# != 2 )); then echo echo "You are not root!" echo echo "Try run ./$SCRIPTNAME with \"sudo su -\"," echo "or as user start this script with command line" echo "options. For example:" echo "./$SCRIPTNAME install_dir binary_dir" echo "install_dir: Where I create \"jvtv\ folder." echo "binary_dir: Where we copy start script." echo echo "Please use full directory path name!!!" echo exit 0 else echo echo "Start install as user..." echo fi fi # Test JAVA and JAVA_HOME TEST_JAVA=`which java` if [ -z "$TEST_JAVA" ]; then echo "Java is not installed, or JAVA_HOME not set." echo "Add your \$JAVA_HOME/bin folder to PATH environment variable." exit else echo echo "Java version: `java -version`" echo $JAVA_HOME echo fi # Create (If not exist) $HOME/.jvtv if [ -d $JVTV_SETFOLDER ]; then echo "$JVTV_SETFOLDER exist." echo else mkdir $JVTV_SETFOLDER echo "$JVTV_SETFOLDER created!" echo fi # Test folders function test_fold { res="" if [ -d $1 ]; then echo "Folder exist: $1" if [ -w $1 ]; then echo "Folder writable: $1" res="ok" else echo "Folder read-oly: $1" exit 0 fi else echo "$1 does not exist. Try create it." mkdir -p $1 if [ -d $1 ]; then echo "Created folder: $1" res="ok" fi fi } test_fold $JVTV_PATH test_fold $JVTV_PATH/jvtv JVTV_PATH="$JVTV_PATH/jvtv" echo "JVTV_PATH=$JVTV_PATH" if [ $res == "ok" ]; then `cp ./*class $JVTV_PATH/` `cp ./*form $JVTV_PATH/` `cp -r ./doc $JVTV_PATH/` `cp -r ./images $JVTV_PATH/` else echo "Check your folder, and permission!!!" exit 0 fi # Create start script test_fold $JVTV_BIN if [ $res == "ok" ]; then echo "Create start script" echo "cd $JVTV_PATH" > $JVTV_BIN/jvtv.sh echo "export JVTV_PATH=\"$JVTV_PATH\"" > $JVTV_BIN/jvtv.sh echo "echo \"\$JVTV_PATH\"" >> $JVTV_BIN/jvtv.sh echo "cd \$JVTV_PATH" >> $JVTV_BIN/jvtv.sh echo "$JAVA_HOME/bin/java TvControl \"\$JVTV_PATH\"" >> $JVTV_BIN/jvtv.sh echo "cd -" >> $JVTV_BIN/jvtv.sh `chmod 755 $JVTV_BIN/jvtv.sh` echo "#######################################" echo "#####Start jvtv with this command:#####" echo "$JVTV_BIN/jvtv.sh" echo echo "Create jvtv menu item template." cp ./template/jvtv.deskto ./template/jvtv.desktop echo "Exec='$JVTV_BIN/jvtv.sh'" >> ./template/jvtv.desktop echo "Icon=$JVTV_PATH/images/tvcard.png" >> ./template/jvtv.desktop else echo "Error! Please check your binary folder." fi echo "Do you want to create menu icon? (Multimedia/jvtv)" echo "y/n" OPTIONS="Yes No" select opt in $OPTIONS; do if [ "$opt" = "No" ]; then echo "Have a nice day!" elif [ "$opt" = "Yes" ]; then if (( UID == 0 )); then cp ./template/jvtv.desktop /usr/share/applnk/Multimedia else cp ./template/jvtv.desktop $HOME/.kde/share/applnk/Multimedia fi echo "Icon created" else echo "Bad answer! Please enter your answer's number!" fi done if (( UID == 0 )); then echo "now searching for ptune.pl and record-v4l2.pl." echo "I want to link them into your /usr/local/bin" echo "I presume they are located unser the /usr tree" echo "searching... please wait" cd /usr ln `find | grep ptune.pl` /usr/local/bin ln `find | grep record-v4l2.pl` /usr/local/bin fi exit #/usr/share/applnk/Multimedia #$HOME/.kde/share/applnk/Multimedia