install.sh 752 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. INSTALL_DIR="/opt/lenovo_fix"
  3. systemctl stop lenovo_fix.service &>/dev/null
  4. mkdir -p "$INSTALL_DIR" &>/dev/null
  5. set -e
  6. cd "$(dirname "$0")"
  7. echo "Copying config file..."
  8. if [ ! -f /etc/lenovo_fix.conf ]; then
  9. cp etc/lenovo_fix.conf /etc
  10. else
  11. echo "Config file already exists, skipping."
  12. fi
  13. echo "Copying systemd service file..."
  14. cp systemd/lenovo_fix.service /etc/systemd/system
  15. echo "Building virtualenv..."
  16. cp -n requirements.txt lenovo_fix.py mmio.py "$INSTALL_DIR"
  17. cd "$INSTALL_DIR"
  18. /usr/bin/python3 -m venv venv
  19. . venv/bin/activate
  20. pip install -r requirements.txt
  21. echo "Enabling and starting systemd service..."
  22. systemctl daemon-reload
  23. systemctl enable lenovo_fix.service
  24. systemctl restart lenovo_fix.service
  25. echo "All done."