Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #!/bin/bash
  2. # Launches various calibre libraries on puma # change this to your hostname
  3.  
  4.  
  5. # check that we are on puma
  6. if [ "$HOSTNAME" != puma ]; then # change this to your hostname
  7. echo "This should only be run on puma!" # change this to your hostname
  8. exit 1
  9. fi
  10.  
  11. # echo "Hostname check passed."
  12.  
  13. ## Root location of all libraries
  14. ROOT='/storage/data1/Media/Books/'
  15.  
  16. ## Libraries by name
  17. SCIAM='Scientific American'
  18. TECH='Technology eBooks'
  19. ENGFI='English Fiction'
  20. ENGNFI='English Nonfiction'
  21. KIN='Kindle Library'
  22. MAIN='Main Calibre Library'
  23. BUSI='Business Book Summaries'
  24. FRFI='French Fiction'
  25.  
  26. ## Calibre command
  27. COMMAND='/usr/bin/calibre-server --daemonize'
  28.  
  29.  
  30.  
  31.  
  32. ## Stops all libraries
  33. function stop() {
  34. # purge all prior instances
  35. if [[ ! -z $(pgrep calibre-server) ]]
  36. then killall calibre-server
  37. echo "Stopped all libraries!"
  38. fi
  39. }
  40.  
  41.  
  42.  
  43.  
  44. ## Starts all libraries
  45. function start() {
  46. echo $COMMAND --port 9001 --with-library "$ROOT$SCIAM"
  47. # launch various libraries
  48. $($COMMAND --port 9001 --with-library "$ROOT$SCIAM")
  49. echo "launched" $SCIAM
  50. $($COMMAND --port 9002 --with-library "$ROOT$TECH")
  51. echo "launched" $TECH
  52. $($COMMAND --port 9003 --with-library "$ROOT$ENGFI")
  53. echo "launched" $ENGFI
  54. $($COMMAND --port 9004 --with-library "$ROOT$ENGNFI")
  55. echo "launched" $ENGNFI
  56. $($COMMAND --port 9005 --with-library "$ROOT$KIN")
  57. echo "launched" $KIN
  58. $($COMMAND --port 9006 --with-library "$ROOT$MAIN")
  59. echo "launched" $MAIN
  60. $($COMMAND --port 9007 --with-library "$ROOT$BUSI")
  61. echo "launched" $BUSI
  62. $($COMMAND --port 9008 --with-library "$ROOT$FRFI")
  63. echo "launched" $FRFI
  64.  
  65. ## Inform Success
  66. echo "All libraries launched!"
  67. }
  68.  
  69.  
  70. ## Returns status of calibre daemons
  71. function status() {
  72. if [[ ! -z $(pgrep calibre-server) ]]
  73. then
  74. echo "Status: running"
  75. else
  76. echo "Status: stopped"
  77. fi
  78. }
  79.  
  80.  
  81.  
  82. ## Main
  83. if [[ "$1" == "start" ]]
  84. then
  85. echo "Starting all services..."
  86. start
  87. elif [[ "$1" == "stop" ]]
  88. then
  89. echo "Stopping all services..."
  90. stop
  91. elif [[ "$1" == "restart" ]]
  92. then
  93. echo "Restarting all services..."
  94. stop
  95. start
  96. elif [[ "$1" == "status" ]]
  97. then
  98. status
  99. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement