File: //usr/local/bin/ffmpeg-switcher.sh
#!/bin/bash
####################################
#
# MojoHost
# Script ffmpeg-switcher.sh
#
#
# ffmpeg version swticher
#
# allows for changing the symlink between ffmpeg static compile versions
#
#######################################
# changelog
# Greg Martin Jan 29 2013 -- initial release
#########################################
function ffSym () {
# Set the prompt for the select command
PS3="Type a number or 'q' to quit: "
if [ -h /usr/local/bin/ffmpeg ]
then
echo "you are currently using `readlink /usr/local/bin/ffmpeg`"
else
echo "ffmpeg is currently not linked to any version"
fi
echo ""
echo "To select or change ffmpeg versions please select from the menu below"
# Create a list of files to display
fileList=$( ls -1 /usr/local/bin/ffmpeg.* )
# Show a menu and ask for input. If the user entered a valid choice,
# then invoke the editor on that file
select fileName in $fileList; do
if [ -n "$fileName" ]; then
echo "you have selected "${fileName}
if [ -h /usr/local/bin/ffmpeg ]
then
unlink /usr/local/bin/ffmpeg
fi
ln -s ${fileName} /usr/local/bin/ffmpeg
fi
break
done
}
#ffmpeg exists
if [ -a /usr/local/bin/ffmpeg ]
then
#ffmpeg exists and is a symlink
if [ -h /usr/local/bin/ffmpeg ]
then
##there are other symlinks available
if [ $( ls -1 /usr/local/bin/ffmpeg.*|wc -l ) -gt 1 ]
then
ffSym
else
echo "ffmpeg exists and is a symlink,, but there are no other options available"
echo "looks like this was a non-static compile"
echo "please run the installer from"
echo "fs01/ffm/static"
fi
else
echo "ffmpeg exists, but is not a symlink."
echo "maybe this was a rpm install?"
echo "please run the installer from"
echo "fs01/ffm/static"
fi
elif [ $( ls -1 /usr/local/bin/ffmpeg.*|wc -l ) -gt 1 ]
then
ffSym
else
echo "ffmpeg does not exist"
echo "please run the installer from"
echo "fs01/ffm/static"
fi