Add state initialization to the deploy scripts, make cache dir configurable

This commit is contained in:
Sander van der Burg 2020-10-13 19:37:23 +02:00 committed by Sander van der Burg
parent 196179930b
commit aceee4f138
39 changed files with 556 additions and 173 deletions

View File

@ -61,11 +61,11 @@ Installation
============
First, make a Git clone of this repository.
The next step is installing the build tool:
The next step is installing the common tools:
```bash
$ cd tools
$ nix-env -f default.nix -iA build
$ nix-env -f default.nix -iA common
```
Then, at least one tool that deploys a configuration for a supported process

View File

@ -29,6 +29,8 @@ let
inherit (stdenv) lib;
};
commonTools = (import ../../../tools {}).common;
generateForegroundProxy = import ./generate-foreground-proxy.nix {
inherit stdenv writeTextFile;
};
@ -87,11 +89,10 @@ let
runAsRoot = ''
${dockerTools.shadowSetup}
# Create a temp dir, because many apps rely on it
mkdir -p /tmp
chmod 1777 /tmp
# Initialize common state directories
${commonTools}/bin/nixproc-init-state --state-dir ${stateDir} --runtime-dir ${runtimeDir}
${stdenv.lib.optionalString (credentialsSpec != null) ''
${stdenv.lib.optionalString (!forceDisableUserChange && credentialsSpec != null) ''
export PATH=$PATH:${findutils}/bin:${glibc.bin}/bin
${dysnomia}/bin/dysnomia-addgroups ${credentialsSpec}
${dysnomia}/bin/dysnomia-addusers ${credentialsSpec}

View File

@ -17,6 +17,8 @@ let
logDir = builtins.getEnv "NIXPROC_LOG_DIR";
} // pkgs.lib.optionalAttrs (builtins.getEnv "NIXPROC_TMP_DIR" != "") {
tmpDir = builtins.getEnv "NIXPROC_TMP_DIR";
} // pkgs.lib.optionalAttrs (builtins.getEnv "NIXPROC_CACHE_DIR" != "") {
tmpDir = builtins.getEnv "NIXPROC_CACHE_DIR";
} // pkgs.lib.optionalAttrs (builtins.getEnv "NIXPROC_FORCE_DISABLE_USER_CHANGE" != "") {
forceDisableUserChange = true;
};

View File

@ -8,3 +8,5 @@ port = 127.0.0.1:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]

View File

@ -43,7 +43,7 @@ makeTest {
environment.systemPackages = [
pkgs.stdenv
pkgs.dysnomia
tools.build
tools.common
tools.generate-config
];
};

View File

@ -79,7 +79,7 @@ makeTest {
pkgs.stdenv
pkgs.dysnomia
pkgs.disnix
tools.build
tools.common
tools.systemd
tools.disnix
];

View File

@ -67,7 +67,7 @@ makeTest {
pkgs.stdenv
pkgs.docker
pkgs.dysnomia
tools.build
tools.common
tools.systemd
tools.docker
];

View File

@ -33,7 +33,7 @@ makeTest {
pkgs.stdenv
pkgs.pythonPackages.supervisor
pkgs.dysnomia
tools.build
tools.common
tools.systemd
tools.supervisord
];

View File

@ -73,7 +73,7 @@ makeTest {
pkgs.stdenv
pkgs.pythonPackages.supervisor
pkgs.dysnomia
tools.build
tools.common
tools.systemd
tools.supervisord
];

View File

@ -83,7 +83,7 @@ makeTest {
environment.systemPackages = [
pkgs.stdenv
pkgs.dysnomia
tools.build
tools.common
tools.systemd
];
};
@ -103,7 +103,10 @@ makeTest {
start_all()
machine.wait_for_unit("display-manager.service")
machine.succeed('su - unprivileged -c "mkdir -p /home/unprivileged/var"')
# Do an undeploy to force the state to get initialized
machine.succeed(
'su - unprivileged -c "${env} nixproc-systemd-switch --user --state-dir /home/unprivileged/var --force-disable-user-change --undeploy"'
)
# Deploy the entire system in auto mode. Should result in foreground webapp processes

View File

@ -54,7 +54,7 @@ makeTest {
environment.systemPackages = [
pkgs.stdenv
pkgs.dysnomia
tools.build
tools.common
tools.systemd
];
};

View File

@ -100,7 +100,7 @@ makeTest {
environment.systemPackages = [
pkgs.stdenv
pkgs.dysnomia
tools.build
tools.common
tools.sysvinit
];
};
@ -162,8 +162,10 @@ makeTest {
start_all()
# Make sure the unprivileged user can deploy
machine.succeed('su - unprivileged -c "mkdir -p var/run var/tmp"')
# Make sure the unprivileged user can deploy (this implicitly creates all required state folders)
machine.succeed(
"su - unprivileged -c '${env} nixproc-sysvinit-switch --state-dir /home/unprivileged/var --force-disable-user-change --undeploy'"
)
# Test webapp in foreground mode as an unprivileged user
check_webapp_foreground("${webappUnprivilegedForegroundMode}")

View File

@ -82,7 +82,7 @@ makeTest {
environment.systemPackages = [
pkgs.stdenv
pkgs.dysnomia
tools.build
tools.common
tools.sysvinit
];
};
@ -125,8 +125,10 @@ makeTest {
start_all()
# Make sure the unprivileged user can deploy
machine.succeed('su - unprivileged -c "mkdir -p var/run var/tmp"')
# Make sure the unprivileged user can deploy (this implicitly creates all required state folders)
machine.succeed(
"su - unprivileged -c '${env} nixproc-sysvinit-switch --state-dir /home/unprivileged/var --force-disable-user-change --undeploy'"
)
# Test webapp deployed by an unprivileged user
check_webapp_daemon("${webappUnprivileged}")

View File

@ -17,18 +17,36 @@ Options:
-o, --old-profile=PATH
Path to the previously deployed Nix profile (by default,
it gets auto detected)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
-h, --help Shows the usage of this command
Environment:
NIX_STATE_DIR Overrides the location of the Nix state directory
BSDRC_TARGET_DIR Directory in which the BSD rc scripts reside (defaults to:
/usr/local/etc/rc.d)
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_CACHE_DIR Changes the directory in which cache 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:o:h -l profile:,old-profile:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,help -- "$@"`
if [ $? != 0 ]
then
@ -49,6 +67,24 @@ do
-o|--old-profile)
oldProfilePath="$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"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
-h|--help)
showUsage
exit 0
@ -75,6 +111,10 @@ BSDRC_TARGET_DIR=${BSDRC_TARGET_DIR:-/usr/local/etc/rc.d}
rcnew="$profilePath/etc/rc.d"
rcold="$oldProfilePath/etc/rc.d"
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Determine paths of old scripts
oldscripts=()

View File

@ -49,6 +49,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -67,6 +68,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -75,7 +77,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,enable-at-boot,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,enable-at-boot,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -133,6 +135,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -167,7 +172,7 @@ composeProfileBaseDir
deploy()
{
nixproc-bsdrc-deploy $profileArg $oldProfileArg $profilePath
nixproc-bsdrc-deploy $profileArg $oldProfileArg $profilePath $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChange
}
executeDeploymentOperation bsdrc

View File

@ -1,7 +1,7 @@
{stdenv, getopt}:
stdenv.mkDerivation {
name = "nixproc-build-tools";
name = "nixproc-common-tools";
buildCommand = ''
mkdir -p $out/bin
@ -18,5 +18,11 @@ stdenv.mkDerivation {
-e "s|@NIXPROC@|${../../nixproc}|" \
${./nixproc-build.in} > $out/bin/nixproc-build
chmod +x $out/bin/nixproc-build
sed -e "s|/bin/bash|$SHELL|" \
-e "s|@getopt@|${getopt}/bin/getopt|" \
-e 's|@DEFAULT_RUNTIME_DIR@|${if stdenv.isLinux || stdenv.isCygwin then "/run" else "/var/run"}|' \
${./nixproc-init-state.in} > $out/bin/nixproc-init-state
chmod +x $out/bin/nixproc-init-state
'';
}

View File

@ -20,6 +20,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -36,6 +37,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -44,7 +46,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o P:h -l undeploy,process-manager:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,no-out-link,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o P:h -l undeploy,process-manager:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,no-out-link,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -77,6 +79,9 @@ do
--tmp-dir)
tmpDir="--argstr tmpDir $2"
;;
--cache-dir)
cacheDir="--argstr cacheDir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--arg forceDisableUserChange true"
;;
@ -144,6 +149,11 @@ then
tmpDirArg="--argstr tmpDir $NIXPROC_TMP_DIR"
fi
if [ "$NIXPROC_CACHE_DIR" != "" ]
then
cacheDirArg="--argstr cacheDir $NIXPROC_CACHE_DIR"
fi
if [ "$NIXPROC_FORCE_DISABLE_USER_CHANGE" = "1" ]
then
forceDisableUserChangeArg="--arg forceDisableUserChange true"
@ -152,4 +162,4 @@ fi
NIXPROC=${NIXPROC:-@NIXPROC@}
# Build the profile
nix-build $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $noOutLinkArg $showTraceArg $processManagerArg "${extraParamsArg[@]}" $exprFileArg $NIXPROC/create-managed-process/$processManager/build-$processManager-env.nix
nix-build $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg $noOutLinkArg $showTraceArg $processManagerArg "${extraParamsArg[@]}" $exprFileArg $NIXPROC/create-managed-process/$processManager/build-$processManager-env.nix

View File

@ -0,0 +1,144 @@
#!/bin/bash -e
# Shows the usage of this command to the user
showUsage()
{
cat <<EOF
Usage: $0 [OPTION]
Initializes the common state directories so that processes can be managed
properly.
Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
-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_CACHE_DIR Changes the directory in which cache 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 h -l state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,help -- "$@"`
if [ $? != 0 ]
then
showUsage
exit 1
fi
# Evaluate valid options
eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--state-dir)
NIXPROC_STATE_DIR="$2"
;;
--runtime-dir)
NIXPROC_RUNTIME_DIR="$2"
;;
--log-dir)
NIXPROC_LOG_DIR="$2"
;;
--tmp-dir)
NIXPROC_TMP_DIR="$2"
;;
--cache-dir)
NIXPROC_CACHE_DIR="$2"
;;
--force-disable-user-change)
forceDisableUserChange=1
;;
-h|--help)
showUsage
exit 0
;;
esac
shift
done
shift
# Some default values
defaultStateDir="/var"
defaultRuntimeDir="@DEFAULT_RUNTIME_DIR@"
# Determine and create state directory
NIXPROC_STATE_DIR="${NIXPROC_STATE_DIR:-$defaultStateDir}"
mkdir -p "$NIXPROC_STATE_DIR"
# Determine and create temp directory
if [ "$NIXPROC_TMP_DIR" = "" ]
then
if [ "$NIXPROC_STATE_DIR" = "$defaultStateDir" ]
then
NIXPROC_TMP_DIR="/tmp"
else
NIXPROC_TMP_DIR="$NIXPROC_STATE_DIR/tmp"
fi
fi
if [ ! -d "$NIXPROC_TMP_DIR" ]
then
mkdir -p "$NIXPROC_TMP_DIR"
if [ "$forceDisableUserChange" != "1" ]
then
chmod 1777 "$NIXPROC_TMP_DIR"
fi
fi
if [ "$NIXPROC_TMP_DIR" = "/tmp" ] && [ ! -e "$NIXPROC_STATE_DIR/tmp" ]
then
ln -sfn /tmp "$NIXPROC_STATE_DIR/tmp" # When the temp directory is /tmp: also create a tmp symlink in the state folder, for compatibility
fi
# Determine and create runtime directory
if [ "$NIXPROC_RUNTIME_DIR" = "" ]
then
if [ "$NIXPROC_STATE_DIR" = "$defaultStateDir" ]
then
NIXPROC_RUNTIME_DIR="$defaultRuntimeDir"
else
NIXPROC_RUNTIME_DIR="$NIXPROC_STATE_DIR/run"
fi
fi
mkdir -p "$NIXPROC_RUNTIME_DIR"
if [ "$NIXPROC_RUNTIME_DIR" = "/run" ] && [ ! -e "$NIXPROC_STATE_DIR/run" ]
then
ln -sfn /run "$NIXPROC_STATE_DIR/run" # When the runtime directory is /run: also create a run symlink in the state folder, for compatibility
fi
# Determine and create log directory
NIXPROC_LOG_DIR="${NIXPROC_LOG_DIR:-$NIXPROC_STATE_DIR/log}"
mkdir -p "$NIXPROC_LOG_DIR"
# Determine and create cache directory
NIXPROC_CACHE_DIR="${NIXPROC_CACHE_DIR:-$NIXPROC_STATE_DIR/cache}"
mkdir -p "$NIXPROC_CACHE_DIR"

View File

@ -35,7 +35,7 @@ buildProfile()
local deployArg="$path"
fi
profilePath=$(nixproc-build --process-manager $processManager $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $showTraceArg "${extraParamsArg[@]}" --no-out-link $deployArg)
profilePath=$(nixproc-build --process-manager $processManager $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg $showTraceArg "${extraParamsArg[@]}" --no-out-link $deployArg)
}
composeProfileBaseDir()

View File

@ -15,16 +15,35 @@ Options:
-o, --old-profile=PATH
Path to the previously deployed Nix profile (by default,
it gets auto detected)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
-h, --help Shows the usage of this command
Environment:
NIX_STATE_DIR Overrides the location of the Nix state directory
NIX_STATE_DIR Overrides the location of the Nix state directory
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_CACHE_DIR Changes the directory in which cache 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:o:h -l profile:,old-profile:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,help -- "$@"`
if [ $? != 0 ]
then
@ -45,6 +64,24 @@ do
-o|--old-profile)
oldProfilePath="$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"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
-h|--help)
showUsage
exit 0
@ -66,6 +103,10 @@ checkNixStateDir
checkProfile
composeOldProfilePath
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Determine paths of old param files
oldparams=()

View File

@ -40,6 +40,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -56,6 +57,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -64,7 +66,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -110,6 +112,9 @@ do
--state-dir)
stateDirArg="--state-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--runtime-dir)
runtimeDirArg="--runtime-dir $2"
;;
@ -153,7 +158,7 @@ composeProfileBaseDir
deploy()
{
nixproc-cygrunsrv-deploy $profileArg $oldProfileArg $profilePath
nixproc-cygrunsrv-deploy $profileArg $oldProfileArg $profilePath $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChange
}
executeDeploymentOperation cygrunsrv

View File

@ -3,7 +3,7 @@
}:
rec {
build = import ./build {
common = import ./common {
inherit (pkgs) stdenv getopt;
};

View File

@ -39,6 +39,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -55,6 +56,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -63,7 +65,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -116,6 +118,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -152,6 +157,7 @@ export DISNIX_DATA_DIR="$(readlink -f "$(dirname $(readlink -f $(type -p disnix-
deploy()
{
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
disnix-deploy $oldProfileArg $profilePath
}

View File

@ -41,6 +41,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -59,6 +60,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -67,7 +69,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -122,6 +124,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
forceDisableUserChange=1

View File

@ -18,6 +18,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -31,6 +32,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -39,7 +41,7 @@ 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 -- "$@"`
PARAMS=`@getopt@ -n $0 -o P:h -l process-manager:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,no-out-link,show-trace,help -- "$@"`
if [ $? != 0 ]
then
@ -69,6 +71,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--arg forceDisableUserChange true"
;;
@ -108,4 +113,4 @@ 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
nix-build $NIXPROC/create-managed-process/agnostic/create-managed-process-from-config.nix --arg configFile $configFile --argstr processManager $processManager $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg $noOutLinkArg $showTraceArg

View File

@ -11,20 +11,27 @@ resources configuration.
Usage: $0 [OPTION] --id-resources id_resources_nix PATH
--id-resources=id_resources_nix
ID resources Nix expression defining numeric ID
resources
--ids=ids_nix IDs Nix expression mapping services to unique
IDs per resource
ID resources Nix expression defining numeric ID resources
--ids=ids_nix IDs Nix expression mapping services to unique IDs per
resource
--service-property=serviceProperty
Property in the processes model that specifies
which numeric ID resources a service needs
(Defaults to: requireUniqueIdsFor)
--output-file Specifies the file where to write the IDS to.
If no file was provided, it writes to the
standard output
--output-xml Specifies that the output should be in XML not the
Nix expression language
-h, --help Shows the usage of this command to the user
Property in the processes model that specifies
which numeric ID resources a service needs
(Defaults to: requireUniqueIdsFor)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
--output-file Specifies the file where to write the IDS to. If no file
was provided, it writes to the standard output
--output-xml Specifies that the output should be in XML not the Nix
expression language
-h, --help Shows the usage of this command to the user
Environment:
NIXPROC_STATE_DIR Changes the directory in which the state of the
@ -32,6 +39,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -40,7 +48,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o h -l id-resources:,ids:,service-property:,,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,output-file:,output-xml,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o h -l id-resources:,ids:,service-property:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,output-file:,output-xml,help -- "$@"`
if [ $? != 0 ]
then
@ -82,6 +90,9 @@ do
--tmp-dir)
NIXPROC_TMP_DIR="$2"
;;
--cache-dir)
NIXPROC_CACHE_DIR="$2"
;;
--force-disable-user-change)
NIXPROC_FORCE_DISABLE_USER_CHANGE=1
;;
@ -117,4 +128,4 @@ NIXPROC=${NIXPROC:-@NIXPROC@}
export PROCESSES_EXPR="$(@readlink@ -f "$processesFile")"
# Assign IDs
dydisnix-id-assign -s $NIXPROC/create-managed-process/disnix/services-adapter.nix --id-resources $idResourcesFile $idsParam $servicePropertyArg $outputFileArg $outputXmlArg $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg
dydisnix-id-assign -s $NIXPROC/create-managed-process/disnix/services-adapter.nix --id-resources $idResourcesFile $idsParam $servicePropertyArg $outputFileArg $outputXmlArg $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg

View File

@ -15,18 +15,36 @@ Options:
-o, --old-profile=PATH
Path to the previously deployed Nix profile (by default,
it gets auto detected)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
-h, --help Shows the usage of this command
Environment:
NIX_STATE_DIR Overrides the location of the Nix state directory
LAUNCHD_TARGET_DIR Directory in which the plist configuration files are
managed (defaults to: /Library/LaunchDaemons)
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_CACHE_DIR Changes the directory in which cache 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:o:h -l profile:,old-profile:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,help -- "$@"`
if [ $? != 0 ]
then
@ -47,6 +65,24 @@ do
-o|--old-profile)
oldProfilePath="$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"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
-h|--help)
showUsage
exit 0
@ -70,6 +106,10 @@ composeOldProfilePath
LAUNCHD_TARGET_DIR=${LAUNCHD_TARGET_DIR:-/Library/LaunchDaemons}
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Determine paths of old plists
oldplists=()

View File

@ -41,6 +41,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -59,6 +60,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -67,7 +69,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -122,6 +124,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -156,7 +161,7 @@ composeProfileBaseDir
deploy()
{
nixproc-launchd-deploy $profileArg $oldProfileArg $profilePath
nixproc-launchd-deploy $profileArg $oldProfileArg $profilePath $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChange
}
executeDeploymentOperation launchd

View File

@ -5,14 +5,6 @@ stdenv.mkDerivation {
buildCommand = ''
mkdir -p $out/bin
sed -e "s|/bin/bash|$SHELL|" \
-e "s|@getopt@|${getopt}/bin/getopt|" \
-e "s|@readlink@|$(type -p readlink)|" \
-e "s|@commonchecks@|${../commonchecks}|" \
-e "s|@supervisordchecks@|${./supervisordchecks}|" \
${./nixproc-supervisord-start.in} > $out/bin/nixproc-supervisord-start
chmod +x $out/bin/nixproc-supervisord-start
sed -e "s|/bin/bash|$SHELL|" \
-e "s|@getopt@|${getopt}/bin/getopt|" \
-e "s|@readlink@|$(type -p readlink)|" \

View File

@ -18,6 +18,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -33,6 +34,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -41,7 +43,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o h -l state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o h -l state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -68,6 +70,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -91,7 +96,10 @@ shift
path="$1"
# Build the environment with supervisord config files
profilePath=$(nixproc-build --process-manager supervisord $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $showTraceArg "${extraParamsArg[@]}" --no-out-link "$path")
profilePath=$(nixproc-build --process-manager supervisord $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg $showTraceArg "${extraParamsArg[@]}" --no-out-link "$path")
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Create groups and users
dysnomia-addgroups "$profilePath"

View File

@ -15,17 +15,35 @@ Options:
-o, --old-profile=PATH
Path to the previously deployed Nix profile (by default,
it gets auto detected)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
-h, --help Shows the usage of this command
Environment:
NIX_STATE_DIR Overrides the location of the Nix state directory
SUPERVISORD_CONF_DIR Directory if which the supervisord.conf resides
NIX_STATE_DIR Overrides the location of the Nix state directory
SUPERVISORD_CONF_DIR Directory if which the supervisord.conf resides
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_CACHE_DIR Changes the directory in which cache 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:o:h -l undeploy,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -46,6 +64,24 @@ do
-o|--old-profile)
oldProfilePath="$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"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
-h|--help)
showUsage
exit 0
@ -71,6 +107,10 @@ source @supervisordchecks@
checkSupervisordConfDir
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Determine paths of old units
oldunits=()

