1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-03 13:47:01 +03:00

F #5890: Add check for sysctl sudo access

This commit is contained in:
Ruben S. Montero 2022-07-05 11:21:40 +02:00
parent d201ecf816
commit f5788eda2e
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
8 changed files with 11 additions and 11 deletions

View File

@ -48,5 +48,5 @@ fi
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null & (sudo -l | grep -q sysctl) && (sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &) || true
fi fi

View File

@ -27,7 +27,7 @@ cat > $DEP_FILE
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null
fi fi
# Create non-volatile memory to store firmware variables if needed # Create non-volatile memory to store firmware variables if needed

View File

@ -117,7 +117,7 @@ done
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then
ssh_exec_and_log "$DEST_HOST" "sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null" \ ssh_exec_and_log "$DEST_HOST" "(sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null || true" \
"Failed compact memory on $DEST_HOST" "Failed compact memory on $DEST_HOST"
fi fi
@ -285,6 +285,6 @@ fi
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null & (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &
fi fi

View File

@ -36,7 +36,7 @@ done
# Compact memory on dest host # Compact memory on dest host
if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then
ssh_exec_and_log "$dest_host" "sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null" \ ssh_exec_and_log "$dest_host" "(sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null || true" \
"Failed compact memory on $dest_host" "Failed compact memory on $dest_host"
fi fi
@ -71,6 +71,6 @@ fi
# Compact memory on src host # Compact memory on src host
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
ssh_exec_and_log "$src_host" "sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &" \ ssh_exec_and_log "$src_host" "(sudo -l | grep -q sysctl) && (sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &) || true" \
"Failed compact memory on $src_host" "Failed compact memory on $src_host"
fi fi

View File

@ -50,7 +50,7 @@ source $(dirname $0)/../../scripts_common.sh
if [ ! -z "$MEM" -a "$MEM" -ne "$MEM_OLD" ]; then if [ ! -z "$MEM" -a "$MEM" -ne "$MEM_OLD" ]; then
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null
fi fi
# Add memory to VM # Add memory to VM
@ -58,7 +58,7 @@ if [ ! -z "$MEM" -a "$MEM" -ne "$MEM_OLD" ]; then
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null & (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &
fi fi
fi fi

View File

@ -78,7 +78,7 @@ multiline_exec_and_log "$RECALCULATE_CMD" \
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_START" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 >/dev/null
fi fi
### Restore with retry ### Restore with retry

View File

@ -44,7 +44,7 @@ retry_if "active block job" 3 5 \
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null & (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &
fi fi
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -78,7 +78,7 @@ force_shutdown "$deploy_id" \
# Compact memory # Compact memory
if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then if [ "x$CLEANUP_MEMORY_ON_STOP" = "xyes" ]; then
sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null & (sudo -l | grep -q sysctl) && sudo -n sysctl vm.drop_caches=3 vm.compact_memory=1 &>/dev/null &
fi fi
sleep 4 sleep 4