112 lines
3.1 KiB
Bash
112 lines
3.1 KiB
Bash
#!/bin/bash -e
|
|
|
|
# Shows the usage of this command to the user
|
|
|
|
showUsage()
|
|
{
|
|
cat <<EOF
|
|
Usage: $0 [OPTION] PATH
|
|
|
|
Takes a JSON representation of a managed process configuration and translates
|
|
it to a process manager specific configuration.
|
|
|
|
Options:
|
|
-P, --process-manager=MANAGER
|
|
Process manager to build for
|
|
--state-dir Changes the directory in which the state of the
|
|
processes are stored
|
|
--runtime-dir Changes the directory in which the PID files are stored
|
|
--log-dir Changes the directory in which the log files are stored
|
|
--tmp-dir Changes the directory in which temp files are stored
|
|
--force-disable-user-change
|
|
Forces to not create users, groups or change user
|
|
permissions
|
|
--no-out-link Do not create a symlink to the output path
|
|
--show-trace Shows a trace of the output
|
|
-h, --help Shows the usage of this command
|
|
|
|
Environment:
|
|
NIXPROC_STATE_DIR Changes the directory in which the state of the
|
|
processes is stored
|
|
NIXPROC_RUNTIME_DIR Changes the directory in which the PID files are stored
|
|
NIXPROC_LOG_DIR Changes the directory in which log files are stored
|
|
NIXPROC_TMP_DIR Changes the directory in which temp files are stored
|
|
NIXPROC_FORCE_DISABLE_USER_CHANGE
|
|
Forces to not create users, groups or change user
|
|
permissions
|
|
EOF
|
|
}
|
|
|
|
# Parse valid argument options
|
|
|
|
PARAMS=`@getopt@ -n $0 -o P:h -l process-manager:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,no-out-link,show-trace,help -- "$@"`
|
|
|
|
if [ $? != 0 ]
|
|
then
|
|
showUsage
|
|
exit 1
|
|
fi
|
|
|
|
# Evaluate valid options
|
|
|
|
eval set -- "$PARAMS"
|
|
|
|
while [ "$1" != "--" ]
|
|
do
|
|
case "$1" in
|
|
-P|--process-manager)
|
|
processManager="$2"
|
|
;;
|
|
--state-dir)
|
|
stateDirArg="--state-dir $2"
|
|
;;
|
|
--runtime-dir)
|
|
runtimeDirArg="--runtime-dir $2"
|
|
;;
|
|
--log-dir)
|
|
logDirArg="--log-dir $2"
|
|
;;
|
|
--tmp-dir)
|
|
tmpDirArg="--tmp-dir $2"
|
|
;;
|
|
--force-disable-user-change)
|
|
forceDisableUserChangeArg="--force-disable-user-change"
|
|
;;
|
|
--no-out-link)
|
|
noOutLinkArg="--no-out-link"
|
|
;;
|
|
--show-trace)
|
|
showTraceArg="--show-trace"
|
|
;;
|
|
-h|--help)
|
|
showUsage
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
shift
|
|
done
|
|
|
|
shift
|
|
|
|
configFile="$1"
|
|
|
|
# Validate the given options
|
|
|
|
if [ "$configFile" = "" ]
|
|
then
|
|
echo "A config file must be provided!" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$processManager" = "" ]
|
|
then
|
|
echo "No process manager was specified!" >&2
|
|
exit 1
|
|
fi
|
|
|
|
NIXPROC=${NIXPROC:-@NIXPROC@}
|
|
|
|
# Build the configuration
|
|
nix-build $NIXPROC/create-managed-process/agnostic/create-managed-process-from-config.nix --arg configFile $configFile --argstr processManager $processManager $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $noOutLinkArg $showTraceArg
|