Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Launches various calibre libraries on puma # change this to your hostname
- # check that we are on puma
- if [ "$HOSTNAME" != puma ]; then # change this to your hostname
- echo "This should only be run on puma!" # change this to your hostname
- exit 1
- fi
- # echo "Hostname check passed."
- ## Root location of all libraries
- ROOT='/storage/data1/Media/Books/'
- ## Libraries by name
- SCIAM='Scientific American'
- TECH='Technology eBooks'
- ENGFI='English Fiction'
- ENGNFI='English Nonfiction'
- KIN='Kindle Library'
- MAIN='Main Calibre Library'
- BUSI='Business Book Summaries'
- FRFI='French Fiction'
- ## Calibre command
- COMMAND='/usr/bin/calibre-server --daemonize'
- ## Stops all libraries
- function stop() {
- # purge all prior instances
- if [[ ! -z $(pgrep calibre-server) ]]
- then killall calibre-server
- echo "Stopped all libraries!"
- fi
- }
- ## Starts all libraries
- function start() {
- echo $COMMAND --port 9001 --with-library "$ROOT$SCIAM"
- # launch various libraries
- $($COMMAND --port 9001 --with-library "$ROOT$SCIAM")
- echo "launched" $SCIAM
- $($COMMAND --port 9002 --with-library "$ROOT$TECH")
- echo "launched" $TECH
- $($COMMAND --port 9003 --with-library "$ROOT$ENGFI")
- echo "launched" $ENGFI
- $($COMMAND --port 9004 --with-library "$ROOT$ENGNFI")
- echo "launched" $ENGNFI
- $($COMMAND --port 9005 --with-library "$ROOT$KIN")
- echo "launched" $KIN
- $($COMMAND --port 9006 --with-library "$ROOT$MAIN")
- echo "launched" $MAIN
- $($COMMAND --port 9007 --with-library "$ROOT$BUSI")
- echo "launched" $BUSI
- $($COMMAND --port 9008 --with-library "$ROOT$FRFI")
- echo "launched" $FRFI
- ## Inform Success
- echo "All libraries launched!"
- }
- ## Returns status of calibre daemons
- function status() {
- if [[ ! -z $(pgrep calibre-server) ]]
- then
- echo "Status: running"
- else
- echo "Status: stopped"
- fi
- }
- ## Main
- if [[ "$1" == "start" ]]
- then
- echo "Starting all services..."
- start
- elif [[ "$1" == "stop" ]]
- then
- echo "Stopping all services..."
- stop
- elif [[ "$1" == "restart" ]]
- then
- echo "Restarting all services..."
- stop
- start
- elif [[ "$1" == "status" ]]
- then
- status
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement