check status

This commit is contained in:
2024-02-09 17:57:43 +01:00
parent 8a4712a34f
commit c3e9de982d
2 changed files with 5 additions and 5 deletions

View File

@@ -12,10 +12,10 @@ function stop_container() {
}
echo $(date) "- Start updating LXC container..."
for i in $(lxc list type=container -c ns --format csv); do
cont_name=${i%,*}
for cont_name in $(lxc list type=container -c n --format csv); do
echo $(date) "- Updating ${cont_name} container..."
if [ "${i#*,}" == "STOPPED" ]; then
Status=$(lxc list type=container -c ns --format csv | grep ${cont_name} | cut -d',' -f 2)
if [ "${Status}" == "STOPPED" ]; then
echo -e $(date) "- ${BGreen}Start container ${cont_name}${Color_Off}"
lxc start ${cont_name}
sleep 5
@@ -31,7 +31,7 @@ for i in $(lxc list type=container -c ns --format csv); do
echo -e $(date) "- Refresh snap packages"
lxc exec ${cont_name} -- bash -c "if [[ \$(which snap > /dev/null; echo \$?) == 0 ]]; then snap refresh ; fi"
if [ "${i#*,}" == "STOPPED" ]; then
if [ "${Status}" == "STOPPED" ]; then
echo $(date) "- Stop container ${cont_name}"
stop_container ${cont_name} &
pids[${cont_name}]=$!

View File

@@ -15,7 +15,7 @@ if [[ $1 == '' ]]; then
fi
echo $(date) "- Start updating $1 LXC container..."
status=$(lxc info microk8s | grep Status | cut -d' ' -f 2)
status=$(lxc info $1 | grep Status | cut -d' ' -f 2)
echo $(date) "- Updating $1 container..."
if [ $status == "STOPPED" ]; then