diff --git a/build.zig b/build.zig index 06b6d54..1a986f0 100644 --- a/build.zig +++ b/build.zig @@ -9,6 +9,7 @@ const InitSystem = enum { s6, dinit, sysvinit, + freebsd, }; const min_zig_string = "0.15.0"; @@ -42,7 +43,7 @@ pub fn build(b: *std.Build) !void { const version_str = try getVersionStr(b, "ly", ly_version); const enable_x11_support = b.option(bool, "enable_x11_support", "Enable X11 support (default is on)") orelse true; const default_tty = b.option(u8, "default_tty", "Set the TTY (default is 2)") orelse 2; - const fallback_tty = b.option(u8, "fallback_tty", "Set the fallback TTY (default is 1). This value gets embedded into the binary") orelse 1; + const fallback_tty = b.option(u8, "fallback_tty", "Set the fallback TTY (default is 2). This value gets embedded into the binary") orelse 2; default_tty_str = try std.fmt.allocPrint(b.allocator, "{d}", .{default_tty}); @@ -318,6 +319,15 @@ fn install_service(allocator: std.mem.Allocator, patch_map: PatchMap) !void { const patched_service = try patchFile(allocator, "res/ly-sysvinit", patch_map); try installText(patched_service, service_dir, service_path, "ly", .{ .mode = 0o755 }); }, + .freebsd => { + const service_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, config_directory, "/rc.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-freebsd", patch_map); + try installText(patched_service, service_dir, service_path, "ly", .{ .mode = 0o755 }); + }, } } @@ -350,6 +360,7 @@ pub fn Uninstaller(uninstall_config: bool) type { }, .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"), + .freebsd => try deleteFile(allocator, config_directory, "/rc.d/ly", "freebsd service not found"), } } }; diff --git a/readme.md b/readme.md index 1919f91..e19ead1 100644 --- a/readme.md +++ b/readme.md @@ -38,6 +38,12 @@ It is recommended to add a rule for Ly as it currently does not ship one. # dnf install kernel-devel pam-devel libxcb-devel zig xorg-x11-xauth xorg-x11-server brightnessctl ``` +### FreeBSD + +``` +# pkg install ca_root_nss libxcb git +``` + ## Packaging status [![Packaging status](https://repology.org/badge/vertical-allrepos/ly.svg?exclude_unsupported=1)](https://repology.org/project/ly/versions) @@ -169,6 +175,16 @@ To disable TTY 2, go to `/etc/dinit.d/config/console.conf` and modify To disable TTY 2, go to `/etc/inittab` and comment out the line containing `tty2`. +### FreeBSD + +``` +# zig build installexe -Dprefix_directory=/usr/local +# sysrc lightdm_enable="NO" +# sysrc ly_enable="YES" +``` + +To disable TTY 2, go to `/etc/ttys` and comment out the line starting with `ttyv2`. + ### Updating You can also install Ly without overrding the current configuration file. This diff --git a/res/ly-freebsd b/res/ly-freebsd new file mode 100644 index 0000000..9dfcb9f --- /dev/null +++ b/res/ly-freebsd @@ -0,0 +1,23 @@ +#!/bin/sh +# +# PROVIDE: ly +# REQUIRE: DAEMON +# KEYWORD: shutdown + +. /etc/rc.subr + +name=ly +rcvar=ly_enable + +command="/usr/local/bin/ly" + +load_rc_config $name + +# +# DO NOT CHANGE THESE DEFAULT VALUES HERE +# SET THEM IN THE /etc/rc.conf FILE +# +ly_enable=${ly_enable-"NO"} +pidfile=${ly_pidfile-"/var/run/ly.pid"} + +run_rc_command "$1"