View File

@ -1,92 +0,0 @@
#!/bin/bash -e
showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
This command starts supervisord with an empty configuration that can be
populated with services by running \`nixproc-supervisord-switch'.
Options:
--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
-h, --help Shows the usage of this command
Environment:
SUPERVISORD_CONF_DIR Directory if which the supervisord.conf resides
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 h -l state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,help -- "$@"`
if [ $? != 0 ]
then
showUsage
exit 1
fi
# Evaluate valid options
eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--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"
;;
-h|--help)
showUsage
exit 0
;;
esac
shift
done
shift
path="$1"
# Validate the given options
source @supervisordchecks@
checkSupervisordConfDir
# Build the environment with supervisord config files
profilePath=$(nixproc-build --process-manager supervisord $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $showTraceArg --no-out-link "$path")
# Create the supervisord config directory and start supervisord in foreground mode
mkdir -p "$SUPERVISORD_CONF_DIR/conf.d"
cp "$profilePath/supervisord.conf" "$SUPERVISORD_CONF_DIR"
supervisord -n -c "$SUPERVISORD_CONF_DIR/supervisord.conf"

View File

@ -45,6 +45,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -62,6 +63,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -70,7 +72,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -125,6 +127,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -159,7 +164,7 @@ composeProfileBaseDir
deploy()
{
nixproc-supervisord-deploy $profileArg $oldProfileArg $profilePath
nixproc-supervisord-deploy $profileArg $oldProfileArg $profilePath $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChange
}
executeDeploymentOperation supervisord

View File

@ -15,6 +15,15 @@ Options:
-o, --old-profile=PATH
Path to the previously deployed Nix profile (by default,
it gets auto detected)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
--user Deploy the units as systemd user services
-h, --help Shows the usage of this command
@ -23,12 +32,21 @@ Environment:
SYSTEMD_TARGET_DIR Directory in which the unit configuration files are
managed (defaults to: /etc/systemd/system or
~/.config/systemd/user)
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_CACHE_DIR Changes the directory in which cache 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:o:h -l profile:,old-profile:,user,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,user,help -- "$@"`
if [ $? != 0 ]
then
@ -53,6 +71,24 @@ do
systemdUserServices=1
systemdUserArg="--user"
;;
--state-dir)
stateDirArg="--state-dir $2"
;;
--runtime-dir)
runtimeDirArg="--runtime-dir $2"
;;
--log-dir)
logDirArg="--log-dir $2"
;;
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
-h|--help)
showUsage
exit 0
@ -82,6 +118,10 @@ else
SYSTEMD_TARGET_DIR=${SYSTEMD_TARGET_DIR:-/etc/systemd/system}
fi
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Determine paths of old units
oldunits=()

View File

@ -41,6 +41,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -61,6 +62,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -69,7 +71,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,user,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,show-trace,extra-params:,user,help -- "$@"`
if [ $? != 0 ]
then
@ -124,6 +126,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -161,7 +166,7 @@ composeProfileBaseDir
deploy()
{
nixproc-systemd-deploy $systemdUserArg $profileArg $oldProfileArg $profilePath
nixproc-systemd-deploy $systemdUserArg $profileArg $oldProfileArg $profilePath $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChange
}
executeDeploymentOperation systemd

