check status
This commit is contained in:
@@ -12,10 +12,10 @@ function stop_container() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $(date) "- Start updating LXC container..."
|
echo $(date) "- Start updating LXC container..."
|
||||||
for i in $(lxc list type=container -c ns --format csv); do
|
for cont_name in $(lxc list type=container -c n --format csv); do
|
||||||
cont_name=${i%,*}
|
|
||||||
echo $(date) "- Updating ${cont_name} container..."
|
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}"
|
echo -e $(date) "- ${BGreen}Start container ${cont_name}${Color_Off}"
|
||||||
lxc start ${cont_name}
|
lxc start ${cont_name}
|
||||||
sleep 5
|
sleep 5
|
||||||
@@ -31,7 +31,7 @@ for i in $(lxc list type=container -c ns --format csv); do
|
|||||||
echo -e $(date) "- Refresh snap packages"
|
echo -e $(date) "- Refresh snap packages"
|
||||||
lxc exec ${cont_name} -- bash -c "if [[ \$(which snap > /dev/null; echo \$?) == 0 ]]; then snap refresh ; fi"
|
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}"
|
echo $(date) "- Stop container ${cont_name}"
|
||||||
stop_container ${cont_name} &
|
stop_container ${cont_name} &
|
||||||
pids[${cont_name}]=$!
|
pids[${cont_name}]=$!
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ if [[ $1 == '' ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo $(date) "- Start updating $1 LXC container..."
|
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..."
|
echo $(date) "- Updating $1 container..."
|
||||||
if [ $status == "STOPPED" ]; then
|
if [ $status == "STOPPED" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user