mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fixes and changes to calibre-portable.sh
Fixes #1426222 [Updated version of calibre-portable.sh](https://bugs.launchpad.net/calibre/+bug/1426222)
This commit is contained in:
parent
00b21d8d71
commit
973e0e9d6f
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# Calibre-Portable.sh
|
# Calibre-Portable.sh
|
||||||
# ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
|
# ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬
|
||||||
#
|
#
|
||||||
@ -18,9 +18,9 @@
|
|||||||
#
|
#
|
||||||
# If trying to run off a USB stick then the folder structure
|
# If trying to run off a USB stick then the folder structure
|
||||||
# shown below is recommended (relative to the location of
|
# shown below is recommended (relative to the location of
|
||||||
# this script file). This can structure can also be used
|
# this script file). This structure can also be used when
|
||||||
# when running of a local hard disk if you want to get the
|
# running of a local hard disk if you want to get the level
|
||||||
# level of control this script file provides.
|
# of control this script file provides.
|
||||||
# - Calibre Location of linux program files
|
# - Calibre Location of linux program files
|
||||||
# - CalibreConfig Location of Configuration files
|
# - CalibreConfig Location of Configuration files
|
||||||
# - CalibreLibrary Location of Books and metadata
|
# - CalibreLibrary Location of Books and metadata
|
||||||
@ -28,74 +28,78 @@
|
|||||||
#
|
#
|
||||||
# This script file is designed so that if you create the recommended
|
# This script file is designed so that if you create the recommended
|
||||||
# folder structure then it can be used 'as is' without modification.
|
# folder structure then it can be used 'as is' without modification.
|
||||||
|
# To use your own structure, simply set the variables at the head of each block.
|
||||||
#
|
#
|
||||||
# More information on the Environment Variables used by Calibre can
|
# More information on the Environment Variables used by Calibre can
|
||||||
# be found at:
|
# be found at:
|
||||||
# http://manual.calibre-ebook.com/customize.html#environment-variables
|
# http://manual.calibre-ebook.com/customize.html#environment-variables
|
||||||
#
|
#
|
||||||
# The documentation for this file in the Calibre manual can be found at:
|
|
||||||
# http://manual.calibre-ebook.com/portable.html
|
|
||||||
#
|
|
||||||
# NOTE: It is quite possible to have both Windows and Linux binaries on the same
|
# NOTE: It is quite possible to have both Windows and Linux binaries on the same
|
||||||
# USB stick but set up to use the same calibre settings otherwise.
|
# USB stick but set up to use the same calibre settings otherwise.
|
||||||
# In this case you use:
|
# In this case you use:
|
||||||
# - calibre-portable.bat to run the Windows version
|
# - calibre-portable.bat to run the Windows version
|
||||||
# = calibre-portable.sh to run the Linux version
|
# - calibre-portable.sh to run the Linux version
|
||||||
#
|
#
|
||||||
# CHANGE HISTORY
|
# CHANGE HISTORY
|
||||||
# ¬¬¬¬¬¬¬¬¬¬¬¬¬¬
|
# ¬¬¬¬¬¬¬¬¬¬¬¬¬¬
|
||||||
# 22 Jan 2012 itimpi - First version based on the calibre-portable.bat file for Windows
|
# 22 Jan 2012 itimpi ----- First version based on the calibre-portable.bat file for Windows
|
||||||
# It should have identical functionality but for a linux environment.
|
# It should have identical functionality but for a linux environment.
|
||||||
# It might work on MacOS but that has not been validated
|
# It might work on MacOS but that has not been validated.
|
||||||
|
#
|
||||||
|
# 02 Feb 2015 eschwartz -- Fix path issues, allow setting each location in one variable, allow
|
||||||
|
# specifying a list of libraries in descending order of priority.
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------
|
# ------------------------------------------------
|
||||||
# Set up Calibre Config folder
|
# Set up Calibre Config folder
|
||||||
#
|
#
|
||||||
# This is where user specific settings
|
# This is where user specific settings are stored.
|
||||||
# are stored.
|
# ------------------------------------------------
|
||||||
# -------------------------------------
|
|
||||||
|
|
||||||
if [ -d CalibreConfig ]
|
CONFIG_DIR="$(pwd)/CalibreConfig"
|
||||||
then
|
|
||||||
CALIBRE_CONFIG_DIRECTORY=`pwd`/CalibreConfig
|
if [[ -d "${CONFIG_DIR}" ]]; then
|
||||||
echo "CONFIG FILES: "`pwd`"/CalibreConfig"
|
export CALIBRE_CONFIG_DIRECTORY="${CONFIG_DIR}"
|
||||||
export CALIBRE_CONFIG_DIRECTORY
|
echo "CONFIG FILES: ${CONFIG_DIR}"
|
||||||
|
else
|
||||||
|
echo -e "\033[0;31mCONFIG FILES: Not found\033[0m"
|
||||||
fi
|
fi
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Specify Location of ebooks
|
# Specify Location of ebooks
|
||||||
#
|
#
|
||||||
# Location where Book files are located
|
# Location where Book files are located.
|
||||||
# Either set explicit path, or if running from a USB stick
|
# Either set explicit path, or if running from a USB stick
|
||||||
# a relative path can be used to avoid need to know the
|
# a relative path can be used to avoid need to know the
|
||||||
# drive letter of the USB stick.
|
# drive letter of the USB stick.
|
||||||
#
|
#
|
||||||
# Comment out any of the following that are not to be used
|
# Specify a list of libraries here, by adding new elements to the
|
||||||
# (although leaving them in does not really matter)
|
# array. The first value of LIBRARY_DIRS that is an existing directory
|
||||||
|
# will be used as the current calibre library.
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
if [ -d /eBooks/CalibreLibrary ]
|
LIBRARY_DIRS[0]="/path/to/first/CalibreLibrary"
|
||||||
then
|
LIBRARY_DIRS[1]="/path/to/second/CalibreLibrary"
|
||||||
SET CALIBRE_LIBRARY_DIRECTORY=/eBOOKS/CalibreLibrary
|
LIBRARY_DIRS[2]="$(pwd)/CalibreLibrary"
|
||||||
echo "LIBRARY FILES: /eBOOKS/CalibreLibrary"
|
|
||||||
export LIBRARY_FILES
|
|
||||||
fi
|
|
||||||
if [ -d `pwd`/CalibreLibrary ]
|
|
||||||
then
|
|
||||||
CALIBRE_LIBRARY_DIRECTORY=`pwd`/CalibreLibrary
|
|
||||||
echo "LIBRARY FILES: "`pwd`"/CalibreLibrary"
|
|
||||||
export LIBRARY_FILES
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
for LIBRARY_DIR in "${LIBRARY_DIRS[@]}"; do
|
||||||
|
if [[ -d "${LIBRARY_DIR}" ]]; then
|
||||||
|
export CALIBRE_LIBRARY_DIRECTORY="${LIBRARY_DIR}"
|
||||||
|
echo "LIBRARY FILES: ${CALIBRE_LIBRARY_DIRECTORY}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[[ -z "${CALIBRE_LIBRARY_DIRECTORY}" ]] && echo -e "\033[0;31mLIBRARY FILES: Not found\033[0m"
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Specify Location of metadata database (optional)
|
# Specify Location of metadata database (optional)
|
||||||
#
|
#
|
||||||
# Location where the metadata.db file is located. If not set
|
# Location where the metadata.db file is located. If not set
|
||||||
# then the same location as Books files will be assumed. This.
|
# then the same location as Book files will be assumed. This
|
||||||
# options is typically used to get better performance when the
|
# option is typically used to get better performance when the
|
||||||
# Library is on a (slow) network drive. Putting the metadata.db
|
# Library is on a (slow) network drive. Putting the metadata.db
|
||||||
# file locally then makes gives a big performance improvement.
|
# file locally then makes gives a big performance improvement.
|
||||||
#
|
#
|
||||||
@ -105,28 +109,26 @@ fi
|
|||||||
# is at the same location as the book files.
|
# is at the same location as the book files.
|
||||||
#
|
#
|
||||||
# Another point to watch is that plugins can cause problems
|
# Another point to watch is that plugins can cause problems
|
||||||
# as they often store absolute path information
|
# as they often store absolute path information.
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
if [ -d `pwd`/CalibreMetadata/metadata.db ]
|
METADATA_DIR="$(pwd)/CalibreMetadata"
|
||||||
then
|
|
||||||
if [ $CALIBRE_LIBRARY_DIRECTORY != `pwd`/CalibreMetadata ]
|
if [[ -f "${METADATA_DIR}/metadata.db" && "$CALIBRE_LIBRARY_DIRECTORY" != "${METADATA_DIR}" ]]; then
|
||||||
then
|
export CALIBRE_OVERRIDE_DATABASE_PATH="${METADATA_DIR}/metadata.db"
|
||||||
CALIBRE_OVERRIDE_DATABASE_PATH=`pwd`/CalibreMetadata/metadata.db
|
echo "DATABASE: ${METADATA_DIR}/metadata.db"
|
||||||
echo DATABASE: `pwd`"/CalibreMetadata/metadata.db"
|
|
||||||
export CALIBRE_OVERRIDE_DATABASE
|
|
||||||
echo
|
echo
|
||||||
echo "***CAUTION*** Library Switching will be disabled"
|
echo -e "\033[0;31m***CAUTION*** Library Switching will be disabled\033[0m"
|
||||||
echo
|
echo
|
||||||
fi
|
echo "--------------------------------------------------"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Specify Location of source (optional)
|
# Specify Location of source (optional)
|
||||||
#
|
#
|
||||||
# It is easy to run Calibre from source
|
# It is easy to run Calibre from source.
|
||||||
# Just set the environment variable to where the source is located
|
# Just set the environment variable to where the source is located.
|
||||||
# When running from source the GUI will have a '*' after the version.
|
# When running from source the GUI will have a '*' after the version
|
||||||
# number that is displayed at the bottom of the Calibre main screen.
|
# number that is displayed at the bottom of the Calibre main screen.
|
||||||
#
|
#
|
||||||
# More information on setting up a development environment can
|
# More information on setting up a development environment can
|
||||||
@ -134,39 +136,49 @@ fi
|
|||||||
# http://manual.calibre-ebook.com/develop.html#develop
|
# http://manual.calibre-ebook.com/develop.html#develop
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
if [ -d CalibreSource/src ]
|
SRC_DIR="$(pwd)/CalibreSource/src"
|
||||||
then
|
|
||||||
CALIBRE_DEVELOP_FROM=`pwd`/CalibreSource/src
|
if [[ -d "${SRC_DIR}" ]]; then
|
||||||
echo "SOURCE FILES: "`pwd`"/CalibreSource/src"
|
export CALIBRE_DEVELOP_FROM="${SRC_DIR}"
|
||||||
export CALIBRE_DEVELOP_FROM
|
echo "SOURCE FILES: ${SRC_DIR}"
|
||||||
else
|
else
|
||||||
echo "SOURCE FILES: *** Not being Used ***"
|
echo "SOURCE FILES: *** Not being Used ***"
|
||||||
fi
|
fi
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Specify Location of calibre linux binaries (optional)
|
# Specify Location of calibre linux binaries (optional)
|
||||||
#
|
#
|
||||||
# To avoid needing Calibre to be set in the search path, ensure
|
# To avoid needing Calibre to be set in the search path, ensure
|
||||||
# that Calibre Program Files is current directory when starting.
|
# that if Calibre Program Files exists, we manually specify the
|
||||||
# The following test falls back to using search path.
|
# location of the binary.
|
||||||
|
# The following test falls back to using the search path, or you
|
||||||
|
# can specifically use the search path by leaving the BIN_DIR blank.
|
||||||
#
|
#
|
||||||
# This folder can be populated by copying the /opt/calibre folder
|
# This folder can be populated by copying the /opt/calibre folder
|
||||||
# from an existing installation or by installing direct to here.
|
# from an existing installation or by installing direct to here.
|
||||||
#
|
#
|
||||||
# NOTE. Do not try and put both Windows and Linux binaries into
|
# NOTE. Do not try and put both Windows and Linux binaries into
|
||||||
# same folder as this can cause problems.
|
# the same folder as this can cause problems.
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
if [ -d `pwd`/Calibre ]
|
BIN_DIR="$(pwd)/calibre"
|
||||||
then
|
|
||||||
cd `pwd`/Calibre
|
|
||||||
echo "PROGRAM FILES: "`pwd`
|
|
||||||
else
|
|
||||||
echo "PROGRAM FILES: *** Using System search path ***"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [[ -d "${BIN_DIR}" ]]; then
|
||||||
|
CALIBRE="${BIN_DIR}/calibre"
|
||||||
|
echo "PROGRAM FILES: ${BIN_DIR}"
|
||||||
|
elif [[ -z "${BIN_DIR}" ]]; then
|
||||||
|
CALIBRE="calibre"
|
||||||
|
echo "PROGRAM FILES: Using System search path"
|
||||||
|
else
|
||||||
|
CALIBRE="calibre"
|
||||||
|
echo "PROGRAM FILES: No portable copy found."
|
||||||
|
echo "To intall a portable copy, run the following command:"
|
||||||
|
echo "wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py" \
|
||||||
|
"| python -c \"import sys; main=lambda x,y:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main('$(pwd)/calibre', True)\""
|
||||||
|
echo -e "\033[0;31m*** Using System search path instead***\033[0m"
|
||||||
|
fi
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Location of Calibre Temporary files (optional)
|
# Location of Calibre Temporary files (optional)
|
||||||
@ -179,14 +191,13 @@ fi
|
|||||||
# If not set Calibre uses the normal system TEMP location
|
# If not set Calibre uses the normal system TEMP location
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
CALIBRE_TEMP_DIR=/tmp/CALIBRE_TEMP
|
CALIBRE_TEMP_DIR="/tmp/CALIBRE_TEMP"
|
||||||
echo "TEMPORARY FILES: $CALIBRE_TEMP_DIR"
|
|
||||||
|
echo "TEMPORARY FILES: ${CALIBRE_TEMP_DIR}"
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
rm -rf "${CALIBRE_TEMP_DIR}"
|
||||||
|
mkdir "${CALIBRE_TEMP_DIR}"
|
||||||
|
|
||||||
if [ -d "$CALIBRE_TEMP_DIR" ]
|
|
||||||
then
|
|
||||||
rm -fr "$CALIBRE_TEMP_DIR"
|
|
||||||
fi
|
|
||||||
mkdir "$CALIBRE_TEMP_DIR"
|
|
||||||
# set the following for any components that do
|
# set the following for any components that do
|
||||||
# not obey the CALIBRE_TEMP_DIR setting
|
# not obey the CALIBRE_TEMP_DIR setting
|
||||||
|
|
||||||
@ -194,12 +205,13 @@ mkdir "$CALIBRE_TEMP_DIR"
|
|||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Set the Interface language (optional)
|
# Set the Interface language (optional)
|
||||||
#
|
#
|
||||||
# If not set Calibre uses the language set in Preferences
|
# Remove the if test to use this. ;)
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
CALIBRE_OVERRIDE_LANG=EN
|
if false; then
|
||||||
echo "INTERFACE LANGUAGE: $CALIBRE_OVERRIDE_LANG"
|
export CALIBRE_OVERRIDE_LANG="EN"
|
||||||
export CALIBRE_OVERRIDE_LANG
|
echo "INTERFACE LANGUAGE: ${CALIBRE_OVERRIDE_LANG}"
|
||||||
|
fi
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
# The following gives a chance to check the settings before
|
# The following gives a chance to check the settings before
|
||||||
@ -215,6 +227,5 @@ read DUMMY
|
|||||||
# Start up the calibre program.
|
# Start up the calibre program.
|
||||||
# --------------------------------------------------------
|
# --------------------------------------------------------
|
||||||
|
|
||||||
echo "Starting up Calibre"
|
echo "Starting up Calibre from portable directory \"$(pwd)\""
|
||||||
echo `pwd`
|
$CALIBRE --with-library "$CALIBRE_LIBRARY_DIRECTORY"
|
||||||
calibre --with-library "$CALIBRE_LIBRARY_DIRECTORY"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user