servis.ex 550 B

123456789101112131415161718192021222324252627282930313233
  1. defmodule Servis do
  2. def status(service) do
  3. durum='servis #{service} durum' |> :os.cmd |> to_string |> String.split("\n")
  4. |> Enum.member?("aktif")
  5. case durum do
  6. true -> :true
  7. false -> :false
  8. end
  9. end
  10. @doc """
  11. servis başlatır
  12. """
  13. def start(service) do
  14. 'servis #{service} start' |> :os.cmd
  15. service |> status
  16. end
  17. def stop(service) do
  18. 'servis #{service} stop' |> :os.cmd
  19. service |> status
  20. end
  21. def info(service) do
  22. File.read!("/etc/init.d/" <> service)
  23. end
  24. end