mirror of https://github.com/fairyglade/ly.git
Add SysVinit service (closes #224)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
bb669c239c
commit
412994775b
11
build.zig
11
build.zig
|
@ -8,6 +8,7 @@ const InitSystem = enum {
|
||||||
runit,
|
runit,
|
||||||
s6,
|
s6,
|
||||||
dinit,
|
dinit,
|
||||||
|
sysvinit,
|
||||||
};
|
};
|
||||||
|
|
||||||
const min_zig_string = "0.15.0";
|
const min_zig_string = "0.15.0";
|
||||||
|
@ -308,6 +309,15 @@ fn install_service(allocator: std.mem.Allocator, patch_map: PatchMap) !void {
|
||||||
const patched_service = try patchFile(allocator, "res/ly-dinit", patch_map);
|
const patched_service = try patchFile(allocator, "res/ly-dinit", patch_map);
|
||||||
try installText(patched_service, service_dir, service_path, "ly", .{});
|
try installText(patched_service, service_dir, service_path, "ly", .{});
|
||||||
},
|
},
|
||||||
|
.sysvinit => {
|
||||||
|
const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/init.d" });
|
||||||
|
std.fs.cwd().makePath(service_path) catch {};
|
||||||
|
var service_dir = std.fs.cwd().openDir(service_path, .{}) catch unreachable;
|
||||||
|
defer service_dir.close();
|
||||||
|
|
||||||
|
const patched_service = try patchFile(allocator, "res/ly-sysvinit", patch_map);
|
||||||
|
try installText(patched_service, service_dir, service_path, "ly", .{});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +349,7 @@ pub fn Uninstaller(uninstall_config: bool) type {
|
||||||
try deleteFile(allocator, config_directory, "/s6/adminsv/default/contents.d/ly-srv", "s6 admin service not found");
|
try deleteFile(allocator, config_directory, "/s6/adminsv/default/contents.d/ly-srv", "s6 admin service not found");
|
||||||
},
|
},
|
||||||
.dinit => try deleteFile(allocator, config_directory, "/dinit.d/ly", "dinit service not found"),
|
.dinit => try deleteFile(allocator, config_directory, "/dinit.d/ly", "dinit service not found"),
|
||||||
|
.sysvinit => try deleteFile(allocator, config_directory, "/init.d/ly", "sysvinit service not found"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
10
readme.md
10
readme.md
|
@ -159,6 +159,16 @@ To disable TTY 2, edit `/etc/s6/config/tty2.conf` and set `SPAWN="no"`.
|
||||||
To disable TTY 2, go to `/etc/dinit.d/config/console.conf` and modify
|
To disable TTY 2, go to `/etc/dinit.d/config/console.conf` and modify
|
||||||
`ACTIVE_CONSOLES`.
|
`ACTIVE_CONSOLES`.
|
||||||
|
|
||||||
|
### sysvinit
|
||||||
|
|
||||||
|
```
|
||||||
|
# zig build installexe -Dinit_system=sysvinit
|
||||||
|
# update-rc.d lightdm disable
|
||||||
|
# update-rc.d ly defaults
|
||||||
|
```
|
||||||
|
|
||||||
|
To disable TTY 2, go to `/etc/inittab` and comment out the line containing `tty2`.
|
||||||
|
|
||||||
### Updating
|
### Updating
|
||||||
|
|
||||||
You can also install Ly without overrding the current configuration file. This
|
You can also install Ly without overrding the current configuration file. This
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
#!/bin/sh
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: ly
|
||||||
|
# Required-Start: $remote_fs $syslog
|
||||||
|
# Required-Stop: $remote_fs $syslog
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: Ly display manager
|
||||||
|
# Description: Starts and stops the Ly display manager
|
||||||
|
### END INIT INFO
|
||||||
|
#
|
||||||
|
# Author: AnErrupTion <anerruption@disroot.org>
|
||||||
|
#
|
||||||
|
|
||||||
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||||
|
DAEMON=/usr/bin/ly
|
||||||
|
TTY=/dev/tty$DEFAULT_TTY
|
||||||
|
PIDFILE=/var/run/ly.pid
|
||||||
|
NAME=ly
|
||||||
|
DESC="Ly display manager"
|
||||||
|
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
log_daemon_msg "Starting $DESC on $TTY..."
|
||||||
|
if [ -f "$PIDFILE" ]; then
|
||||||
|
log_progress_msg "$DESC is already running"
|
||||||
|
log_end_msg 0
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure TTY exists
|
||||||
|
[ -c "$TTY" ] || {
|
||||||
|
log_failure_msg "$TTY does not exist"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE \
|
||||||
|
--chdir / --exec /bin/sh -- -c "exec setsid sh -c 'exec <$TTY >$TTY 2>&1 $DAEMON'"
|
||||||
|
log_end_msg $?
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
log_daemon_msg "Stopping $DESC..."
|
||||||
|
start-stop-daemon --stop --pidfile $PIDFILE --retry 5
|
||||||
|
RETVAL=$?
|
||||||
|
[ $RETVAL -eq 0 ] && rm -f "$PIDFILE"
|
||||||
|
log_end_msg $RETVAL
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
echo "Restarting $DESC..."
|
||||||
|
$0 stop
|
||||||
|
sleep 1
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue