Advertisement
Rnery

Calibre

Nov 12th, 2023
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | Source Code | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. check_root() {
  4.     [ "$EUID" -ne 0 ] && echo "Por favor, execute como root."; exit 1
  5. }
  6.  
  7. # Configura o serviço do Calibre-Web
  8. configure_calibre_web_service() {
  9.     local calibre_web_path="$1"
  10.     local virtualenv_path="$2"
  11.     local service_file="$3"
  12.  
  13.     cat << EOF > "$service_file"
  14. [Unit]
  15. Description=Calibre-Web Service
  16. After=network.target
  17.  
  18. [Service]
  19. User=root
  20. WorkingDirectory=$calibre_web_path
  21. ExecStart=$virtualenv_path/bin/python $calibre_web_path/cps
  22.  
  23. [Install]
  24. WantedBy=multi-user.target
  25. EOF
  26.  
  27.     enable_start_service "$service_file"
  28. }
  29.  
  30. # Habilita e inicia o serviço
  31. enable_start_service() {
  32.     local service_file="$1"
  33.     systemctl enable calibre-web
  34.     systemctl start calibre-web
  35.     echo "Serviço do Calibre-Web configurado para iniciar automaticamente."
  36. }
  37.  
  38. main() {
  39.     check_root
  40.  
  41.     local calibre_path="/root/calibre-web"
  42.     local virtualenv_path="/root/calibre-web/venv"
  43.     local service_file="/etc/systemd/system/calibre-web.service"
  44.  
  45.     configure_calibre_web_service "$calibre_path" "$virtualenv_path" "$service_file"
  46. }
  47.  
  48. main
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement