From 68a2b692f77a53055cebcda869d4949ab29cc66d Mon Sep 17 00:00:00 2001 From: 0x4D616E75 <0x4d616e75@elektronische-nachricht.de> Date: Mon, 19 Dec 2022 16:18:38 +0100 Subject: [PATCH 1/2] add support for FreeBSD --- mktxp/cli/config/config.py | 10 ++++++++++ setup.py | 1 + 2 files changed, 11 insertions(+) diff --git a/mktxp/cli/config/config.py b/mktxp/cli/config/config.py index b9e255d..2b320c6 100755 --- a/mktxp/cli/config/config.py +++ b/mktxp/cli/config/config.py @@ -135,6 +135,8 @@ class OSConfig(metaclass = ABCMeta): return LinuxConfig() elif sys.platform == 'darwin': return OSXConfig() + elif sys.platform.startswith('freebsd'): + return FreeBSDConfig() else: print(f'Non-supported platform: {sys.platform}') return None @@ -145,6 +147,14 @@ class OSConfig(metaclass = ABCMeta): pass +class FreeBSDConfig(OSConfig): + ''' FreeBSD-related config + ''' + @property + def mktxp_user_dir_path(self): + return FSHelper.full_path('~/mktxp') + + class OSXConfig(OSConfig): ''' OSX-related config ''' diff --git a/setup.py b/setup.py index 4777e5b..6294425 100755 --- a/setup.py +++ b/setup.py @@ -69,6 +69,7 @@ setup( 'Intended Audience :: System Administrators', 'Intended Audience :: Information Technology', 'Operating System :: MacOS', + 'Operating System :: POSIX :: BSD :: FreeBSD', 'Operating System :: POSIX :: Linux', 'Topic :: System', 'Topic :: System :: Systems Administration', From 71c991fcac4168539f9846de97a2cc3377fce5f3 Mon Sep 17 00:00:00 2001 From: 0x4D616E75 <0x4d616e75@elektronische-nachricht.de> Date: Mon, 19 Dec 2022 17:27:06 +0100 Subject: [PATCH 2/2] add setup of a FreeBSD service --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/README.md b/README.md index 5b6b308..1a4ded5 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,63 @@ Let's save and then start the service as well as check on its' status: ``` +## Setting up MKTXP to run as a FreeBSD Service +If you've installed MKTXP on a FreeBSD system, you can run it with system boot via adding a service. \ +Let's start with: + + +``` +❯ nano /usr/local/etc/rc.d/mktxp +``` + +Now copy and paste the following: + +``` +#!/bin/sh + +# PROVIDE: mktxp +# REQUIRE: DAEMON NETWORKING +# BEFORE: LOGIN +# KEYWORD: shutdown + +# Add the following lines to /etc/rc.conf to enable mktxp: +# mktxp_enable="YES" +# +# mktxp_enable (bool): Set to YES to enable mktxp +# Default: NO +# mktxp_user (str): mktxp daemon user +# Default: root + +. /etc/rc.subr + +name=mktxp +rcvar=mktxp_enable + +: ${mktxp_enable:="NO"} +: ${mktxp_user:="root"} + +# daemon +pidfile="/var/run/${name}.pid" +command="/usr/sbin/daemon" +mktxp_command="/usr/local/bin/mktxp export" +procname="daemon" +command_args=" -c -f -P ${pidfile} ${mktxp_command}" + +load_rc_config $name +run_rc_command "$1" +``` + +Let's save and then start the service as well as check on its' status: +``` +❯ sudo sysrc mktxp_enable="YES" +❯ service mktxp start +❯ service mktxp status + +❯ service mktxp status +mktxp is running as pid 36704 +``` + + ## Description of CLI Commands ### mktxp commands . MKTXP commands: