Skip to content
Browse files

Merge branch '2.0'

  • Loading branch information...
2 parents d56b1bb + a56fe9b commit e535ac0fddcbc15f33edc502c158802cd6bdbe9a @jaredmorrow jaredmorrow committed Sep 4, 2014
Showing with 881 additions and 326 deletions.
  1. +47 −34 Makefile
  2. +9 −0 README.org
  3. +121 −42 priv/base/env.sh
  4. +22 −15 priv/base/nodetool
  5. +183 −155 priv/base/runner
  6. +2 −1 priv/templates/deb/Makefile
  7. +1 −1 priv/templates/deb/Makefile.bootstrap
  8. +1 −2 priv/templates/deb/control
  9. +12 −6 priv/templates/deb/init.script
  10. +1 −0 priv/templates/deb/postinst
  11. +1 −1 priv/templates/fbsd/Makefile
  12. +1 −1 priv/templates/fbsd/Makefile.bootstrap
  13. +18 −0 priv/templates/fbsdng/+MANIFEST
  14. +98 −0 priv/templates/fbsdng/Makefile
  15. +12 −0 priv/templates/fbsdng/Makefile.bootstrap
  16. +25 −0 priv/templates/fbsdng/fbsdng.template
  17. +19 −0 priv/templates/fbsdng/rc.d
  18. +20 −0 priv/templates/fbsdng/vars.config
  19. +1 −1 priv/templates/osx/Makefile
  20. +1 −1 priv/templates/osx/Makefile.bootstrap
  21. +14 −2 priv/templates/rpm/Makefile
  22. +1 −1 priv/templates/rpm/Makefile.bootstrap
  23. +11 −0 priv/templates/rpm/{init.script → rhel.init.script}
  24. +2 −1 priv/templates/rpm/rpm.template
  25. +44 −8 priv/templates/rpm/specfile
  26. +156 −0 priv/templates/rpm/suse.init.script
  27. +1 −1 priv/templates/smartos/+DISPLAY
  28. +33 −11 priv/templates/smartos/+INSTALL
  29. +2 −12 priv/templates/smartos/Makefile
  30. +1 −1 priv/templates/smartos/Makefile.bootstrap
  31. +0 −4 priv/templates/smartos/env.patch
  32. +16 −22 priv/templates/smartos/runner.patch
  33. +0 −1 priv/templates/smartos/smartos.template
  34. +3 −0 priv/templates/solaris/Makefile
  35. +1 −1 priv/templates/solaris/Makefile.bootstrap
  36. +1 −1 priv/templates/solaris/solaris.template
