mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-25 06:03:36 +03:00
F #5890: Add check for sysctl sudo access
This commit is contained in:
parent
d201ecf816
commit
f5788eda2e
@ -48,5 +48,5 @@ fi
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
@ -27,7 +27,7 @@ cat > $DEP_FILE
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
# Create non-volatile memory to store firmware variables if needed
|
||||
|
@ -117,7 +117,7 @@ done
|
||||
|
||||
# Compact memory
|
||||
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"
|
||||
fi
|
||||
|
||||
@ -285,6 +285,6 @@ fi
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
|
@ -36,7 +36,7 @@ done
|
||||
|
||||
# Compact memory on dest host
|
||||
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"
|
||||
fi
|
||||
|
||||
@ -71,6 +71,6 @@ fi
|
||||
|
||||
# Compact memory on src host
|
||||
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"
|
||||
fi
|
||||
|
@ -50,7 +50,7 @@ source $(dirname $0)/../../scripts_common.sh
|
||||
if [ ! -z "$MEM" -a "$MEM" -ne "$MEM_OLD" ]; then
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
# Add memory to VM
|
||||
@ -58,7 +58,7 @@ if [ ! -z "$MEM" -a "$MEM" -ne "$MEM_OLD" ]; then
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
|
@ -78,7 +78,7 @@ multiline_exec_and_log "$RECALCULATE_CMD" \
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
### Restore with retry
|
||||
|
@ -44,7 +44,7 @@ retry_if "active block job" 3 5 \
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -78,7 +78,7 @@ force_shutdown "$deploy_id" \
|
||||
|
||||
# Compact memory
|
||||
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
|
||||
|
||||
sleep 4
|
||||
|
Loading…
x
Reference in New Issue
Block a user