Implement --undeploy option for all tools, make Docker tests a bit more robust

This commit is contained in:
Sander van der Burg 2020-08-17 21:08:25 +02:00 committed by Sander van der Burg
parent 459a8cb228
commit dad1f2f7ca
29 changed files with 151 additions and 87 deletions

View File

@ -455,6 +455,16 @@ unprivileged user:
$ nixproc-sysvinit-switch --state-dir /home/sander/var --force-disable-user-change processes.nix
```
Undeploying the system
----------------------
It may also be desired to completely undeploy a system when it is no longer
needed. The following command completely undeploys all previously deployed
processes:
```bash
$ nixproc-sysvinit-switch --undeploy
```
Integration with Disnix
-----------------------
In addition to the fact that this toolset provides a `disnix` backend that

View File

@ -1,13 +0,0 @@
{ pkgs ? import <nixpkgs> { inherit system; }
, system ? builtins.currentSystem
, stateDir ? "/var"
, runtimeDir ? "${stateDir}/run"
, logDir ? "${stateDir}/log"
, cacheDir ? "${stateDir}/cache"
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, processManager
}:
{
}

View File

@ -1,11 +0,0 @@
{ pkgs ? import <nixpkgs> { inherit system; }
, system ? builtins.currentSystem
, stateDir ? "/var"
, runtimeDir ? "${stateDir}/run"
, logDir ? "${stateDir}/log"
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
}:
{
}

View File

@ -5,7 +5,7 @@
, logDir ? "${stateDir}/log"
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, exprFile
, exprFile ? null
, extraParams ? {}
}@args:
@ -18,7 +18,7 @@ let
processManager = "bsdrc";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "rc.d";

View File

@ -6,7 +6,7 @@
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -18,7 +18,7 @@ let
processManager = "cygrunsrv";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "cygrunsrv-env";

View File

@ -8,7 +8,7 @@
, clientInterface ? (if builtins.getEnv "DISNIX_CLIENT_INTERFACE" == "" then "disnix-run-activity" else builtins.getEnv "DISNIX_CLIENT_INTERFACE")
, disnixDataDir ? (if builtins.getEnv "DISNIX_DATA_DIR" == "" then throw "Set DISNIX_DATA_DIR to the data directory of Disnix" else builtins.getEnv "DISNIX_DATA_DIR")
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -20,7 +20,7 @@ let
processManager = "disnix";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
localhostTarget = {
properties.hostname = "localhost";

View File

@ -6,7 +6,7 @@
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -18,7 +18,7 @@ let
processManager = "docker";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "docker";

View File

@ -6,7 +6,7 @@
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -18,7 +18,7 @@ let
processManager = "launchd";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "launchd";

View File

@ -6,7 +6,7 @@
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -18,7 +18,7 @@ let
processManager = "supervisord";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "supervisord.d";

View File

@ -6,7 +6,7 @@
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -18,7 +18,7 @@ let
processManager = "systemd";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "systemd";

View File

@ -6,7 +6,7 @@
, tmpDir ? (if stateDir == "/var" then "/tmp" else "${stateDir}/tmp")
, forceDisableUserChange ? false
, extraParams ? {}
, exprFile
, exprFile ? null
}@args:
let
@ -18,7 +18,7 @@ let
processManager = "sysvinit";
} // extraParams);
processes = processesFun processesArgs;
processes = if exprFile == null then {} else processesFun processesArgs;
in
pkgs.buildEnv {
name = "rc.d";

View File

@ -39,7 +39,7 @@ let
processesEnvEmpty = import ../nixproc/create-managed-process/disnix/build-disnix-env.nix {
inherit disnixDataDir;
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
};
tools = import ../tools {};
@ -165,7 +165,7 @@ makeTest {
# Undeploy the system
machine.succeed(
"${env} nixproc-disnix-switch ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix"
"${env} nixproc-disnix-switch --undeploy"
)
check_system_unavailable()

View File

@ -35,13 +35,15 @@ let
};
processesEnvEmpty = import ../nixproc/create-managed-process/docker/build-docker-env.nix {
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
};
tools = import ../tools {};
nix-processmgmt = ./..;
procps = (import nixpkgs {}).procps;
env = "NIX_PATH=nixpkgs=${nixpkgs} SYSTEMD_TARGET_DIR=/etc/systemd-mutable/system";
in
makeTest {
@ -80,7 +82,9 @@ makeTest {
def check_system_unavailable():
machine.fail("curl --fail http://localhost:8080")
machine.fail("pgrep -f '/bin/webapp'")
machine.fail(
"docker exec nixproc-webapp ${procps}/bin/pgrep -f '/bin/webapp'"
)
def check_nginx_multi_instance_redirection():
@ -116,7 +120,10 @@ makeTest {
)
machine.succeed("sleep 10")
machine.succeed("pgrep -u webapp -f '/bin/webapp$'")
machine.succeed(
"docker exec nixproc-webapp ${procps}/bin/pgrep -u webapp -f '/bin/webapp$'"
)
check_nginx_redirection()
# Deploy the system with daemon webapp processes
@ -126,7 +133,9 @@ makeTest {
)
machine.succeed("sleep 10")
machine.succeed("pgrep -u webapp -f '/bin/webapp -D$'")
machine.succeed(
"docker exec nixproc-webapp ${procps}/bin/pgrep -u webapp -f '/bin/webapp -D$'"
)
check_nginx_redirection()
@ -137,7 +146,9 @@ makeTest {
)
machine.succeed("sleep 10")
machine.succeed("pgrep -u webapp -f '/bin/webapp$'")
machine.succeed(
"docker exec nixproc-webapp ${procps}/bin/pgrep -u webapp -f '/bin/webapp$'"
)
check_nginx_redirection()
@ -159,14 +170,16 @@ makeTest {
)
machine.succeed("sleep 10")
machine.succeed("pgrep -u root -f '/bin/webapp$'")
machine.succeed(
"docker exec nixproc-webapp ${procps}/bin/pgrep -u root -f '/bin/webapp$'"
)
check_nginx_redirection()
# Undeploy the system
machine.succeed(
"${env} nixproc-docker-switch ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix"
"${env} nixproc-docker-switch --undeploy"
)
check_system_unavailable()

View File

@ -35,7 +35,7 @@ let
};
processesEnvEmpty = import ../nixproc/create-managed-process/supervisord/build-supervisord-env.nix {
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
};
tools = import ../tools {};
@ -167,7 +167,7 @@ makeTest {
# Undeploy the system
machine.succeed(
"${env} nixproc-supervisord-switch ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix"
"${env} nixproc-supervisord-switch --undeploy"
)
check_system_unavailable()

View File

@ -10,7 +10,7 @@ let
};
processesEnvEmpty = import ../nixproc/create-managed-process/systemd/build-systemd-env.nix {
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
stateDir = "/home/unprivileged/var";
forceDisableUserChange = true;
};
@ -119,7 +119,7 @@ makeTest {
# Undeploy the system
machine.succeed(
'su - unprivileged -c "${env} nixproc-systemd-switch --user --state-dir /home/unprivileged/var --force-disable-user-change ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix"'
'su - unprivileged -c "${env} nixproc-systemd-switch --user --state-dir /home/unprivileged/var --force-disable-user-change --undeploy"'
)
check_system_unavailable()

View File

@ -26,7 +26,7 @@ let
};
processesEnvEmpty = import ../nixproc/create-managed-process/systemd/build-systemd-env.nix {
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
};
tools = import ../tools {};
@ -141,7 +141,7 @@ makeTest {
# Undeploy the system
machine.succeed(
"${env} nixproc-systemd-switch ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix"
"${env} nixproc-systemd-switch --undeploy"
)
check_system_unavailable()

View File

@ -45,11 +45,11 @@ let
};
processesEnvEmpty = import ../nixproc/create-managed-process/sysvinit/build-sysvinit-env.nix {
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
};
processesEnvEmptyUnprivileged = import ../nixproc/create-managed-process/sysvinit/build-sysvinit-env.nix {
exprFile = ../examples/webapps-agnostic/processes-empty.nix;
exprFile = null;
stateDir = "/home/unprivileged/var";
forceDisableUserChange = true;
};
@ -190,7 +190,7 @@ makeTest {
# Undeploy the entire system as an unprivileged user
machine.succeed(
"su - unprivileged -c '${env} nixproc-sysvinit-switch --state-dir /home/unprivileged/var --force-disable-user-change ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix'"
"su - unprivileged -c '${env} nixproc-sysvinit-switch --state-dir /home/unprivileged/var --force-disable-user-change --undeploy'"
)
check_system_unavailable()
@ -211,7 +211,7 @@ makeTest {
# Undeploy the entire system
machine.succeed(
"${env} nixproc-sysvinit-switch ${nix-processmgmt}/examples/webapps-agnostic/processes-empty.nix"
"${env} nixproc-sysvinit-switch --undeploy"
)
check_system_unavailable()

View File

@ -29,11 +29,11 @@ let
};
processesEnvEmpty = import ../nixproc/create-managed-process/sysvinit/build-sysvinit-env.nix {
exprFile = ../examples/webapps-sysvinit/processes-empty.nix;
exprFile = null;
};
processesEnvEmptyUnprivileged = import ../nixproc/create-managed-process/sysvinit/build-sysvinit-env.nix {
exprFile = ../examples/webapps-sysvinit/processes-empty.nix;
exprFile = null;
forceDisableUserChange = true;
stateDir = "/home/unprivileged/var";
};
@ -147,7 +147,7 @@ makeTest {
# Undeploy the entire system as an unprivileged user
machine.succeed(
"su - unprivileged -c '${env} nixproc-sysvinit-switch --state-dir /home/unprivileged/var --force-disable-user-change ${nix-processmgmt}/examples/webapps-sysvinit/processes-empty.nix'"
"su - unprivileged -c '${env} nixproc-sysvinit-switch --state-dir /home/unprivileged/var --force-disable-user-change --undeploy'"
)
check_system_unavailable()
@ -168,7 +168,7 @@ makeTest {
# Undeploy the entire system
machine.succeed(
"${env} nixproc-sysvinit-switch ${nix-processmgmt}/examples/webapps-sysvinit/processes-empty.nix"
"${env} nixproc-sysvinit-switch --undeploy"
)
check_system_unavailable()

View File

@ -8,6 +8,7 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command starts all BSD rc scripts in the provided Nix profile and
optionally deactivates all obsolete sysvinit scripts in the previous Nix
@ -18,6 +19,7 @@ produces a Nix profile. If the provided path is a directory, then it is
considered a pre-built Nix profile.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the BSD rc scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -56,7 +58,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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,profile:,old-profile:,enable-at-boot,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -71,6 +73,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -6,11 +6,13 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command builds a Nix profile containing multiple sysvinit scripts, and
their start and stop symlinks.
Options:
--undeploy Generates a configuration to undeploy all processes
-P, --process-manager=MANAGER
Process manager to build for
--state-dir Changes the directory in which the state of the processes
@ -42,7 +44,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,extra-params:,help -- "$@"`
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 -- "$@"`
if [ $? != 0 ]
then
@ -57,6 +59,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-P|--process-manager)
processManager="$2"
;;
@ -95,6 +100,8 @@ done
shift
# Validate the given options
if [ "$processManager" = "" ]
then
echo "No process manager specified!" >&2
@ -105,14 +112,18 @@ fi
if [ "$1" = "" ]
then
echo "No processes expression provided!" >&2
exit 1
if [ "$undeploy" = "1" ]
then
exprFileArg="--arg exprFile null"
else
echo "No processes expression provided!" >&2
exit 1
fi
else
exprFile=$(@readlink@ -f "$1")
exprFile="$(@readlink@ -f "$1")"
exprFileArg="--argstr exprFile $exprFile"
fi
# Validate the given options
if [ "$NIXPROC_STATE_DIR" != "" ]
then
stateDirArg="--argstr stateDir $NIXPROC_STATE_DIR"
@ -141,4 +152,4 @@ fi
NIXPROC=${NIXPROC:-@NIXPROC@}
# Build the profile
nix-build $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $noOutLinkArg $showTraceArg $processManagerArg "${extraParamsArg[@]}" --argstr exprFile "$exprFile" $NIXPROC/create-managed-process/$processManager/build-$processManager-env.nix
nix-build $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $noOutLinkArg $showTraceArg $processManagerArg "${extraParamsArg[@]}" $exprFileArg $NIXPROC/create-managed-process/$processManager/build-$processManager-env.nix

View File

@ -27,7 +27,15 @@ checkProfile()
buildProfile()
{
local processManager="$1"
profilePath=$(nixproc-build --process-manager $processManager $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $showTraceArg "${extraParamsArg[@]}" --no-out-link "$path")
if [ "$undeploy" = "1" ]
then
local deployArg="--undeploy"
else
local deployArg="$path"
fi
profilePath=$(nixproc-build --process-manager $processManager $stateDirArg $runtimeDirArg $logDirArg $tmpDirArg $forceDisableUserChangeArg $showTraceArg "${extraParamsArg[@]}" --no-out-link $deployArg)
}
composeProfileDir()

View File

@ -6,11 +6,13 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command updates the Windows services configuration so that obsolete
services will be stoppped and new services will be started.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -45,7 +47,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -60,6 +62,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -4,12 +4,14 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command uses Disnix's deployment facilities to deploy a set of running
processes taking the process dependencies into account for activating and
deactivating them in the right order.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -44,7 +46,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -59,6 +61,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -6,12 +6,14 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command repopulates a folder with systemd configuration files and updates
the configuration so that obsolete services will be stoppped and new services
will be started.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -48,7 +50,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -63,6 +65,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -6,12 +6,14 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command repopulates a folder with launchd plist files and updates the
configuration so that obsolete services will be stoppped and new services will
be started.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -48,7 +50,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -63,6 +65,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -6,6 +6,7 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command repopulates the conf.d sub directory of a supervisord configuration
and updates the live configuration so that obsolete services will be stopped and
@ -16,6 +17,7 @@ produces a Nix profile. If the provided path is a directory, then it is
considered a pre-built Nix profile.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -51,7 +53,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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:,force-disable-user-change,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -66,6 +68,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -6,12 +6,14 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command repopulates a folder with systemd configuration files and updates
the configuration so that obsolete services will be stoppped and new services
will be started.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -50,7 +52,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,show-trace,extra-params:,user,help -- "$@"`
if [ $? != 0 ]
then
@ -65,6 +67,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;

View File

@ -88,13 +88,19 @@ rcpath="$oldProfilePath/etc/rc.d/rc${runlevel}.d"
if [ "$reverse" = "1" ]
then
for i in $(ls $rcpath/S* | sort -r)
do
$i $activity
done
if [ -n "$(ls -A $rcpath 2> /dev/null)" ]
then
for i in $(ls $rcpath/S* | sort -r)
do
$i $activity
done
fi
else
for i in $(ls $rcpath/S*)
do
$i $activity
done
if [ -n "$(ls -A $rcpath 2> /dev/null)" ]
then
for i in $(ls $rcpath/S*)
do
$i $activity
done
fi
fi

View File

@ -8,6 +8,7 @@ showUsage()
{
cat <<EOF
Usage: $0 [OPTION] PATH
or: $0 --undeploy [OPTION]
This command starts all sysvinit scripts in the provided Nix profile and
optionally deactivates all obsolete sysvinit scripts in the previous Nix
@ -18,6 +19,7 @@ produces a Nix profile. If the provided path is a directory, then it is
considered a pre-built Nix profile.
Options:
--undeploy Undeploys all previously deployed processes
-p, --profile=NAME Name of the Nix profile that stores the sysvinit scripts
(defaults to: processes)
-o, --old-profile=PATH
@ -54,7 +56,7 @@ EOF
# Parse valid argument options
PARAMS=`@getopt@ -n $0 -o p:o:h -l 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,profile:,old-profile:,state-dir:,runtime-dir:,log-dir:,tmp-dir:,force-disable-user-change,runlevel:,show-trace,extra-params:,help -- "$@"`
if [ $? != 0 ]
then
@ -69,6 +71,9 @@ eval set -- "$PARAMS"
while [ "$1" != "--" ]
do
case "$1" in
--undeploy)
undeploy=1
;;
-p|--profile)
profile="$2"
;;