diff --git a/bin/pct-reboot b/bin/pct-reboot new file mode 100755 index 0000000..24a6869 --- /dev/null +++ b/bin/pct-reboot @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# CONSTANTS + +BASEDIR=$(dirname "$0") +NAME= + +# FUNCTIONS + +function usage { + echo "usage: $(basename "$0") { name }" +} + +function parse_options { + while [[ $# -gt 0 ]]; do + case "$1" in + --help | -h) + usage && exit 0 + ;; + *) + if [[ -z $NAME ]]; then + NAME=$1 + else + echo >&2 "Unknown option: $1" && usage && exit 2 + fi + ;; + esac + + shift 1 # Move to the next argument + done +} + +function reboot { + vmid=$(pct-lookup $NAME) + pct stop $vmid + pct start $vmid +} + +# MAIN + +set -Eue +parse_options $* +reboot diff --git a/bin/pct-start b/bin/pct-start new file mode 100755 index 0000000..351c34b --- /dev/null +++ b/bin/pct-start @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# CONSTANTS + +BASEDIR=$(dirname "$0") +NAME= + +# FUNCTIONS + +function usage { + echo "usage: $(basename "$0") { name }" +} + +function parse_options { + while [[ $# -gt 0 ]]; do + case "$1" in + --help | -h) + usage && exit 0 + ;; + *) + if [[ -z $NAME ]]; then + NAME=$1 + else + echo >&2 "Unknown option: $1" && usage && exit 2 + fi + ;; + esac + + shift 1 # Move to the next argument + done +} + +function start { + vmid=$(pct-lookup $NAME) + pct start $vmid +} + +# MAIN + +set -Eue +parse_options $* +start diff --git a/bin/pct-stop b/bin/pct-stop new file mode 100755 index 0000000..ea360c0 --- /dev/null +++ b/bin/pct-stop @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# CONSTANTS + +BASEDIR=$(dirname "$0") +NAME= + +# FUNCTIONS + +function usage { + echo "usage: $(basename "$0") { name }" +} + +function parse_options { + while [[ $# -gt 0 ]]; do + case "$1" in + --help | -h) + usage && exit 0 + ;; + *) + if [[ -z $NAME ]]; then + NAME=$1 + else + echo >&2 "Unknown option: $1" && usage && exit 2 + fi + ;; + esac + + shift 1 # Move to the next argument + done +} + +function stop { + vmid=$(pct-lookup $NAME) + pct stop $vmid +} + +# MAIN + +set -Eue +parse_options $* +stop