View File

@ -15,18 +15,36 @@ Options:
-o, --old-profile=PATH
Path to the previously deployed Nix profile (by default,
it gets auto detected)
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
--runlevel=LEVEL Specifies which runlevel to activate (defaults to the
runlevel of the system)
-h, --help Shows the usage of this command
Environment:
NIX_STATE_DIR Overrides the location of the Nix state directory
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_CACHE_DIR Changes the directory in which cache 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:o:h -l profile:,old-profile:,runlevel:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,runlevel:,help -- "$@"`
if [ $? != 0 ]
then
@ -47,6 +65,24 @@ do
-o|--old-profile)
oldProfilePath="$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"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
--runlevel)
runlevel="$2"
;;
@ -75,15 +111,19 @@ source @sysvinitchecks@
checkRunlevel
rcnew="$profilePath/etc/rc.d/rc${runlevel}.d"
rcold="$oldProfilePath/etc/rc.d/rc${runlevel}.d"
if [ "$profilePath" = "" ]
then
echo "No profile path was provided!" >&2
exit 1
fi
rcnew="$profilePath/etc/rc.d/rc${runlevel}.d"
rcold="$oldProfilePath/etc/rc.d/rc${runlevel}.d"
# Initialize all state
nixproc-init-state $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChangeArg
# Determine paths of old scripts
oldscripts=()

View File

@ -82,9 +82,14 @@ source @sysvinitchecks@
checkRunlevel
# Execute the activities
if [ "$2" = "" ]
then
rcpath="$oldProfilePath/etc/rc.d/rc${runlevel}.d"
else
rcpath="$2"
fi
rcpath="$oldProfilePath/etc/rc.d/rc${runlevel}.d"
# Execute the activities
if [ "$reverse" = "1" ]
then

View File

@ -49,6 +49,7 @@ Options:
--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
--cache-dir Changes the directory in which cache files are stored
--force-disable-user-change
Forces to not create users, groups or change user
permissions
@ -65,6 +66,7 @@ Environment:
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_CACHE_DIR Changes the directory in which cache files are stored
NIXPROC_FORCE_DISABLE_USER_CHANGE
Forces to not create users, groups or change user
permissions
@ -73,7 +75,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,runlevel:,show-trace,extra-params:,help -- "$@"`
PARAMS=`@getopt@ -n $0 -o p:o:h -l undeploy,rollback,switch-generation:,list-generations,delete-generations:,delete-all-generations,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,cache-dir:,force-disable-user-change,runlevel:,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -126,6 +128,9 @@ do
--tmp-dir)
tmpDirArg="--tmp-dir $2"
;;
--cache-dir)
cacheDirArg="--cache-dir $2"
;;
--force-disable-user-change)
forceDisableUserChangeArg="--force-disable-user-change"
;;
@ -164,7 +169,7 @@ composeProfileBaseDir
deploy()
{
nixproc-sysvinit-deploy $runlevelArg $profileArg $oldProfileArg $profilePath
nixproc-sysvinit-deploy $runlevelArg $profileArg $oldProfileArg $profilePath $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $cacheDirArg $forceDisableUserChange
}
executeDeploymentOperation sysvinit

View File

@ -4,7 +4,7 @@ checkRunlevel()
{
if [ "$runlevel" = "" ]
then
if command -v runlevel
if command -v runlevel 2> /dev/null
then
runlevel=$(runlevel | cut -d ' ' -f2)