_common.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. #
  3. # Common variables
  4. #
  5. pkg_dependencies="php5-fpm sipcalc hostapd iptables iw dnsmasq"
  6. nonfree_packages="firmware-linux-free firmware-linux-nonfree firmware-atheros firmware-realtek firmware-ralink firmware-libertas atmel-firmware zd1211-firmware"
  7. free_packages="firmware-linux-free"
  8. #
  9. # Helper to start/stop/.. a systemd service from a yunohost context,
  10. # *and* the systemd service itself needs to be able to run yunohost
  11. # commands.
  12. #
  13. # Hence the need to release the lock during the operation
  14. #
  15. # usage : ynh_systemctl yolo restart
  16. #
  17. function ynh_systemctl()
  18. {
  19. local ACTION="$1"
  20. local SERVICE="$2"
  21. local LOCKFILE="/var/run/moulinette_yunohost.lock"
  22. # Launch the action
  23. sudo systemctl "$ACTION" "$SERVICE" &
  24. local SYSCTLACTION=$!
  25. # Save and release the lock...
  26. cp $LOCKFILE $LOCKFILE.bkp.$$
  27. rm $LOCKFILE
  28. # Wait for the end of the action
  29. wait $SYSCTLACTION
  30. # Make sure the lock is released...
  31. while [ -f $LOCKFILE ]
  32. do
  33. sleep 0.1
  34. done
  35. # Restore the old lock
  36. mv $LOCKFILE.bkp.$$ $LOCKFILE
  37. }