postinst 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -e
  3. if [ "$1" = configure ]; then
  4. INITSYS=$(ls -al /proc/1/exe | awk -F' ' '{print $NF}' | awk -F'/' '{print $NF}')
  5. ln -s /usr/lib/rustdesk/rustdesk /usr/bin/rustdesk
  6. if [ "systemd" == "$INITSYS" ]; then
  7. if [ -e /etc/systemd/system/rustdesk.service ]; then
  8. rm /etc/systemd/system/rustdesk.service /usr/lib/systemd/system/rustdesk.service /usr/lib/systemd/user/rustdesk.service >/dev/null 2>&1
  9. fi
  10. version=$(python3 -V 2>&1 | grep -Po '(?<=Python )(.+)')
  11. parsedVersion=$(echo "${version//./}")
  12. mkdir -p /usr/lib/systemd/system/
  13. cp /usr/share/rustdesk/files/systemd/rustdesk.service /usr/lib/systemd/system/rustdesk.service
  14. # try fix error in Ubuntu 18.04
  15. # Failed to reload rustdesk.service: Unit rustdesk.service is not loaded properly: Exec format error.
  16. # /usr/lib/systemd/system/rustdesk.service:10: Executable path is not absolute: pkill -f "rustdesk --"
  17. if [ -e /usr/bin/pkill ]; then
  18. sed -i "s|pkill|/usr/bin/pkill|g" /usr/lib/systemd/system/rustdesk.service
  19. fi
  20. systemctl daemon-reload
  21. systemctl enable rustdesk
  22. systemctl start rustdesk
  23. fi
  24. fi