chroot-manager: fixing machinectl not killing/stopping machines properly

This commit is contained in:
itdominator 2024-07-06 21:11:09 -05:00
parent ca0980c416
commit f4bb73c858
1 changed files with 11 additions and 29 deletions

View File

@ -22,7 +22,7 @@ X_PORT=10
function _prompt_chroot_env() {
target=`\ls -1 -d ./*/ | fzf --prompt "${1}"`
target=$(\ls -1 -d ./*/ | fzf --prompt "${1}")
target=`sed 's|\.\/||g' <<< ${target}`
chroot_env="${CHROOT_FOLDERS_PATH}/${target}"
echo "${chroot_env}"
@ -481,39 +481,21 @@ function load_chroot_sysd() {
function poweroff_chroot_sysd() {
cd "${CHROOT_FOLDERS_PATH}"
chroot_env=$(_get_chroot_env " " "Poweroff SysD Chroot Venv:")
parentdir="$(dirname "${chroot_env}")"
target=$(basename "${chroot_env}")
target=`echo "${target}" | sed "s|/||g"`
if [[ -d "${chroot_env}" && "${parentdir}" == "${CHROOT_FOLDERS_PATH}" ]]; then
target=$(sudo machinectl list | awk '{print $1}' | head -n -2 | tail -n +2 | fzf --prompt "Stop:")
clear
echo "Stopping: ${target}"
sudo machinectl poweroff "${target}"
clear
echo -e "Powered off Chroot Env: ${target}\nPath: ${chroot_env}"
else
echo -e "Path: ${chroot_env}\nis not a child path of\nParent: ${CHROOT_FOLDERS_PATH}"
fi
echo -e "Powered off Chroot Env: ${target}"
}
function kill_chroot_sysd() {
cd "${CHROOT_FOLDERS_PATH}"
chroot_env=$(_get_chroot_env " " "Kill SysD Chroot Venv:")
parentdir="$(dirname "${chroot_env}")"
target=$(basename "${chroot_env}")
target=`echo "${target}" | sed "s|/||g"`
if [[ -d "${chroot_env}" && "${parentdir}" == "${CHROOT_FOLDERS_PATH}" ]]; then
target=$(sudo machinectl list | awk '{print $1}' | head -n -2 | tail -n +2 | fzf --prompt "Kill:")
clear
echo "Killing: ${target}"
sudo machinectl kill "${target}"
clear
echo -e "Killed Chroot Env: ${target}\nPath: ${chroot_env}"
else
echo -e "Path: ${chroot_env}\nis not a child path of\nParent: ${CHROOT_FOLDERS_PATH}"
fi
echo -e "Killed Chroot Env: ${target}"
}
function _bind_mounts() {