summaryrefslogtreecommitdiff
path: root/hscript/script_e.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2023-10-20 05:20:11 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2023-10-20 05:20:11 -0500
commita9ccd9bc7e22573c5c327d3f75722ebd3cca6a82 (patch)
treee2a5bfcdcad071b5045586673b32f9849b8b6991 /hscript/script_e.cc
parent926aeb7fe8f50e5f1243b88a63d305c7d9f85371 (diff)
downloadhorizon-a9ccd9bc7e22573c5c327d3f75722ebd3cca6a82.tar.gz
horizon-a9ccd9bc7e22573c5c327d3f75722ebd3cca6a82.tar.bz2
horizon-a9ccd9bc7e22573c5c327d3f75722ebd3cca6a82.tar.xz
horizon-a9ccd9bc7e22573c5c327d3f75722ebd3cca6a82.zip
hscript: Allow svcenable to create new runlevels
This is going to be useful in general for some advanced use cases, but most importantly, it will allow us to define runlevels for live media. Ref: #346
Diffstat (limited to 'hscript/script_e.cc')
-rw-r--r--hscript/script_e.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/hscript/script_e.cc b/hscript/script_e.cc
index 3cdc78f..8f0f4b4 100644
--- a/hscript/script_e.cc
+++ b/hscript/script_e.cc
@@ -677,6 +677,25 @@ bool Script::execute() const {
for(const auto &svc : internal->svcs_enable) {
EXECUTE_OR_FAIL("svcenable", svc)
}
+#ifdef HAS_INSTALL_ENV
+ if(!opts.test(Simulate)) {
+ const std::set<std::string> def_runlevels{
+ "boot", "default", "empty", "nonetwork", "shutdown", "sysinit"
+ };
+ const auto rl_dir{targ_etc + "/runlevels"};
+ for(auto &&file : fs::directory_iterator(rl_dir)) {
+ const auto runlevel{file.path().filename().string()};
+ if(def_runlevels.find(runlevel) == def_runlevels.end()) {
+ fs::create_symlink("../default",
+ rl_dir + "/" + runlevel + "/default", ec);
+ if(ec) {
+ output_error("internal", "could not stack runlevel " +
+ runlevel, ec.message());
+ }
+ }
+ }
+ }
+#endif
if(internal->boot) {
EXECUTE_OR_FAIL("bootloader", internal->boot)