summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/container/remove21
-rwxr-xr-xlib/container/restart15
-rwxr-xr-xlib/container/start17
-rwxr-xr-xlib/container/stop20
-rw-r--r--share/man/container-remove.1.txt5
-rw-r--r--share/man/container-restart.1.txt5
-rw-r--r--share/man/container-start.1.txt5
-rw-r--r--share/man/container-stop.1.txt5
8 files changed, 89 insertions, 4 deletions
diff --git a/lib/container/remove b/lib/container/remove
index 427bf4a..275c867 100755
--- a/lib/container/remove
+++ b/lib/container/remove
@@ -28,6 +28,8 @@ MACHINES="/var/lib/machines"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,allow-stop,force,verbose,"
GETOPT_OPTIONS="n:,f,v,"
@@ -52,16 +54,22 @@ Parameters ()
--allow-stop)
ALLOW_STOP="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --allow-stop"
;;
-f|--force)
FORCE="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
-v|--verbose)
VERBOSE="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --verbose"
;;
--)
@@ -111,6 +119,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --stopped)"
+
+ for NAME in ${NAMES}
+ do
+ container remove --name ${NAME} ${OPTIONS_ALL} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ] && [ ! -e "${CONFIG}/${NAME}.conf" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/lib/container/restart b/lib/container/restart
index a507cc0..a22b970 100755
--- a/lib/container/restart
+++ b/lib/container/restart
@@ -27,6 +27,8 @@ MACHINES="/var/lib/machines"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,"
GETOPT_OPTIONS="n:,"
@@ -74,6 +76,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --started)"
+
+ for NAME in ${NAMES}
+ do
+ container restart --name ${NAME} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/lib/container/start b/lib/container/start
index e4b2ee6..62fb926 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -31,6 +31,8 @@ SYSTEMCTL="true"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,force,nspawn,start,"
GETOPT_OPTIONS="n:f,"
@@ -55,6 +57,8 @@ Parameters ()
-f|--force)
FORCE="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
--nspawn)
@@ -96,6 +100,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --stopped)"
+
+ for NAME in ${NAMES}
+ do
+ container start --name ${NAME} ${OPTIONS_ALL} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/lib/container/stop b/lib/container/stop
index 5099005..d996282 100755
--- a/lib/container/stop
+++ b/lib/container/stop
@@ -30,6 +30,8 @@ CLEAN="false"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,force,clean,"
GETOPT_OPTIONS="n:,f,"
@@ -53,12 +55,17 @@ Parameters ()
-f|--force)
FORCE="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
--clean)
# internal option
CLEAN="true"
shift 1
+
+ OPTONS_ALL="${OPTIONS_ALL} --clean"
;;
--)
@@ -108,6 +115,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --started)"
+
+ for NAME in ${NAMES}
+ do
+ container stop --name ${NAME} ${OPTIONS_ALL} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/share/man/container-remove.1.txt b/share/man/container-remove.1.txt
index afc078c..94d167b 100644
--- a/share/man/container-remove.1.txt
+++ b/share/man/container-remove.1.txt
@@ -46,7 +46,7 @@ OPTIONS
The following container options are available:
*-n, --name='NAME'*::
- Specify container name.
+ Specify container name. Specifying 'ALL' will remove all stopped container.
*--allow-stop*::
Stop container prior removal.
@@ -69,6 +69,9 @@ EXAMPLES
*Remove a running container from the system, without prompt:*::
sudo container remove -n example.net -f --allow-stop
+*Remove all container:*::
+ sudo container remove -n ALL
+
SEE ALSO
--------
diff --git a/share/man/container-restart.1.txt b/share/man/container-restart.1.txt
index a22d9a6..99b461d 100644
--- a/share/man/container-restart.1.txt
+++ b/share/man/container-restart.1.txt
@@ -44,7 +44,7 @@ OPTIONS
The following container options are available:
*-n, --name='NAME'*::
- Specify container name.
+ Specify container name. Specifying 'ALL' will restart all started container.
EXAMPLES
@@ -52,6 +52,9 @@ EXAMPLES
*Restart example.net container:*::
sudo container restart -n example.net
+*Restart all container:*::
+ sudo container restart -n ALL
+
SEE ALSO
--------
diff --git a/share/man/container-start.1.txt b/share/man/container-start.1.txt
index 2ffb4a0..ae4ff89 100644
--- a/share/man/container-start.1.txt
+++ b/share/man/container-start.1.txt
@@ -44,7 +44,7 @@ OPTIONS
The following container options are available:
*-n, --name='NAME'*::
- Specify container name.
+ Specify container name. Specifying 'ALL' will start all stopped container.
*-f, --force'*::
Removing stray lock file if existing.
@@ -55,6 +55,9 @@ EXAMPLES
*Start example.net container:*::
sudo container start -n example.net
+*Start all container:*::
+ sudo container start -n ALL
+
SEE ALSO
--------
diff --git a/share/man/container-stop.1.txt b/share/man/container-stop.1.txt
index 5f1d221..ec169d8 100644
--- a/share/man/container-stop.1.txt
+++ b/share/man/container-stop.1.txt
@@ -44,7 +44,7 @@ OPTIONS
The following container options are available:
*-n, --name='NAME'*::
- Specify container name.
+ Specify container name. Specifying 'ALL' will stop all started container.
*-f, --force*::
Instead of running the proper shutdown sequence, terminate all processes of the container imediatly.
@@ -58,6 +58,9 @@ EXAMPLES
*Immediately stop example.net container:*::
sudo container stop -n example.net -f
+*Stop all container:*::
+ sudo container stop -n ALL
+
SEE ALSO
--------