Merge branch 'master' of ssh://git.karchnu.fr:2202/WeirdOS/service

master
Philippe PITTOLI 2019-10-24 12:04:19 +02:00
commit 79e2b3253c
5 changed files with 45 additions and 9 deletions

View File

@ -21,12 +21,22 @@ type[src/config.cr]=script
sources[src/config.cr]=src/config.cr.in
install[src/config.cr]=false
auto[src/config.cr]=true # Dont display it in `make help`.
chmod[src/config.cr]=0644
for file in services/*.spec; do
targets+=($file)
type[$file]=script
install[$file]='$(SHAREDIR)/services'
auto[$file]=true
chmod[$file]=0644
done
for file in templates/*.j2; do
targets+=($file)
type[$file]=script
install[$file]='$(SYSCONFDIR)/templates'
auto[$file]=true
chmod[$file]=0644
done
# FIXME: This should be upstreamed.

View File

@ -5,6 +5,8 @@ RC_DIRECTORY = "@SYSCONFDIR@/rc/services"
LOG_DIRECTORY = "@VARSTATEDIR@/log"
SERVICES_DIRECTORY = "@SHAREDIR@/services"
ENVIRONMENTS_DIRECTORY = "@SYSCONFDIR@/rc/environments"
SYSTEM_CONFIGURATION_DIRECTORY = "@SYSCONFDIR@"
SHARED_DATA_DIRECTORY = "@SHAREDIR@"
OWN_LIBEXEC_DIR = "@LIBEXECDIR@/service"
CACHE_DIRECTORY = "@VARSTATEDIR@/cache"

View File

@ -1,5 +1,7 @@
require "crinja"
require "./config.cr"
def sanitize_path(path)
path.gsub /\/\/+/, "/"
end
@ -41,11 +43,9 @@ class Configure::Context
def generate(template, target : String, options : Hash(String, String | Array(String) | Crinja::Callable::Instance | Hash(String, String)))
target_file = File.open target, "w"
# FIXME: Alter default sources at build-time.
# FIXME: Well want a way to alter those context-wide.
sources = [
"/etc/templates",
"/usr/share/templates"
"#{SYSTEM_CONFIGURATION_DIRECTORY}/templates",
"#{SHARED_DATA_DIRECTORY}/templates"
]
sources = sources

View File

@ -129,7 +129,8 @@ begin
end
end
elsif args[0] == "status"
child = Process.run "#{OWN_LIBEXEC_DIR}/status", [args[1]],
args.shift
child = Process.run "#{OWN_LIBEXEC_DIR}/status", args,
output: Process::Redirect::Inherit,
error: Process::Redirect::Inherit
return_value = (child.exit_status / 256).to_i

View File

@ -10,10 +10,33 @@ Service.load RC_DIRECTORY
LibC.setuid 0
LibC.setgid 0
Service.get_by_id(ARGV[0]).try do |service|
puts service.status PID_DIRECTORY
exit 0
services = ARGV
if services.size == 0
services = Service.all
else
services = services.map do |id|
Service.get_by_id id
end
end
exit 1
if services.size == 1
services[0]?.try do |service|
puts service.status PID_DIRECTORY
exit 0
end
exit 1
else
service_not_found = false
services.each do |service|
if service.nil?
service_not_found = true
else
puts "#{service.id}: #{service.status PID_DIRECTORY}"
end
end
exit 1 if service_not_found
end