4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

FreeBSD - creating a simple rc.d service

created services before, this is much easier than systemd.

this is all it takes to create a small service that mounts and unmounts a nfs partition.

yes I could put this into fstab.. but I found it can hang the computer on boot if it is not present.. and there is no easy way to 'turn it off' in the fstab without physically editing it.

it only requires one file, a rc.d style service file.

this makes things easier, i can not simply say.. as root

service zengarden start 
service zengarden stop

and add this to my rc.conf

zengarden_enable="YES"

here is the file that does all the work.

/usr/local/etc/rc.d/zengarden

#!/bin/sh

# PROVIDE: zengarden
# REQUIRE: serenity nfs-client
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable the zengarden:
#
# zengarden_enable="YES"
#

. /etc/rc.subr

#export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

name="zengarden"
rcvar="zengarden_enable"
start_cmd="${name}_start" 
stop_cmd="${name}_stop" 

zengarden_start() 
{
	/sbin/mount serenity:/srv/nfs/zg /mnt/zg
}
zengarden_stop() 
{
	umount /mnt/zg
}

load_rc_config $name 
: ${zengarden_enable=NO}
run_rc_command "$1"

using search/replace all of 'zengarden' in this file .. you can create a simple rc.d service that works for you. (be sure you name the file you create the same)

edit the command within start/stop respectively to get the results you want.

7 upvotes $0.12

Replies (0)

Conversation

No replies yet

Replies will appear here as people join the conversation.

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: