From 76c5a2326f9806231d5ce12634aa32c0fb2fbefc Mon Sep 17 00:00:00 2001 From: pvincent Date: Mon, 9 Feb 2026 11:03:32 +0400 Subject: [PATCH] start stop reboot --- bin/pct-reboot | 43 +++++++++++++++++++++++++++++++++++++++++++ bin/pct-start | 42 ++++++++++++++++++++++++++++++++++++++++++ bin/pct-stop | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100755 bin/pct-reboot create mode 100755 bin/pct-start create mode 100755 bin/pct-stop 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