View
81 Makefile
@@ -3,78 +3,91 @@
##
export
-OS = $(shell uname -s)
-ERLANG_BIN ?= $(shell dirname $(shell which erl))
+OS = $(shell uname -s)
+ERLANG_BIN ?= $(shell dirname $(shell which erl))
+DEPS_DIR ?= deps
##
## Support RPM and Debian based linux systems
##
ifeq ($(OS),Linux)
-ARCH = $(shell uname -m)
-ISRPM = $(shell cat /etc/redhat-release 2> /dev/null)
-ISDEB = $(shell cat /etc/debian_version 2> /dev/null)
+ARCH = $(shell uname -m)
+ISRPM = $(shell cat /etc/redhat-release 2> /dev/null)
+ISDEB = $(shell cat /etc/debian_version 2> /dev/null)
+ISSLES = $(shell cat /etc/SuSE-release 2> /dev/null)
ifneq ($(ISRPM),)
-OSNAME= RedHat
-PKGERDIR = rpm
-BUILDDIR = rpmbuild
+OSNAME = RedHat
+PKGERDIR = rpm
+BUILDDIR = rpmbuild
else
ifneq ($(ISDEB),)
-OSNAME = Debian
-PKGERDIR = deb
-BUILDDIR = debuild
+OSNAME = Debian
+PKGERDIR = deb
+BUILDDIR = debuild
+else
+ifneq ($(ISSLES),)
+OSNAME = SLES
+PKGERDIR = rpm
+BUILDDIR = rpmbuild
+endif # SLES
endif # deb
endif # rpm
endif # linux
ifeq ($(OS),Darwin) # OSX
-OSNAME = OSX
-ARCH = $(shell file `which erlc` | grep -c x86_64 2> /dev/null | awk \
- '{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
-PKGERDIR = osx
-BUILDDIR = osxbuild
+OSNAME = OSX
+ARCH = $(shell file `which erlc` | grep -c x86_64 2> /dev/null | awk \
+ '{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
+PKGERDIR = osx
+BUILDDIR = osxbuild
endif
ifeq ($(OS),FreeBSD)
-OSNAME = FreeBSD
-ARCH = $(shell uname -m)
-PKGERDIR = fbsd
-BUILDDIR = fbsdbuild
+OSNAME = FreeBSD
+ARCH = $(shell uname -m)
+BUILDDIR = fbsdbuild
+PKGNG = $(shell uname -r | awk -F. '{ print ($$1 > 9) ? "true" : "false" }')
+ifeq ($(PKGNG),true) # FreeBSD 10.0 or greater
+PKGERDIR = fbsdng
+else # Older FreeBSD pkg_add
+PKGERDIR = fbsd
+endif
endif
ifeq ($(OS),SunOS) # Solaris flavors
-KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null)
-ARCH = $(shell file `which erlc` | grep -c 64-bit 2> /dev/null | awk \
+KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null)
+ARCH = $(shell file `which erlc` | grep -c 64-bit 2> /dev/null | awk \
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
ifneq ($(KERNELVER),0) # SmartOS
-OSNAME = SmartOS
-PKGERDIR = smartos
-BUILDDIR = smartosbuild
+OSNAME = SmartOS
+PKGERDIR = smartos
+BUILDDIR = smartosbuild
else # Solaris / OmniOS
-DISTRO = $(shell head -1 /etc/release|awk \
- '{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}')
-OSNAME = ${DISTRO}
-PKGERDIR = solaris
-BUILDDIR = solarisbuild
+DISTRO = $(shell head -1 /etc/release|awk \
+ '{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}')
+OSNAME = ${DISTRO}
+PKGERDIR = solaris
+BUILDDIR = solarisbuild
endif
endif
-DATE = $(shell date +%Y-%m-%d)
+DATE = $(shell date +%Y-%m-%d)
# Default the package build version to 1 if not already set
-PKG_BUILD ?= 1
+PKG_BUILD ?= 1
.PHONY: ostype varcheck
## Call platform dependent makefile
ostype: varcheck setversion
$(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported by node_package"))
- $(MAKE) -f $(PKG_ID)/deps/node_package/priv/templates/$(PKGERDIR)/Makefile.bootstrap
+ $(MAKE) -f $(PKG_ID)/$(DEPS_DIR)/node_package/priv/templates/$(PKGERDIR)/Makefile.bootstrap
## Set app version
setversion: varcheck
- echo "{app_version, \"$(PKG_VERSION)\"}." >> $(PKG_ID)/deps/node_package/priv/templates/$(PKGERDIR)/vars.config
+ echo "{app_version, \"$(PKG_VERSION)\"}." >> $(PKG_ID)/$(DEPS_DIR)/node_package/priv/templates/$(PKGERDIR)/vars.config
## Check required settings before continuing
varcheck:
View
9 README.org
@@ -35,6 +35,8 @@ application.
(ex: app-5.4-1 <- the '1')
- =ERLANG_BIN= - (Default: `which erl`) Sets the path of the current erlang
binary
+ - =DEPS_DIR= - (Default: deps) Sets the deps directory of the project, most
+ projects uses 'deps'. Change this if something different is used.
** Package and Script Variables
@@ -78,6 +80,9 @@ The following variables describe a package and should be put in the
- =freebsd_package_category= - The subsection the package is filed under in FreeBSD
(ex: in this line, "ORIGIN: db/riak" 'db' would be the package_category)
This defaults to 'db' if not specified for lack of a better default.
+ - =debuild_extra_options= - This is added to pass extra flags to debuild
+ - =cuttlefish_conf= - If your app uses cuttlefish for configuration, this
+ is the filename you are using for configuration (ex: "riak.conf")
*** Script Variables
The following variables are used in the =env.sh= and =runner= scripts which can
@@ -93,6 +98,10 @@ your application's =vars.config=.
- =runner_user= - The username to run the application as
- =runner_wait_process= - Registered process to wait for to consider start a
success
+ - =cuttlefish_conf= - This is a rare case of a repeated variable since it is
+ used in packaging and the main runner scripts, you should have this set
+ in both the vars.config and pkg.vars.config (sadly this was the cleanest
+ solution).
*** Templating Order
There are several templating steps done in node_package:
View
163 priv/base/env.sh
@@ -41,44 +41,70 @@ if [ -z "$ULIMIT_WARN" ]; then
ULIMIT_WARN=4096
fi
-## Are we using cuttlefish (http://github.com/basho/cuttlefish)
-## for configuration
-CUTTLEFISH="{{cuttlefish}}"
-
# Registered process to wait for to consider start a success
WAIT_FOR_PROCESS={{runner_wait_process}}
-WHOAMI=$(whoami)
+WHOAMI=`whoami`
# Echo to stderr on errors
echoerr() { echo "$@" 1>&2; }
# Extract the target node name from node.args
-NAME_ARG=`egrep '^\-s?name' $RUNNER_ETC_DIR/vm.args`
+NAME_ARG=`egrep '^\-name' $RUNNER_ETC_DIR/vm.args 2> /dev/null`
if [ -z "$NAME_ARG" ]; then
- echoerr "vm.args needs to have either -name or -sname parameter."
- exit 1
+ NODENAME=`egrep '^[ \t]*nodename[ \t]*=[ \t]*' $RUNNER_ETC_DIR/{{cuttlefish_conf}} 2> /dev/null | tail -1 | cut -d = -f 2`
+ if [ -z "$NODENAME" ]; then
+ echoerr "vm.args needs to have a -name parameter."
+ echoerr " -sname is not supported."
+ exit 1
+ else
+ NAME_ARG="-name ${NODENAME# *}"
+ fi
fi
# Learn how to specify node name for connection from remote nodes
-echo "$NAME_ARG" | grep '^-sname' > /dev/null 2>&1
+NAME_PARAM="-name"
+echo "$NAME_ARG" | grep '@.*' > /dev/null 2>&1
if [ "X$?" = "X0" ]; then
- NAME_PARAM="-sname"
- NAME_HOST=""
+ NAME_HOST=`echo "${NAME_ARG}" | sed -e 's/.*\(@.*\)$/\1/'`
else
- NAME_PARAM="-name"
- echo "$NAME_ARG" | grep '@.*' > /dev/null 2>&1
- if [ "X$?" = "X0" ]; then
- NAME_HOST=`echo "${NAME_ARG}" | sed -e 's/.*\(@.*\)$/\1/'`
- else
- NAME_HOST=""
- fi
+ NAME_HOST=""
fi
# Extract the target cookie
-COOKIE_ARG=`grep '^\-setcookie' $RUNNER_ETC_DIR/vm.args`
+COOKIE_ARG=`grep '^\-setcookie' $RUNNER_ETC_DIR/vm.args 2> /dev/null`
if [ -z "$COOKIE_ARG" ]; then
- echoerr "vm.args needs to have a -setcookie parameter."
+ COOKIE=`egrep '^[ \t]*distributed_cookie[ \t]*=[ \t]*' $RUNNER_ETC_DIR/{{cuttlefish_conf}} 2> /dev/null | tail -1 | cut -d = -f 2`
+ if [ -z "$COOKIE" ]; then
+ echoerr "vm.args needs to have a -setcookie parameter."
+ exit 1
+ else
+ COOKIE_ARG="-setcookie $COOKIE"
+ fi
+fi
+
+# Extract the target net_ticktime
+NET_TICKTIME_ARG=`grep '^\-kernel net_ticktime' $RUNNER_ETC_DIR/vm.args 2> /dev/null`
+if [ -z "$NET_TICKTIME_ARG" ]; then
+ NET_TICKTIME=`egrep '^[ \t]*erlang.distribution.net_ticktime[ \t]*=[ \t]*' $RUNNER_ETC_DIR/{{cuttlefish_conf}} 2> /dev/null | tail -1 | cut -d = -f 2`
+ if [ -z "$NET_TICKTIME" ]; then
+ NET_TICKTIME_ARG=""
+ else
+ NET_TICKTIME_ARG="-kernel net_ticktime $NET_TICKTIME"
+ fi
+fi
+
+# Optionally specify a NUMA policy
+NUMACTL_ARG="{{numactl_arg}}"
+if [ -z "$NUMACTL_ARG" ]
+then
+ NUMACTL=""
+# Confirms `numactl` is in the path and validates $NUMACTL_ARG
+elif which numactl > /dev/null 2>&1 && numactl $NUMACTL_ARG ls /dev/null > /dev/null 2>&1
+then
+ NUMACTL="numactl $NUMACTL_ARG"
+else
+ echoerr "NUMACTL_ARG is specified in env.sh but numactl is not installed or NUMACTL_ARG is invalid."
exit 1
fi
@@ -91,9 +117,20 @@ APP_VSN=${START_ERL#* }
ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
# Setup command to control the node
-NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
+NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG $NET_TICKTIME_ARG"
NODETOOL_LITE="$ERTS_PATH/escript $ERTS_PATH/nodetool"
+
+## Are we using cuttlefish (http://github.com/basho/cuttlefish)
+## for configuration. This needs to come after the $ERTS_PATH
+## definition
+CUTTLEFISH="{{cuttlefish}}"
+if [ -z "$CUTTLEFISH" ]; then
+ CUTTLEFISH_COMMAND_PREFIX=""
+else
+ CUTTLEFISH_COMMAND_PREFIX="$ERTS_PATH/escript $ERTS_PATH/cuttlefish -e $RUNNER_ETC_DIR -s $RUNNER_LIB_DIR -d {{platform_data_dir}}/generated.configs -c $RUNNER_ETC_DIR/{{cuttlefish_conf}}"
+fi
+
# Ping node without stealing stdin
ping_node() {
$NODETOOL ping < /dev/null
@@ -104,7 +141,7 @@ ping_node() {
# read/write/delete .pid files during startup/shutdown
create_pid_dir() {
# Validate RUNNER_USER is set and they have permissions to write to /var/run
- # Don't continue if we've already sudo'd to RUNNER_USER
+ # Don't continue if we've already su'd to RUNNER_USER
if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
if [ -w $RUN_DIR ]; then
mkdir -p $PID_DIR
@@ -160,17 +197,58 @@ create_pid_file() {
fi
}
-# Function to su into correct user
-check_user() {
+
+# Simple way to check the correct user and fail early
+check_user_internal() {
# Validate that the user running the script is the owner of the
# RUN_DIR.
if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
- type sudo > /dev/null 2>&1
- if [ "$?" -ne 0 ]; then
- echoerr "sudo doesn't appear to be installed and your EUID isn't $RUNNER_USER" 1>&2
+ if [ "x$WHOAMI" != "xroot" ]; then
+ echo "You need to be root or use sudo to run this command"
exit 1
fi
- exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
+ fi
+}
+
+# Function to su into correct user that is poorly named for historical
+# reasons (excuses)
+# This also serves as an entry point to most functions
+check_user() {
+ check_user_internal
+
+ # This call must be before the su call, when the user is dropped
+ # optional config will be brought in if available
+ load_default_os_config
+
+ # do not su again if we are already the runner user
+ if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
+ # Escape any double quotes that might be in the command line
+ # args. Without this, passing something like JSON on the command
+ # line will get stripped.
+ # Ex:
+ # riak-admin bucket-type create mytype '{"props": {"n_val": 4}}'
+ # would become
+ # riak-admin bucket-type create mytype {props: {n_val: 4}}
+ # after the arguments were passed into the new shell during exec su
+ #
+ # So this regex finds any '"', '{', or '}' and prepends with a '\'
+ ESCAPED_ARGS=`echo "$@" | sed -e 's/\([{}"]\)/\\\\\1/g'`
+
+ # This will drop priviledges into the runner user
+ # It exec's in a new shell and the current shell will exit
+ exec su - $RUNNER_USER -c "$RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $ESCAPED_ARGS"
+ fi
+}
+
+# Function to load default config files based on OS
+load_default_os_config() {
+ # Only run this if we already dropped to the runner user
+ if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" = "x$RUNNER_USER" ]); then
+ # Common config file on Debian-like systems
+ [ -r /etc/default/$RUNNER_SCRIPT ] && . /etc/default/$RUNNER_SCRIPT
+
+ # Common config file on RPM-like systems
+ [ -r /etc/sysconfig/$RUNNER_SCRIPT ] && . /etc/sysconfig/$RUNNER_SCRIPT
fi
}
@@ -195,17 +273,28 @@ node_up_check() {
# Function to check if the config file is valid
check_config() {
if [ -z "$CUTTLEFISH" ]; then
- CONFIG_FILE="$RUNNER_ETC_DIR/app.config"
+ # Note: we have added a parameter '-vm_args' to this. It
+ # appears redundant but it is not! the erlang vm allows us to
+ # access all arguments to the erl command EXCEPT '-args_file',
+ # so in order to get access to this file location from within
+ # the vm, we need to pass it in twice.
+ CONFIG_ARGS=" -config $RUNNER_ETC_DIR/app.config -args_file $RUNNER_ETC_DIR/vm.args -vm_args $RUNNER_ETC_DIR/vm.args "
else
- cuttlefish
+ CONFIG_ARGS=`$CUTTLEFISH_COMMAND_PREFIX generate`
+ if [ "$?" -ne 0 ]; then
+ echoerr "Error generating config with cuttlefish"
+ echoerr " run \`$RUNNER_SCRIPT config generate -l debug\` for more information."
+ exit 1
+ fi
fi
- MUTE=`$NODETOOL_LITE chkconfig $CONFIG_FILE`
+ MUTE=`$NODETOOL_LITE chkconfig $CONFIG_ARGS`
if [ "$?" -ne 0 ]; then
- echoerr "Error reading $CONFIG_FILE"
+ echoerr "Error reading $CONFIG_ARGS"
exit 1
fi
echo "config is OK"
+ echo $CONFIG_ARGS
}
# Function to check if ulimit is properly set
@@ -237,13 +326,3 @@ get_pid() {
return 0
}
-
-# This guy sets $CONFIG_FILE to the absolute filename to the app.config
-# generated by cuttlefish
-cuttlefish() {
- CONFIG_FILE=`$ERTS_PATH/cuttlefish -e $RUNNER_ETC_DIR -s $RUNNER_LIB_DIR -c $RUNNER_ETC_DIR/{{cuttlefish_conf}}`
- if [ "$?" -ne 0 ]; then
- echoerr "Error generating config with cuttlefish, there should be logs"
- exit 1
- fi
-}
View
37 priv/base/nodetool
@@ -1,4 +1,5 @@
#!/usr/bin/env escript
+%%! +fnu
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
%% -------------------------------------------------------------------
@@ -10,6 +11,7 @@
%% installed by node_package (github.com/basho/node_package)
main(Args) ->
+ io:setopts([{encoding, utf8}]),
ok = start_epmd(),
%% Extract the args
{RestArgs, TargetNode} = process_args(Args, [], undefined),
@@ -29,21 +31,9 @@ main(Args) ->
%% any commands that don't need a running node
case RestArgs of
["chkconfig", File] ->
- case file:consult(File) of
- {ok, _} ->
- io:format("ok\n"),
- halt(0);
- {error, {Line, Mod, Term}} ->
- io:format(standard_error,
- ["Error on line ",
- file:format_error({Line, Mod, Term}), "\n"], []),
- halt(1);
- {error, R} ->
- io:format(standard_error,
- ["Error reading config file: ",
- file:format_error(R), "\n"], []),
- halt(1)
- end;
+ chkconfig(File);
+ ["chkconfig", "-config", File|_] ->
+ chkconfig(File);
_ ->
ok
end,
@@ -171,6 +161,23 @@ append_node_suffix(Name, Suffix) ->
list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
end.
+chkconfig(File) ->
+ case file:consult(File) of
+ {ok, _} ->
+ io:format("ok\n"),
+ halt(0);
+ {error, {Line, Mod, Term}} ->
+ io:format(standard_error,
+ ["Error on line ",
+ file:format_error({Line, Mod, Term}), "\n"], []),
+ halt(1);
+ {error, R} ->
+ io:format(standard_error,
+ ["Error reading config file: ",
+ file:format_error(R), "\n"], []),
+ halt(1)
+ end.
+
%%
%% Given a string or binary, parse it into a list of terms, ala file:consult/0
View
338 priv/base/runner
@@ -20,10 +20,11 @@ SCRIPT=`basename $0`
usage() {
cat <<EOF
Usage: $SCRIPT «command»
-where «command» is one of the following:
- { help | start | stop | restart | reboot | ping | console | attach
+where «command» is one of the following:
+ { help | start | stop | restart | ping | console | attach
attach-direct | ertspath | chkconfig | escript | version | getpid
- top [-interval N] [-sort { reductions | memory | msg_q }] [-lines N] }
+ top [-interval N] [-sort { reductions | memory | msg_q }] [-lines N] } |
+ config { generate | effective | describe VARIABLE } [-l debug]
Run \`$SCRIPT help\` for more detailed information.
@@ -45,90 +46,121 @@ This is the primary script for controlling the $SCRIPT node.
SERVICE CONTROL COMMANDS
start
- Starts the $SCRIPT node in the background. If the node is already
+ Starts the $SCRIPT node in the background. If the node is already
started, you will get the message "Node is already running!" If the
node is not already running, no output will be given.
stop
- Stops the running $SCRIPT node. Prints "ok" when successful. When
+ Stops the running $SCRIPT node. Prints "ok" when successful. When
the node is already stopped or not responding, prints:
- "Node '$NAME_HOST' not responding to pings."
+ "Node '$NAME_HOST' not responding to pings."
restart
- Stops and then starts the running $SCRIPT node without exiting the
- Erlang VM. Prints "ok" when successful. When the node is already
- stopped or not responding, prints:
- "Node '$NAME_HOST' not responding to pings."
-
- reboot
- Stops and then starts the running $SCRIPT node, exiting the Erlang VM.
- Prints "ok" when successful. When the node is already stopped or not
- responding, prints:
- "Node '$NAME_HOST' not responding to pings."
+ Stops and then starts the running $SCRIPT node. Prints "ok"
+ when successful. When the node is already stopped or not
+ responding, prints: "Node '$NAME_HOST' not responding to
+ pings."
console
- Starts the $SCRIPT node in the foreground, giving access to the Erlang
- shell and runtime messages. Prints "Node is already running - use
+ Starts the $SCRIPT node in the foreground, giving access to the Erlang
+ shell and runtime messages. Prints "Node is already running - use
'$SCRIPT attach' instead" when the node is running in the background.
DIAGNOSTIC COMMANDS
ping
- Checks that the $SCRIPT node is running. Prints "pong" when
+ Checks that the $SCRIPT node is running. Prints "pong" when
successful. When the node is stopped or not responding, prints:
- "Node '$NAME_HOST' not responding to pings."
+ "Node '$NAME_HOST' not responding to pings."
top [-interval N] [-sort {reductions | memory | msg_q }] [-lines N]
Prints performance information about the Erlang Virtual Machine similar
to the information provided by the \`top\` command.
-interval N
- specifies an interval upon which the statistics are collected.
+ specifies an interval upon which the statistics are collected.
-sort { reductions | memory | msg_q }
- Sorts the output of the command by Reduction Count, Memory
+ Sorts the output of the command by Reduction Count, Memory
Utilization, or Message Queue size
- -lines N
+ -lines N
Controls the number of processes displayed in the output
- attach
- Attaches to the console of a $SCRIPT node running in the background
- using an Erlang remote shell, giving access to the Erlang shell and
+ attach
+ Attaches to the console of a $SCRIPT node running in the background
+ using an Erlang remote shell, giving access to the Erlang shell and
runtime messages. Prints "Node is not running!" when the node cannot
be reached. Exit \`$SCRIPT attach\` by pressing Ctrl-C twice.
attach-direct
Attaches to the console of a $SCRIPT node running in the background
- using a directly connected FIFO, giving access to the Erlang shell
+ using a directly connected FIFO, giving access to the Erlang shell
and runtime messages. Prints "Node is not running!" when the node
cannot be reached. Exit \`$SCRIPT attach-direct\` by pressing Ctrl-D.
- chkconfig
- Confirms whether the app.config is valid.
+ chkconfig
+ Confirms whether the $SCRIPT.conf and advanced.config is
+ valid.
+
+ For applications configured with cuttlefish, this includes a call
+ to \`config generate\` also.
+
+ config { generate | effective | describe VARIABLE } [-l debug]
+ prints configuration information for applications configured with
+ cuttlefish enabled. \`-l debug\` outputs more information for
+ troubleshooting.
+
+ generate
+ generates the app.config and vm.args files from the .conf file.
+ This is effectively what happens before start, but you'll need
+ to use \`config generate -l debug\` to see the cuttlefish debug
+ output.
+
+ effective
+ prints out the effective configuration in cuttlefish syntax
+ including defaults not specified in the .conf file. This is
+ for 'start-time' configuration only.
-SCRIPTING COMMANDS
+ describe VARIABLE
+ for a given setting, prints any documentation and other useful
+ information, such as affected location in app.config, datatype
+ of the value, default value, and effective value.
+
+
+SCRIPTING COMMANDS
ertspath
Outputs the path to the $SCRIPT Erlang runtime environment
escript
Provides a means to call the \`escript\` application within the $SCRIPT
Erlang runtime environment
-
+
version
Outputs the $SCRIPT version identifier
-
+
getpid
- Outputs the process identifier for a currently running instance of
+ Outputs the process identifier for a currently running instance of
$SCRIPT.
EOF
}
-# All commands must either call bootstrap or bootstrapd
-# Call bootstrap for non-daemon commands like ping or chkconfig
+
# Call bootstrapd for daemon commands like start/stop/console
-bootstrap() {
+bootstrapd() {
+ # Fail fast if they have no rights to mess around with pids
+ check_user_internal
+
+ # Create PID directory if it does not exist before dropping permissiongs
+ # to the runner user
+ create_pid_dir
+ ES=$?
+ if [ "$ES" -ne 0 ]; then
+ echoerr "Unable to access $PID_DIR, permission denied, run script as root"
+ exit 1
+ fi
+
# Make sure the user running this script is the owner and/or su to that user
check_user $@
ES=$?
@@ -137,132 +169,106 @@ bootstrap() {
fi
}
-bootstrapd() {
- # Create PID directory if it does not exist before dropping permissiongs
- # to the runner user
- create_pid_dir
+do_start() {
+ # Make sure there is not already a node running
+ node_down_check
+
+ # Warn the user if ulimit is too low
+ check_ulimit
+
+ # Make sure log directory exists
+ mkdir -p $RUNNER_LOG_DIR
+
+ HEART_COMMAND="$RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT start"
+ export HEART_COMMAND
+ mkdir -p $PIPE_DIR
+ $ERTS_PATH/run_erl -daemon $PIPE_DIR/ $RUNNER_LOG_DIR \
+ "exec $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT console" 2>&1
+
+ if [ ! -z "$WAIT_FOR_PROCESS" ]; then
+ # Wait for the node to come up. We can't just ping it because
+ # distributed erlang comes up for a second before the node crashes
+ # (eg. in the case of an unwriteable disk). Once the node comes
+ # up we check for the $WAIT_FOR_PROCESS} process. If that's running
+ # then we assume things are good enough. This will at least let
+ # the user know when the node is crashing right after startup.
+ WAIT=${WAIT_FOR_ERLANG:-15}
+ while [ $WAIT -gt 0 ]; do
+ WAIT=`expr $WAIT - 1`
+ sleep 1
+
+ # squash stderr output to not frighten users if the node does not
+ # come up right away
+ MUTE=`ping_node 2> /dev/null`
+ if [ "$?" -ne 0 ]; then
+ continue
+ fi
+ PROCESS=`$NODETOOL rpcterms erlang whereis "'${WAIT_FOR_PROCESS}'."`
+ if [ "$PROCESS" != "undefined" ]; then
+ # Attempt to create a .pid file for the process
+ create_pid_file
+ exit 0
+ fi
+ done
+ echo "${SCRIPT} failed to start within ${WAIT_FOR_ERLANG:-15} seconds,"
+ echo "see the output of '${SCRIPT} console' for more information."
+ echo "If you want to wait longer, set the environment variable"
+ echo "WAIT_FOR_ERLANG to the number of seconds to wait."
+ exit 1
+ fi
+
+ # Attempt to create .pid file
+ create_pid_file
+}
+
+do_stop() {
+ get_pid
+ ES=$?
+ if [ "$ES" -ne 0 ] || [ -z $PID ]; then
+ exit $ES
+ fi
+
+ # Tell nodetool to stop
+ $NODETOOL stop
ES=$?
if [ "$ES" -ne 0 ]; then
- echoerr "Unable to access $PID_DIR, permission denied, run script as root"
- exit 1
+ exit $ES
fi
- # Now call bootstrap to drop to $RUNNER_USER
- bootstrap $@
+ # Now wait for the app to *really* stop
+ while `kill -s 0 $PID 2>/dev/null`;
+ do
+ sleep 1
+ done
+
+ # remove pid file
+ rm -f $PID_FILE
}
# Check the first argument for instructions
case "$1" in
start)
# Bootstrap daemon command (check perms & drop to $RUNNER_USER)
bootstrapd $@
-
- # Make sure there is not already a node running
- node_down_check
-
- # Warn the user if ulimit is too low
- check_ulimit
-
- # Make sure log directory exists
- mkdir -p $RUNNER_LOG_DIR
-
- HEART_COMMAND="$RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT start"
- export HEART_COMMAND
- mkdir -p $PIPE_DIR
- $ERTS_PATH/run_erl -daemon $PIPE_DIR/ $RUNNER_LOG_DIR \
- "exec $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT console" 2>&1
-
- if [ ! -z "$WAIT_FOR_PROCESS" ]; then
- # Wait for the node to come up. We can't just ping it because
- # distributed erlang comes up for a second before the node crashes
- # (eg. in the case of an unwriteable disk). Once the node comes
- # up we check for the $WAIT_FOR_PROCESS} process. If that's running
- # then we assume things are good enough. This will at least let
- # the user know when the node is crashing right after startup.
- WAIT=${WAIT_FOR_ERLANG:-15}
- while [ $WAIT -gt 0 ]; do
- WAIT=`expr $WAIT - 1`
- sleep 1
-
- # squash stderr output to not frighten users if the node does not
- # come up right away
- MUTE=`ping_node 2> /dev/null`
- if [ "$?" -ne 0 ]; then
- continue
- fi
- PROCESS=`$NODETOOL rpcterms erlang whereis "'${WAIT_FOR_PROCESS}'."`
- if [ "$PROCESS" != "undefined" ]; then
- # Attempt to create a .pid file for the process
- create_pid_file
- exit 0
- fi
- done
- echo "${SCRIPT} failed to start within ${WAIT_FOR_ERLANG:-15} seconds,"
- echo "see the output of '${SCRIPT} console' for more information."
- echo "If you want to wait longer, set the environment variable"
- echo "WAIT_FOR_ERLANG to the number of seconds to wait."
- exit 1
- fi
-
- # Attempt to create .pid file
- create_pid_file
+ do_start
;;
stop)
# Bootstrap daemon command (check perms & drop to $RUNNER_USER)
bootstrapd $@
-
- get_pid
- ES=$?
- if [ "$ES" -ne 0 ] || [ -z $PID ]; then
- exit $ES
- fi
-
- # Tell nodetool to stop
- $NODETOOL stop
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
-
- # Now wait for the app to *really* stop
- while `kill -s 0 $PID 2>/dev/null`;
- do
- sleep 1
- done
-
- # remove pid file
- rm -f $PID_FILE
+ do_stop
;;
restart)
# Bootstrap daemon command (check perms & drop to $RUNNER_USER)
bootstrapd $@
-
- ## Restart the VM without exiting the process
- $NODETOOL restart
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
+ do_stop
+ do_start
;;
- reboot)
+ ping)
# Bootstrap daemon command (check perms & drop to $RUNNER_USER)
bootstrapd $@
-
- ## Restart the VM completely (uses heart to restart it)
- $NODETOOL reboot
- ES=$?
- if [ "$ES" -ne 0 ]; then
- exit $ES
- fi
- ;;
-
- ping)
- # Bootstrap command (simply drop to $RUNNER_USER)
- bootstrap $@
-
## See if the VM is alive
ping_node
ES=$?
@@ -298,14 +304,14 @@ case "$1" in
echo "Remote Shell: Use \"Ctrl-C a\" to quit. q() or init:stop() will terminate the $SCRIPT node."
shift
NODE_NAME=${NAME_ARG#* }
- exec $ERTS_PATH/erl -name c_$$_$NODE_NAME -hidden -remsh $NODE_NAME $COOKIE_ARG
+ exec $ERTS_PATH/erl -name c_$$_$NODE_NAME -hidden -remsh $NODE_NAME $COOKIE_ARG $NET_TICKTIME_ARG
;;
console)
# Bootstrap daemon command (check perms & drop to $RUNNER_USER)
bootstrapd $@
- RES=`ping_node`
+ RES=`ping_node 2> /dev/null`
if [ "$?" -eq 0 ]; then
echo "Node is already running - use '$SCRIPT attach' instead"
exit 1
@@ -329,10 +335,9 @@ case "$1" in
BINDIR=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
EMU=beam
PROGNAME=`echo $0 | sed 's/.*\///'`
- CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$RUNNER_SCRIPT \
- -config $CONFIG_FILE \
- -pa $RUNNER_PATCH_DIR \
- -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}"
+ CMD="$NUMACTL $BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$RUNNER_SCRIPT \
+ $CONFIG_ARGS \
+ -pa $RUNNER_PATCH_DIR -- ${1+"$@"}"
export EMU
export ROOTDIR
export BINDIR
@@ -350,9 +355,6 @@ case "$1" in
;;
top)
- # Bootstrap command (simply drop to $RUNNER_USER)
- bootstrap $@
-
# Make sure the local node IS running
node_up_check
@@ -361,7 +363,7 @@ case "$1" in
NODE_NAME=${NAME_ARG#* }
$ERTS_PATH/erl -noshell -noinput \
-pa $RUNNER_PATCH_DIR \
- -hidden $NAME_PARAM np_etop$MYPID$NAME_HOST $COOKIE_ARG \
+ -hidden $NAME_PARAM np_etop$MYPID$NAME_HOST $COOKIE_ARG $NET_TICKTIME_ARG \
-s etop -s erlang halt -output text \
-node $NODE_NAME \
$* -tracing off
@@ -372,16 +374,45 @@ case "$1" in
;;
chkconfig)
- # Bootstrap command (simply drop to $RUNNER_USER)
- bootstrap $@
+ bootstrapd $@
check_config
;;
- escript)
- # Bootstrap command (simply drop to $RUNNER_USER)
- bootstrap $@
+ config)
+ shift
+ if [ -z "$CUTTLEFISH" ]; then
+ echo "This application is not configured to use cuttlefish."
+ echo "$RUNNER_SCRIPT config is not available."
+ exit 1
+ else
+ # Let's validate the output
+
+ case "$1" in
+ effective) ## Great, pass through!
+ ;;
+ describe)
+ if [ $# -lt 2 ] || [ "$2" = "-l" ]; then
+ echo "$RUNNER_SCRIPT config describe requires a variable name to query"
+ echo " Try \`$RUNNER_SCRIPT config describe setting.name\`"
+ exit 1
+ fi
+ ;;
+ generate) ## Great, pass through!
+ ;;
+ *)
+ echo "Valid commands for $RUNNER_SCRIPT config are:"
+ echo " $RUNNER_SCRIPT config effective"
+ echo " $RUNNER_SCRIPT config describe VARIABLE"
+ exit 1
+ ;;
+ esac
+
+ printf '%s \n' "`$CUTTLEFISH_COMMAND_PREFIX $@`"
+ fi
+ ;;
+ escript)
shift
$ERTS_PATH/escript "$@"
ES=$?
@@ -395,9 +426,6 @@ case "$1" in
;;
getpid)
- # Bootstrap command (simply drop to $RUNNER_USER)
- bootstrap $@
-
# Get the PID from nodetool
get_pid
ES=$?
View
3 priv/templates/deb/Makefile
@@ -9,10 +9,11 @@ default:
-e REVISION=$(PKG_VERSION) \
-e RELEASE=$(PKG_BUILD) \
-e REBAR=$(REBAR) \
+ {{debuild_extra_options}} \
-uc -us
mkdir -p ../packages
cd .. && mv *$(PKG_VERSION)-$(PKG_BUILD)_*.deb packages
cd ../packages && \
- for debfile in `ls *.deb`; do \
+ for debfile in *.deb; do \
sha256sum $${debfile} > $${debfile}.sha \
; done
View
2 priv/templates/deb/Makefile.bootstrap
@@ -7,6 +7,6 @@ export
bootstrap:
mkdir -p $(PKG_ID)/debian
cd $(PKG_ID)/debian && $(REBAR) -v create \
- template_dir=../deps/node_package/priv/templates \
+ template_dir=../$(DEPS_DIR)/node_package/priv/templates \
template_vars=../pkg.vars.config template=deb
make -C $(PKG_ID) -f debian/Makefile
View
3 priv/templates/deb/control
@@ -8,7 +8,6 @@ Homepage: {{vendor_url}}
Package: {{package_name}}
Architecture: any
-Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, logrotate, sudo, {{deb_depends}}
+Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, logrotate, {{deb_depends}}
Description: {{package_shortdesc}}
{{package_desc}}
-
View
18 priv/templates/deb/init.script
@@ -9,7 +9,6 @@
# Description: {{package_desc}}
### END INIT INFO
-DESC="{{package_shortdesc}}"
NAME={{package_install_name}}
DAEMON=/usr/{{bin_or_sbin}}/$NAME
SCRIPTNAME=/etc/init.d/$NAME
@@ -21,6 +20,13 @@ SCRIPTNAME=/etc/init.d/$NAME
. /lib/init/vars.sh
. /lib/lsb/init-functions
+# `service` strips all environmental VARS so
+# if no HOME was set in /etc/default/$NAME then set one here
+# to the data directory for erlexec's sake
+if [ -z "$HOME" ]; then
+ export HOME={{platform_data_dir}}
+fi
+
#
# Function that starts the daemon/service
#
@@ -80,8 +86,8 @@ do_status() {
case "$1" in
start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- $DAEMON ping 2>&1>/dev/null && echo $"$NAME is already running" && exit 0
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $NAME"
+ $DAEMON ping >/dev/null 2>&1 && echo $"$NAME is already running" && exit 0
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@@ -91,7 +97,7 @@ case "$1" in
esac
;;
stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@@ -105,14 +111,14 @@ case "$1" in
$DAEMON ping || exit $?
;;
reload|force-reload)
- log_daemon_msg "Reloading $DESC" "$NAME"
+ log_daemon_msg "Reloading $NAME"
do_reload
ES=$?
log_end_msg $ES
exit $ES
;;
restart)
- log_daemon_msg "Restarting $DESC" "$NAME"
+ log_daemon_msg "Restarting $NAME"
do_stop
case "$?" in
0|1)
View
1 priv/templates/deb/postinst
@@ -33,6 +33,7 @@ chmod 0755 /var/run/{{package_install_name}} /etc/{{package_install_name}}
chmod 0644 /etc/{{package_install_name}}/*
chmod -R +X /etc/{{package_install_name}}
chmod 0755 /usr/lib/{{package_install_name}}/lib/env.sh
+chmod 0755 /usr/lib/{{package_install_name}}/erts-*/bin/nodetool
case "$1" in
configure)
View
2 priv/templates/fbsd/Makefile
@@ -37,7 +37,7 @@ build: packing_list_files templates
mv $(TARNAME).gz ../../packages/$(PKGNAME)
cd ../packages && \
- for tarfile in `ls *.tbz`; do \
+ for tarfile in *.tbz; do \
shasum -a 256 $${tarfile} > $${tarfile}.sha \
; done
View
2 priv/templates/fbsd/Makefile.bootstrap
@@ -7,6 +7,6 @@ export
bootstrap:
mkdir -p $(PKG_ID)/fbsd
cd $(PKG_ID)/fbsd && $(REBAR) -v create \
- template_dir=../deps/node_package/priv/templates \
+ template_dir=../$(DEPS_DIR)/node_package/priv/templates \
template_vars=../pkg.vars.config template=fbsd
$(MAKE) -C $(PKG_ID) -f fbsd/Makefile
View
18 priv/templates/fbsdng/+MANIFEST
@@ -0,0 +1,18 @@
+name: {{package_name}}
+origin: {{freebsd_package_category}}
+comment: {{package_shortdesc}}
+licenses: [{{license_type}}]
+licenselogic: single
+arch: freebsd:10:x86:64
+www: {{vendor_url}}
+maintainer: {{vendor_contact_email}}
+users: [{{package_install_user}}]
+groups: [{{package_install_group}}]
+prefix: /usr/local
+categories: [{{freebsd_package_category}}]
+desc: "{{package_desc}}"
+scripts:
+ pre-install: |-
+ if ! pw groupshow {{package_install_group}} 2>/dev/null; then pw groupadd {{package_install_group}}; fi
+ if ! pw usershow {{package_install_user}} 2>/dev/null; then pw useradd {{package_install_user}} -g {{package_install_group}} -h - -d {{platform_data_dir}} -s /bin/sh -c \"{{package_install_user_desc}}\"; fi
+ if [ ! -d /var/log/{{package_install_name}} ]; then mkdir /var/log/{{package_install_name}} && chown {{package_install_user}}:{{package_install_group}} /var/log/{{package_install_name}}; fi
View
98 priv/templates/fbsdng/Makefile
@@ -0,0 +1,98 @@
+BUILDDIR = $(shell pwd)
+BUILD_STAGE_DIR = $(BUILDDIR)/{{package_name}}
+
+# Where we install things (based on vars.config)
+# /usr/local based dirs
+PMAN_DIR = $(BUILD_STAGE_DIR)/usr/local/man
+PBIN_DIR = $(BUILD_STAGE_DIR)/{{platform_bin_dir}}
+PETC_DIR = $(BUILD_STAGE_DIR)/{{platform_etc_dir}}
+PLIB_DIR = $(BUILD_STAGE_DIR)/{{platform_base_dir}}
+# /var based dirs
+PDATA_DIR = $(BUILD_STAGE_DIR)/{{platform_data_dir}}
+PLOG_DIR = $(BUILD_STAGE_DIR)/var/log/{{package_install_name}}
+
+# For scanning later, remove the leading slash
+# '/var/db/server' becomes 'var/db/server'
+PDATA_ROOT_DIR = $(shell echo "{{platform_data_dir}}" | cut -d'/' -f 2-4)
+
+TARNAME = {{package_name}}-$(PKG_VERSION)-$(OSNAME)-$(ARCH).tar
+PKGNAME = {{package_name}}-$(PKG_VERSION)-$(OSNAME)-$(ARCH).tbz
+
+
+# Recursive assignment of ERTS version
+# We will know this after building the rel
+ERTS_PATH = $(shell ls $(BUILDDIR)/rel/{{package_install_name}} | egrep -o "erts-.*")
+
+build: packing_list_files
+ @echo "Building package $(PKGNAME)"
+
+ cd $(BUILD_STAGE_DIR) && \
+ mkdir ../../packages && \
+ pkg create -m . -r . -o ../../packages
+
+ cd ../packages && \
+ for tarfile in *.txz; do \
+ shasum -a 256 $${tarfile} > $${tarfile}.sha \
+ ; done
+
+packing_list_files: $(BUILD_STAGE_DIR)
+ @mv ${BUILDDIR}/fbsdng/+MANIFEST ${BUILD_STAGE_DIR}
+ sed -e "s/%ERTS_PATH%/${ERTS_PATH}/" < \
+ ${BUILDDIR}/fbsdng/rc.d > ${BUILD_STAGE_DIR}/usr/local/etc/rc.d/{{package_install_name}}
+ chmod -w ${BUILD_STAGE_DIR}/usr/local/etc/rc.d/{{package_install_name}}
+ chmod +x ${BUILD_STAGE_DIR}/usr/local/etc/rc.d/{{package_install_name}}
+ @cd $(BUILD_STAGE_DIR) && \
+ echo "version: ${PKG_VERSION}" >> +MANIFEST && \
+ echo "files:" >> +MANIFEST
+
+ @echo "Copying Man pages to staging directory"
+ @cd $(BUILDDIR) && \
+ if [ -d doc/man/man1 ]; then \
+ mkdir -p $(PMAN_DIR) && \
+ cp -R doc/man/man1 $(PMAN_DIR); fi
+
+ @echo "Packaging /usr/local files"
+ @cd $(BUILD_STAGE_DIR) && \
+ find usr -type f | while read file ; do \
+ mode=$$(stat -f%p "$$file" | cut -c 3-) && \
+ sum=$$(sha256 -q $$file) && \
+ echo " /$$file: { sum: $$sum, perm: $$mode, uname: root, gname: wheel }" >> +MANIFEST; done
+
+ @cd $(BUILD_STAGE_DIR) && \
+ echo "directories:" >> +MANIFEST && \
+ echo " {{platform_base_dir}}: {}" >> +MANIFEST && \
+ echo " {{platform_data_dir}}: {uname: {{package_install_user}}, gname: {{package_install_group}}, perm: 0700 }" >> +MANIFEST && \
+ echo " {{platform_etc_dir}}: {}" >> +MANIFEST
+
+# Copy the app rel directory to the staging directory to build our
+# package structure and move the directories into the right place
+# for the package, see the vars.config file for destination
+# directories
+$(BUILD_STAGE_DIR): buildrel
+ @echo "Copying rel directory to staging directory"
+ mkdir -p $@
+ mkdir -p $(PBIN_DIR)
+ cp -R rel/{{package_install_name}}/bin/* $(PBIN_DIR)
+ mkdir -p $(PETC_DIR)
+ cp -R rel/{{package_install_name}}/etc/* $(PETC_DIR)
+ mkdir -p $(PLIB_DIR)
+ cp -R rel/{{package_install_name}}/lib $(PLIB_DIR)
+ cp -R rel/{{package_install_name}}/erts-* $(PLIB_DIR)
+ cp -R rel/{{package_install_name}}/releases $(PLIB_DIR)
+ mkdir -p $(PDATA_DIR)
+ cp -R rel/{{package_install_name}}/data/* $(PDATA_DIR)
+ mkdir -p ${BUILD_STAGE_DIR}/usr/local/etc/rc.d
+
+
+# Build the release we need to package
+# * Ensure all binaries are executable
+# * copy the vars.config over for build config
+buildrel:
+ OVERLAY_VARS="overlay_vars=../fbsdng/vars.config" $(MAKE) deps rel
+ chmod 0755 rel/{{package_install_name}}/bin/* rel/{{package_install_name}}/erts-*/bin/*
+
+$(BUILDDIR):
+ mkdir -p $@
+
+$(PKGERDIR)/pkgclean:
+ rm -rf $(BUILD_STAGE_DIR) $(BUILDDIR)
View
12 priv/templates/fbsdng/Makefile.bootstrap
@@ -0,0 +1,12 @@
+
+##
+## Export all variables to sub-invocation
+##
+export
+
+bootstrap:
+ mkdir -p $(PKG_ID)/fbsdng
+ cd $(PKG_ID)/fbsdng && $(REBAR) -v create \
+ template_dir=../$(DEPS_DIR)/node_package/priv/templates \
+ template_vars=../pkg.vars.config template=fbsdng
+ $(MAKE) -C $(PKG_ID) -f fbsdng/Makefile
View
25 priv/templates/fbsdng/fbsdng.template
@@ -0,0 +1,25 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+%%
+{variables, [
+ {package_name, "package_name"},
+ {package_install_name, "package_install_name"},
+ {package_install_user, "package_install_user"},
+ {package_install_user_desc, "package_install_user_desc"},
+ {package_install_group, "package_install_group"},
+ {bin_or_sbin, "bin"},
+ {freebsd_package_category, "db"},
+
+ %% Platform-specific installation paths
+ {platform_bin_dir, "/usr/local/{{bin_or_sbin}}"},
+ {platform_data_dir, "/usr/local/{{package_install_name}}"},
+ {platform_etc_dir, "/usr/local/etc/{{package_install_name}}"},
+ {platform_base_dir, "/usr/local/lib/{{package_install_name}}"},
+ {platform_lib_dir, "/usr/local/lib/{{package_install_name}}/lib"},
+ {platform_log_dir, "/var/log/{{package_install_name}}"}
+ ]
+}.
+{template, "Makefile", "Makefile"}.
+{template, "vars.config", "vars.config"}.
+{template, "+MANIFEST", "+MANIFEST"}.
+{template, "rc.d", "rc.d"}.
View
19 priv/templates/fbsdng/rc.d
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: {{package_install_name}}
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name={{package_install_name}}
+command={{platform_base_dir}}/%ERTS_PATH%/bin/beam.smp
+rcvar={{package_install_name}}_enable
+start_cmd="{{platform_bin_dir}}/${name} start"
+stop_cmd="{{platform_bin_dir}}/${name} stop"
+pidfile="/var/run/${name}/${name}.pid"
+
+load_rc_config $name
+run_rc_command "$1"
View
20 priv/templates/fbsdng/vars.config
@@ -0,0 +1,20 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+
+%% Platform-specific installation paths
+{platform_bin_dir, "{{platform_bin_dir}}"}.
+{platform_data_dir, "{{platform_data_dir}}"}.
+{platform_etc_dir, "{{platform_etc_dir}}"}.
+{platform_base_dir, "{{platform_base_dir}}"}.
+{platform_lib_dir, "{{platform_lib_dir}}"}.
+{platform_log_dir, "{{platform_log_dir}}"}.
+
+%% TODO can we just get rid of these?
+{runner_script_dir, "{{platform_bin_dir}}"}.
+{runner_base_dir, "{{platform_base_dir}}"}.
+{runner_etc_dir, "{{platform_etc_dir}}"}.
+{runner_log_dir, "{{platform_log_dir}}"}.
+{runner_user, "{{package_install_user}}"}.
+{runner_lib_dir, "{{platform_lib_dir}}"}.
+{runner_patch_dir, "{{platform_lib_dir}}/{{package_patch_dir}}"}.
+{pipe_dir, "/tmp/{{package_install_name}}/"}.
View
2 priv/templates/osx/Makefile
@@ -10,7 +10,7 @@ default: buildrel
tar -czf ../packages/$(PKGNAME) \
{{package_name}}-$(PKG_VERSION)
cd packages && \
- for tarfile in `ls *.gz`; do \
+ for tarfile in *.gz; do \
shasum -a 256 $${tarfile} > $${tarfile}.sha \
; done
View
2 priv/templates/osx/Makefile.bootstrap
@@ -6,6 +6,6 @@ export
bootstrap:
$(REBAR) -v create \
- template_dir=$(PKG_ID)/deps/node_package/priv/templates \
+ template_dir=$(PKG_ID)/$(DEPS_DIR)/node_package/priv/templates \
template_vars=$(PKG_ID)/pkg.vars.config template=osx
make -f Makefile
View
16 priv/templates/rpm/Makefile
@@ -1,12 +1,21 @@
PWD = $(shell pwd)
+
+
+ifeq ($(OSNAME),RedHat)
DISTRO = $(shell head -1 /etc/redhat-release| awk \
'{if ($$0 ~ /CentOS release 5/) { print ".el5."} else { print "." }} ')
+INITSCRIPT=rhel.init.script
+endif
+ifeq ($(OSNAME),SLES)
+DISTRO = .SLES$(shell grep VERSION /etc/SuSE-release | cut -d ' ' -f 3).
+INITSCRIPT=suse.init.script
+endif
# No hyphens are allowed in the _version field in RPM
PKG_VERSION_NO_H ?= $(shell echo $(PKG_VERSION) | tr - .)
-default:
+default: init.script
mkdir -p BUILD
mkdir -p packages
rpmbuild --define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}$(DISTRO)%%{ARCH}.rpm" \
@@ -22,6 +31,9 @@ default:
--define "_tarname_base $(PKG_ID)" \
-ba $(PWD)/specfile
cd packages && \
- for rpmfile in `ls *.rpm`; do \
+ for rpmfile in *.rpm; do \
sha256sum $${rpmfile} > $${rpmfile}.sha \
; done
+
+init.script:
+ cp $(INITSCRIPT) init.script
View
2 priv/templates/rpm/Makefile.bootstrap
@@ -6,6 +6,6 @@ export
bootstrap:
$(REBAR) -v create \
- template_dir=$(PKG_ID)/deps/node_package/priv/templates \
+ template_dir=$(PKG_ID)/$(DEPS_DIR)/node_package/priv/templates \
template_vars=$(PKG_ID)/pkg.vars.config template=rpm
make -f Makefile
View
11 priv/templates/rpm/init.script → priv/templates/rpm/rhel.init.script
@@ -7,6 +7,7 @@
# processname: beam
# config: /etc/{{package_install_name}}/app.config
# config: /etc/{{package_install_name}}/vm.args
+# config: /etc/sysconfig/{{package_install_name}}
#
# Source function library.
@@ -25,6 +26,16 @@ pidfile=/var/run/$NAME/$NAME.pid
[ -d /etc/$NAME ] || exit 0
[ -d /var/lib/$NAME ] || exit 0
+# Read configuration variable file if it is present and readable
+[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
+
+# `service` strips all environmental VARS so
+# if no HOME was set in /etc/sysconfig/$NAME then set one here
+# to the data directory for erlexec's sake
+if [ -z "$HOME" ]; then
+ export HOME={{platform_data_dir}}
+fi
+
status -p $pidfile -l $(basename $lockfile) $NAME >/dev/null 2>&1
running=$?
View
3 priv/templates/rpm/rpm.template
@@ -17,4 +17,5 @@
}.
{template, "Makefile", "Makefile"}.
{template, "specfile", "specfile"}.
-{template, "init.script", "init.script"}.
+{template, "rhel.init.script", "rhel.init.script"}.
+{template, "suse.init.script", "suse.init.script"}.
View
52 priv/templates/rpm/specfile
@@ -1,8 +1,22 @@
-# _revision, _release, and _version should be defined on the rpmbuild command
-# line like so:
-#
-# --define "_version 0.9.1.19.abcdef" --define "_release 7" \
-# --define "_revision 0.9.1-19-abcdef"
+## -------------------------------------------------------------------
+##
+## Copyright (c) 2014 Basho Technologies, Inc.
+##
+## This file is provided to you under the Apache License,
+## Version 2.0 (the "License"); you may not use this file
+## except in compliance with the License. You may obtain
+## a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+## -------------------------------------------------------------------
Name: {{package_name}}
Version: %{_version}
@@ -102,13 +116,13 @@ cp -R %{relpath}/data/* \
mkdir -p %{buildroot}%{_sysconfdir}/init.d
install -m755 %{_topdir}/init.script %{buildroot}%{_sysconfdir}/init.d/{{package_install_name}}
-
# Needed to work around check-rpaths which seems to be hardcoded into recent
# RPM releases
export QA_RPATHS=3
%pre
+# Pre-install script
if ! getent group {{package_install_group}} >/dev/null 2>&1; then
groupadd -r {{package_install_group}}
fi
@@ -119,16 +133,38 @@ else
useradd -r -g {{package_install_group}} \
--home %{_localstatedir}/lib/{{package_install_name}} \
--comment "{{package_install_user_desc}}" \
+ --shell /bin/bash \
{{package_install_user}}
fi
+
%post
-# Fixup perms for SELinux (if it is enabled)
-selinuxenabled && find %{_localstatedir}/lib/{{package_install_name}} -name "*.so" -exec chcon -t textrel_shlib_t {} \;
+# Post Installation Script
+
+# For distros with SELinux (RHEL/Fedora)
+if [ `which selinuxenabled > /dev/null 2>&1` ] ; then
+ # Fixup perms for SELinux (if it is enabled)
+ selinuxenabled && find %{_localstatedir}/lib/{{package_install_name}} -name "*.so" -exec chcon -t textrel_shlib_t {} \;
+fi
# Make sure shell library file is readable
chmod 0755 %{_libdir}/{{package_install_name}}/lib/env.sh
+# Add application to chkconfig, but default to "off"
+/sbin/chkconfig --add {{package_install_name}}
+/sbin/chkconfig {{package_install_name}} off
+
+
+%preun
+# Pre-uninstall script
+
+# Only on uninstall, not upgrades
+if [ "$1" = 0 ] ; then
+ /sbin/service {{package_install_name}} stop > /dev/null 2>&1
+ /sbin/chkconfig --del {{package_install_name}}
+fi
+exit 0
+
# Man pages are optional and might be missing, read from file
%files -f additional_files_list
View
156 priv/templates/rpm/suse.init.script
@@ -0,0 +1,156 @@
+#!/bin/sh
+#
+# {{package_name}}
+#
+### BEGIN INIT INFO
+# Provides: {{package_name}}
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: {{package_shortdesc}}
+# Description: {{package_desc}}
+### END INIT INFO
+
+# Source the LSB function library.
+. /lib/lsb/init-functions
+
+RETVAL=0
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="{{package_shortdesc}}"
+NAME={{package_install_name}}
+DAEMON=/usr/{{bin_or_sbin}}/$NAME
+lockfile=/var/lock/subsys/$NAME
+pidfile=/var/run/$NAME/$NAME.pid
+
+# Check for script, config and data dirs
+[ -x /usr/{{bin_or_sbin}}/$NAME ] || exit 0
+[ -d /etc/$NAME ] || exit 0
+[ -d /var/lib/$NAME ] || exit 0
+
+# Read configuration variable file if it is present and readable
+[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
+
+# `service` strips all environmental VARS so
+# if no HOME was set in /etc/sysconfig/$NAME then set one here
+# to the data directory for erlexec's sake
+if [ -z "$HOME" ]; then
+ export HOME={{platform_data_dir}}
+fi
+
+# Checks the status of a node
+do_status() {
+ $DAEMON ping >/dev/null 2>&1 && return 0 || return 3
+}
+
+check_pid_status() {
+ pid=$(ps ax | grep beam.smp | grep "\-progname $NAME" | awk '{print $1}')
+ if [ "$pid" = "" ]; then
+ # prog not running?
+ return 1
+ else
+ # running
+ return 0
+ fi
+}
+
+do_start() {
+ # Start daemons.
+ echo -n $"Starting {{package_install_name}}: "
+ $DAEMON start
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]; then
+ touch $lockfile
+ log_success_msg
+ else
+ log_failure_msg $"$NAME start"
+ fi
+ echo
+ return $RETVAL
+}
+
+do_stop() {
+ # Stop daemon.
+ echo -n $"Shutting down {{package_install_name}}: "
+ $DAEMON stop 2>/dev/null
+ for n in $(seq 1 10); do
+ sleep 1
+ check_pid_status
+ RETVAL=$?
+ if [ $RETVAL -eq 1 ]; then
+ break
+ fi
+ done
+ if [ $RETVAL -eq 1 ]; then
+ rm -f $lockfile $pidfile
+ log_success_msg
+ echo && return 0
+ else
+ log_failure_msg $"$NAME stop"
+ echo && return 1
+ fi
+}
+
+do_hardstop() {
+ echo -n $"Shutting down $NAME: "
+ su - {{package_install_user}} -c "ps -ef | grep beam.smp | grep '\-progname $NAME ' | grep -v grep | awk '{print \$2}' | xargs kill -9"
+ for n in $(seq 1 10); do
+ sleep 1
+ check_pid_status
+ RETVAL=$?
+ if [ $RETVAL -eq 1 ]; then
+ break
+ fi
+ done
+ if [ $RETVAL -eq 1 ]; then
+ rm -f $lockfile $pidfile
+ log_success_msg
+ echo && return 0
+ else
+ log_failure_msg $"$NAME hardstop"
+ echo && return 1
+ fi
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ do_status && exit 0
+ do_start
+ ;;
+ stop)
+ if do_status; then
+ do_stop
+ else
+ check_pid_status
+ RETVAL=$?
+ if [ $RETVAL -eq 1 ]; then
+ rm -f $lockfile $pidfile
+ fi
+ exit 0
+ fi
+ ;;
+ restart|reload|force-reload)
+ do_status && do_stop
+ do_start
+ ;;
+ hardstop)
+ do_status || exit 0
+ do_hardstop
+ ;;
+ condrestart|try-restart)
+ do_status && do_stop || exit 0
+ do_start
+ ;;
+ status)
+ do_status && echo $"$NAME is running" && exit 0 || echo $"$NAME is stopped" && exit 3
+ ;;
+ ping)
+ $DAEMON ping || exit $?
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart|reload|force-reload|hardstop|condrestart|try-restart|status|ping}"
+ exit 1
+esac
+
+exit $?
View
2 priv/templates/smartos/+DISPLAY
@@ -10,7 +10,7 @@ The primary directories are:
{platform_lib_dir, "{{platform_lib_dir}}"}
{platform_log_dir, "{{platform_log_dir}}"}
-These can be configured and changed in the {{platform_etc_dir}}/app.config.
+These can be configured and changed in the configuration files in {{platform_etc_dir}}
Add {{platform_bin_dir}} to your path to run the {{#package_commands}}{{name}} {{/package_commands}} directly.
View
44 priv/templates/smartos/+INSTALL
@@ -3,6 +3,9 @@
# Variable that will get replaced by the Makefile dirs_create target
CREATE_DIRS="%DIRS_CREATE%"
+# Config files that could possibly be installed
+CONFIG_FILES="vm.args app.config advanced.config {{cuttlefish_conf}}"
+
if [ "$2" = "PRE-INSTALL" ]; then
if ! getent group "{{package_install_group}}" 2>/dev/null 1>&2; then
groupadd {{package_install_group}}
@@ -26,16 +29,13 @@ if [ "$2" = "PRE-INSTALL" ]; then
done
# Backup config files if they already exist
- if [ -f {{platform_etc_dir}}/vm.args ]; then
- echo "Config file exists: backing up {{platform_etc_dir}}/vm.args to {{platform_etc_dir}}/vm.args.bak"
- cp {{platform_etc_dir}}/vm.args {{platform_etc_dir}}/vm.args.bak
- fi
-
- if [ -f {{platform_etc_dir}}/app.config ]; then
- echo "Config file exists: backing up {{platform_etc_dir}}/app.config to {{platform_etc_dir}}/app.config.bak"
- cp {{platform_etc_dir}}/app.config {{platform_etc_dir}}/app.config.bak
- fi
-
+ # These will be moved back to their proper names in the post-install
+ for i in $CONFIG_FILES; do
+ if [ -f {{platform_etc_dir}}/$i ]; then
+ echo "Config file exists: backing up {{platform_etc_dir}}/$i to {{platform_etc_dir}}/$i.bak"
+ mv {{platform_etc_dir}}/$i {{platform_etc_dir}}/$i.bak
+ fi
+ done
fi
if [ "$2" = "POST-INSTALL" ]; then
@@ -49,14 +49,36 @@ if [ "$2" = "POST-INSTALL" ]; then
# Ensure proper ownership of lib directory
chown -R {{package_install_user}}:{{package_install_group}} {{platform_lib_dir}}
+ # Treat new configuration files as new if old ones already exist
+ # if FILE and FILE.bak both exist, move FILE to FILE.new and FILE.bak to FILE
+ # If there is just a FILE.bak and no newer file, copy the .bak file back to FILE
+ # this supports the changing of configuration file names on upgrades
+ for i in $CONFIG_FILES; do
+ if [ -f {{platform_etc_dir}}/$i -a -f {{platform_etc_dir}}/$i.bak ]; then
+ echo "Config file already exists, creating new configuration file as {{platform_etc_dir}}/$i.new"
+ mv {{platform_etc_dir}}/$i {{platform_etc_dir}}/$i.new
+ mv {{platform_etc_dir}}/$i.bak {{platform_etc_dir}}/$i
+ elif [ -f {{platform_etc_dir}}/$i.bak -a ! -f {{platform_etc_dir}}/$i ]; then
+ mv {{platform_etc_dir}}/$i.bak {{platform_etc_dir}}/$i
+ fi
+ done
+
# Ensure proper ownership of etc directory
# This shouldn't have to happen in the post-install, but
# there is some non-deterministic stuff happening during
# install on SmartOS that causes wrong ownership.
chown -R root:{{package_install_group}} {{platform_etc_dir}}
+
+ for i in $CONFIG_FILES; do
+ if [ -f {{platform_etc_dir}}/$i ]; then
+ chmod 640 {{platform_etc_dir}}/$i
+ fi
+ done
+
chmod -R g+r+X {{platform_etc_dir}}
- # Create {{package_install_name}} project
+
+ # Create {{package_install_name}} project to handle custom system settings
if ! projects -l {{package_install_name}} >/dev/null 2>&1; then
projadd -U {{package_install_user}} -G {{package_install_group}} \
-K "process.max-file-descriptor=(priv,262140,deny)" \
View
14 priv/templates/smartos/Makefile
@@ -15,8 +15,6 @@ BUILD_STAGE_DIR = $(BUILDDIR)/$(PACKAGE_NAME_CLEAN)
## 1.6 0.9.8knb1 5.4nb1
## 1.8 0.9.8knb1 5.4nb1
## 13.1 1.0.1c 5.4nb1
-## ## Additional Deps for runner
-## sudo (same for all versions)
##
## ## SMF Manifest Mapping
## SmartOS Manifest File
@@ -94,7 +92,7 @@ build: packing_list_files dirs_file
mv $(TARNAME).gz ../../packages/$(PKGNAME)
cd ../packages && \
- for tarfile in `ls *.tgz`; do \
+ for tarfile in *.tgz; do \
shasum -a 256 $${tarfile} > $${tarfile}.sha \
; done
@@ -110,7 +108,6 @@ packing_list_files: $(BUILD_STAGE_DIR) templates
@echo "Adding to packaging list $(PACKAGE_NAME_CLEAN)-$(PKG_VERSION)"
echo "@name $(PACKAGE_NAME_CLEAN)-$(PKG_VERSION)" >> plist
echo "@pkgcfl $(PACKAGE_NAME_CLEAN)-*" >> plist
- echo "@pkgdep sudo-[0-9]*" >> plist
echo "@pkgdep $(OPENSSL_DEP)" >> plist
echo "@pkgdep $(NCURSES_DEP)" >> plist
echo "@pkgdep $(GCC_DEP)" >> plist
@@ -131,10 +128,7 @@ packing_list_files: $(BUILD_STAGE_DIR) templates
echo "@cwd /opt/local" >> +CONTENTS && \
echo "@owner root" >> +CONTENTS && \
echo "@group {{package_install_user}}" >> +CONTENTS && \
- find etc -type f >> +CONTENTS && \
- echo "@exec chmod o-r {{platform_etc_dir}}/vm.args" >> +CONTENTS && \
- echo "@exec chown -R root:{{package_install_group}} {{platform_etc_dir}}" >> +CONTENTS && \
- echo "@exec chmod -R g+r+X {{platform_etc_dir}}" >> +CONTENTS
+ find etc -type f >> +CONTENTS
cd $(BUILD_STAGE_DIR) && \
echo "@comment Packing lib files" >> +CONTENTS && \
@@ -240,13 +234,9 @@ smartos_check:
# Patch the runner script with SmartOS modifications
patch_runner: buildrel
cp $(PKGERDIR)/runner.patch $(BUILDDIR)/rel/{{package_install_name}}/bin/
- cp $(PKGERDIR)/env.patch $(BUILDDIR)/rel/{{package_install_name}}/lib/
cd $(BUILDDIR)/rel/{{package_install_name}}/bin && \
patch -p0 {{package_install_name}} runner.patch
rm $(BUILDDIR)/rel/{{package_install_name}}/bin/runner.patch
- cd $(BUILDDIR)/rel/{{package_install_name}}/lib && \
- patch -p0 env.sh env.patch
- rm $(BUILDDIR)/rel/{{package_install_name}}/lib/env.patch
# Build the release we need to package
View
2 priv/templates/smartos/Makefile.bootstrap
@@ -7,6 +7,6 @@ export
bootstrap:
mkdir -p $(PKG_ID)/smartos
cd $(PKG_ID)/smartos && $(REBAR) -v create \
- template_dir=../deps/node_package/priv/templates \
+ template_dir=../$(DEPS_DIR)/node_package/priv/templates \
template_vars=../pkg.vars.config template=smartos
$(MAKE) -C $(PKG_ID) -f smartos/Makefile
View
4 priv/templates/smartos/env.patch
@@ -1,4 +0,0 @@
-169c169
-< exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
----
-> exec sudo -H -u $RUNNER_USER $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
View
38 priv/templates/smartos/runner.patch
@@ -1,40 +1,34 @@
-54a55
->
-57a59,64
+176,177c176,182
+< # Warn the user if ulimit is too low
+< check_ulimit
+---
+> # Make sure we have access to enough file descriptors
+> ULIMIT_S=$(prctl -n process.max-file-descriptor -t system -P $$ | awk '/max-file-descriptor/ { print $3 }')
+> ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
+> if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
+> echo "Trying to raise the file descriptor limit to maximum allowed."
+> prctl -n process.max-file-descriptor -t system -v ${ULIMIT_H} $$ || true
+> fi
+250a256,260
> if [ "${SMF_METHOD}" != "start" ]; then
> echo "***"
> echo "Warning: please use 'svcadm enable $SCRIPT' instead"
> echo "***"
> fi
->
-68,69c75,81
-< # Warn the user if ulimit is too low
-< check_ulimit
----
-> # Make sure we have access to enough file descriptors
-> ULIMIT_S=$(prctl -n process.max-file-descriptor -t basic -P $$ | awk '/max-file-descriptor/ { print $3 }')
-> ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
-> if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
-> echo "Trying to raise the file descriptor limit to maximum allowed."
-> prctl -n process.max-file-descriptor -t basic -v ${ULIMIT_H} $$ || true
-> fi
-116a129
->
-119a133,138
+256a267,271
> if [ "${SMF_METHOD}" != "stop" ]; then
> echo "***"
> echo "Warning: please use 'svcadm disable $SCRIPT' instead"
> echo "***"
> fi
->
-226,227c245,251
+327,328c342,348
< # Warn the user if ulimit -n is less than the defined threshold
< check_ulimit
---
> # Make sure we have access to enough file descriptors
-> ULIMIT_S=$(prctl -n process.max-file-descriptor -t basic -P $$ | awk '/max-file-descriptor/ { print $3 }')
+> ULIMIT_S=$(prctl -n process.max-file-descriptor -t system -P $$ | awk '/max-file-descriptor/ { print $3 }')
> ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
> if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
> echo "Trying to raise the file descriptor limit to maximum allowed."
-> prctl -n process.max-file-descriptor -t basic -v ${ULIMIT_H} $$ || true
+> prctl -n process.max-file-descriptor -t system -v ${ULIMIT_H} $$ || true
> fi
View
1 priv/templates/smartos/smartos.template
@@ -32,4 +32,3 @@
{template, "manifest131.xml", "manifest131.xml"}.
{template, "epmd", "epmd"}.
{template, "runner.patch", "runner.patch"}.
-{template, "env.patch", "env.patch"}.
View
3 priv/templates/solaris/Makefile
@@ -21,13 +21,16 @@ build: buildrel depend pkginfo prototype
cd ../packages && echo "`digest -a sha256 $(PKGFILE).gz` $(PKGFILE).gz" > $(PKGFILE).gz.sha
# Build the release we need to package
+# Make sure to copy binaries to {{bin_or_sbin}}
buildrel:
@# Make sure we set our EUID properly
@# Ye Olde Bourne Shell on Solaris means we have to do it old school
echo "Using `which erl` to build"; \
OVERLAY_VARS="overlay_vars=../solaris/vars.config" $(MAKE) deps rel
chmod 0755 rel/{{package_install_name}}/bin/* \
rel/{{package_install_name}}/erts-*/bin/*
+ if [ "{{bin_or_sbin}}" != "bin" ]; then \
+ mv rel/{{package_install_name}}/bin rel/{{package_install_name}}/{{bin_or_sbin}}; fi
depend:
cp $(PKGERDIR)/depend .
View
2 priv/templates/solaris/Makefile.bootstrap
@@ -7,6 +7,6 @@ export
bootstrap:
mkdir -p $(PKG_ID)/solaris
cd $(PKG_ID)/solaris && $(REBAR) -v create \
- template_dir=../deps/node_package/priv/templates \
+ template_dir=../$(DEPS_DIR)/node_package/priv/templates \
template_vars=../pkg.vars.config template=solaris
$(MAKE) -C $(PKG_ID) -f solaris/Makefile
View
2 priv/templates/solaris/solaris.template
@@ -7,6 +7,7 @@
{package_install_user, "package_install_user"},
{package_install_user_desc, "package_install_user_desc"},
{package_install_group, "package_install_group"},
+ {bin_or_sbin, "bin"},
%% Platform-specific installation paths
{platform_bin_dir, "/opt/{{package_install_name}}/{{bin_or_sbin}}"},
@@ -15,7 +16,6 @@
{platform_base_dir, "/opt/{{package_install_name}}"},
{platform_lib_dir, "/opt/{{package_install_name}}/lib"},
{platform_log_dir, "/opt/{{package_install_name}}/log"},
- {bin_or_sbin, "bin"},
{solaris_pkgname, "MAINTapp"}
]
}.

0 comments on commit e535ac0

Please sign in to comment.
Something went wrong with that request. Please try again.