Skip to content

Instantly share code, notes, and snippets.

@jevonearth
Created July 17, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jevonearth/20296a4213826040b624 to your computer and use it in GitHub Desktop.
Save jevonearth/20296a4213826040b624 to your computer and use it in GitHub Desktop.
freebsd rc scripts and env(1) shebang are not friends
#!/bin/sh
# Create dummy python script which uses env for shebang.
cat << EOF > /usr/local/bin/foo
#!/usr/bin/env python2.7
print("Hello foo")
EOF
# turn on executable bit
chmod +x /usr/local/bin/foo
# create FreeBSD rc script with command_interpreter specified.
cat << EOF > /usr/local/etc/rc.d/foo
#!/bin/sh
#
# PROVIDE: foo
. /etc/rc.subr
name="foo"
rcvar=foo_enable
command_interpreter="/usr/local/bin/python2.7"
command="/usr/local/bin/foo"
load_rc_config \$name
run_rc_command \$1
EOF
# turn on executable bit
chmod +x /usr/local/etc/rc.d/foo
# enable foo
echo "foo_enable=\"YES\"" >> /etc/rc.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment