Merge branch 'master' of ssh://git.karchnu.fr:2202/WeirdOS/service
commit
79e2b3253c
10
project.zsh
10
project.zsh
|
@ -21,12 +21,22 @@ type[src/config.cr]=script
|
||||||
sources[src/config.cr]=src/config.cr.in
|
sources[src/config.cr]=src/config.cr.in
|
||||||
install[src/config.cr]=false
|
install[src/config.cr]=false
|
||||||
auto[src/config.cr]=true # Don’t display it in `make help`.
|
auto[src/config.cr]=true # Don’t display it in `make help`.
|
||||||
|
chmod[src/config.cr]=0644
|
||||||
|
|
||||||
for file in services/*.spec; do
|
for file in services/*.spec; do
|
||||||
targets+=($file)
|
targets+=($file)
|
||||||
type[$file]=script
|
type[$file]=script
|
||||||
install[$file]='$(SHAREDIR)/services'
|
install[$file]='$(SHAREDIR)/services'
|
||||||
auto[$file]=true
|
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
|
done
|
||||||
|
|
||||||
# FIXME: This should be upstreamed.
|
# FIXME: This should be upstreamed.
|
||||||
|
|
|
@ -5,6 +5,8 @@ RC_DIRECTORY = "@SYSCONFDIR@/rc/services"
|
||||||
LOG_DIRECTORY = "@VARSTATEDIR@/log"
|
LOG_DIRECTORY = "@VARSTATEDIR@/log"
|
||||||
SERVICES_DIRECTORY = "@SHAREDIR@/services"
|
SERVICES_DIRECTORY = "@SHAREDIR@/services"
|
||||||
ENVIRONMENTS_DIRECTORY = "@SYSCONFDIR@/rc/environments"
|
ENVIRONMENTS_DIRECTORY = "@SYSCONFDIR@/rc/environments"
|
||||||
|
SYSTEM_CONFIGURATION_DIRECTORY = "@SYSCONFDIR@"
|
||||||
|
SHARED_DATA_DIRECTORY = "@SHAREDIR@"
|
||||||
OWN_LIBEXEC_DIR = "@LIBEXECDIR@/service"
|
OWN_LIBEXEC_DIR = "@LIBEXECDIR@/service"
|
||||||
CACHE_DIRECTORY = "@VARSTATEDIR@/cache"
|
CACHE_DIRECTORY = "@VARSTATEDIR@/cache"
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
require "crinja"
|
require "crinja"
|
||||||
|
|
||||||
|
require "./config.cr"
|
||||||
|
|
||||||
def sanitize_path(path)
|
def sanitize_path(path)
|
||||||
path.gsub /\/\/+/, "/"
|
path.gsub /\/\/+/, "/"
|
||||||
end
|
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)))
|
def generate(template, target : String, options : Hash(String, String | Array(String) | Crinja::Callable::Instance | Hash(String, String)))
|
||||||
target_file = File.open target, "w"
|
target_file = File.open target, "w"
|
||||||
|
|
||||||
# FIXME: Alter default sources at build-time.
|
|
||||||
# FIXME: We’ll want a way to alter those context-wide.
|
|
||||||
sources = [
|
sources = [
|
||||||
"/etc/templates",
|
"#{SYSTEM_CONFIGURATION_DIRECTORY}/templates",
|
||||||
"/usr/share/templates"
|
"#{SHARED_DATA_DIRECTORY}/templates"
|
||||||
]
|
]
|
||||||
|
|
||||||
sources = sources
|
sources = sources
|
||||||
|
|
|
@ -129,7 +129,8 @@ begin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif args[0] == "status"
|
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,
|
output: Process::Redirect::Inherit,
|
||||||
error: Process::Redirect::Inherit
|
error: Process::Redirect::Inherit
|
||||||
return_value = (child.exit_status / 256).to_i
|
return_value = (child.exit_status / 256).to_i
|
||||||
|
|
|
@ -10,10 +10,33 @@ Service.load RC_DIRECTORY
|
||||||
LibC.setuid 0
|
LibC.setuid 0
|
||||||
LibC.setgid 0
|
LibC.setgid 0
|
||||||
|
|
||||||
Service.get_by_id(ARGV[0]).try do |service|
|
services = ARGV
|
||||||
puts service.status PID_DIRECTORY
|
if services.size == 0
|
||||||
exit 0
|
services = Service.all
|
||||||
|
else
|
||||||
|
services = services.map do |id|
|
||||||
|
Service.get_by_id id
|
||||||
|
end
|
||||||
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue