test shell
This commit is contained in:
parent
03c16717cc
commit
0d30de9e22
@ -52,15 +52,48 @@ do
|
|||||||
done
|
done
|
||||||
container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}')
|
container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}')
|
||||||
container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}')
|
container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}')
|
||||||
|
while true
|
||||||
|
do
|
||||||
clear -x
|
clear -x
|
||||||
title
|
title
|
||||||
echo "App Name: $app_name"
|
echo "App Name: $app_name"
|
||||||
echo "Container: $container"
|
echo "Container: $container"
|
||||||
echo
|
echo
|
||||||
|
echo "1) Run a single command"
|
||||||
|
echo "2) Open Shell"
|
||||||
|
echo
|
||||||
echo "0) Exit"
|
echo "0) Exit"
|
||||||
read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; }
|
read -rt 120 -p "Please choose an option: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||||
[[ $command == 0 ]] && echo "Exiting.." && exit
|
case $selection in
|
||||||
k3s crictl exec "$container_id" $command
|
0)
|
||||||
container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}')
|
echo "Exiting.."
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
|
||||||
|
1)
|
||||||
|
clear -x
|
||||||
|
title
|
||||||
|
read -rt 120 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; }
|
||||||
|
k3s crictl exec -it "$container_id" $command
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
|
2)
|
||||||
|
clear -x
|
||||||
|
title
|
||||||
|
|
||||||
|
if ! k3s crictl exec -it "$container_id" /bin/bash ; then
|
||||||
|
k3s crictl exec -it "$container_id" /bin/sh
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "That was not an option.. Try again"
|
||||||
|
sleep 3
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
export -f cmd_to_container
|
export -f cmd_to_container
|
Loading…
Reference in New Issue
Block a user