Tools: setup-unit: restart: added -l and -s flags.
Add flags for cleaning the log file and state dir. Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
This commit is contained in:
@@ -84,7 +84,7 @@ SYNOPSIS
|
|||||||
├── os-probe [-h]
|
├── os-probe [-h]
|
||||||
├── ps [-h] [-t TYPE]
|
├── ps [-h] [-t TYPE]
|
||||||
├── repo-config [-hn] [PKG-MANAGER OS-NAME OS-VERSION]
|
├── repo-config [-hn] [PKG-MANAGER OS-NAME OS-VERSION]
|
||||||
├── restart [-h]
|
├── restart [-hls]
|
||||||
├── sock [-h] SUBCOMMAND [ARGS]
|
├── sock [-h] SUBCOMMAND [ARGS]
|
||||||
│ ├── filter [-chs]
|
│ ├── filter [-chs]
|
||||||
│ └── find [-h]
|
│ └── find [-h]
|
||||||
@@ -1224,7 +1224,7 @@ help_unit_restart()
|
|||||||
{
|
{
|
||||||
cat <<__EOF__ ;
|
cat <<__EOF__ ;
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
$0 restart [-h]
|
$0 restart [-hls]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Restart all running unitd(8) instances.
|
Restart all running unitd(8) instances.
|
||||||
@@ -1233,6 +1233,17 @@ OPTIONS
|
|||||||
-h, --help
|
-h, --help
|
||||||
Print this help.
|
Print this help.
|
||||||
|
|
||||||
|
-l, --log
|
||||||
|
Reset log file.
|
||||||
|
|
||||||
|
-s, --statedir
|
||||||
|
Reset \$statedir.
|
||||||
|
|
||||||
|
CAVEATS
|
||||||
|
This command will ask for confirmation before removing
|
||||||
|
directories; please review those prompts with care, as unknown
|
||||||
|
bugs in the command may attempt to wipe your file system.
|
||||||
|
|
||||||
__EOF__
|
__EOF__
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1245,6 +1256,12 @@ unit_restart()
|
|||||||
help_unit_restart;
|
help_unit_restart;
|
||||||
exit 0;
|
exit 0;
|
||||||
;;
|
;;
|
||||||
|
-l | --log)
|
||||||
|
local log_flag='yes';
|
||||||
|
;;
|
||||||
|
-s | --statedir)
|
||||||
|
local state_flag='yes';
|
||||||
|
;;
|
||||||
-*)
|
-*)
|
||||||
err "restart: $1: Unknown option.";
|
err "restart: $1: Unknown option.";
|
||||||
;;
|
;;
|
||||||
@@ -1261,6 +1278,33 @@ unit_restart()
|
|||||||
|
|
||||||
printf '%s\n' "$cmds" \
|
printf '%s\n' "$cmds" \
|
||||||
| while read -r cmd; do
|
| while read -r cmd; do
|
||||||
|
if test -v log_flag; then
|
||||||
|
(
|
||||||
|
echo "$cmd" \
|
||||||
|
| grep '\--log' \
|
||||||
|
| sed 's/.*--log \+\([^ ]\+\).*/\1/' \
|
||||||
|
|| eval $cmd --help \
|
||||||
|
| grep -A1 '\--log FILE' \
|
||||||
|
| grep 'default:' \
|
||||||
|
| sed 's/.*"\(.*\)".*/\1/';
|
||||||
|
) \
|
||||||
|
| xargs rm -f;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if test -v state_flag; then
|
||||||
|
(
|
||||||
|
echo "$cmd" \
|
||||||
|
| grep '\--statedir' \
|
||||||
|
| sed 's/.*--statedir \+\([^ ]\+\).*/\1/' \
|
||||||
|
|| eval $cmd --help \
|
||||||
|
| grep -A1 '\--statedir DIR' \
|
||||||
|
| grep 'default:' \
|
||||||
|
| sed 's/.*"\(.*\)".*/\1/';
|
||||||
|
) \
|
||||||
|
| xargs -I {} find {} -mindepth 1 -maxdepth 1 \
|
||||||
|
| xargs rm -rfi;
|
||||||
|
fi;
|
||||||
|
|
||||||
eval $cmd;
|
eval $cmd;
|
||||||
done;
|
done;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user