Conservative SmartOS global-zone memory pressure guard with dry-run-first policy and SMF integration.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

40 行
1.9 KiB

  1. #!/bin/sh
  2. # First install only. Does not import, enable or signal any service.
  3. set -eu
  4. PATH=/usr/bin:/usr/sbin:/sbin
  5. export PATH
  6. umask 077
  7. cd "$(dirname "$0")"
  8. if [ "$(uname -s)" != SunOS ] || [ "$(id -u)" != 0 ] || [ "$(zonename)" != global ]; then
  9. echo 'Run as root in the SmartOS global zone.' >&2
  10. exit 1
  11. fi
  12. if [ ! -f ./o6h-memory-guard ] || [ ! -x ./o6h-memory-guard ]; then
  13. echo 'Build the native 64-bit binary first (gmake).' >&2
  14. exit 1
  15. fi
  16. for target in /opt/custom/bin/o6h-memory-guard /opt/custom/etc/o6h-memory-guard.conf /opt/custom/smf/o6h-memory-guard.xml; do
  17. if [ -e "$target" ] || [ -L "$target" ]; then
  18. echo "Refusing to overwrite $target; see README upgrade/rollback." >&2
  19. exit 1
  20. fi
  21. done
  22. # Do not change existing /opt/custom permissions or follow destination symlinks.
  23. for dir in /opt/custom /opt/custom/bin /opt/custom/etc /opt/custom/smf /opt/custom/var /opt/custom/var/log /opt/custom/var/log/o6h-memory-guard /opt/custom/var/run; do
  24. if [ ! -d "$dir" ]; then mkdir "$dir"; chmod 0755 "$dir"; fi
  25. done
  26. ./o6h-memory-guard --check-install-dirs
  27. cp ./o6h-memory-guard /opt/custom/bin/o6h-memory-guard
  28. chmod 0755 /opt/custom/bin/o6h-memory-guard
  29. cp ./etc/o6h-memory-guard.conf /opt/custom/etc/o6h-memory-guard.conf
  30. chmod 0600 /opt/custom/etc/o6h-memory-guard.conf
  31. # The binary validates root ownership and all resolved parent permissions.
  32. /opt/custom/bin/o6h-memory-guard --check-config --config /opt/custom/etc/o6h-memory-guard.conf
  33. cp ./smf/o6h-memory-guard.xml /opt/custom/smf/o6h-memory-guard.xml
  34. chmod 0644 /opt/custom/smf/o6h-memory-guard.xml
  35. svccfg validate /opt/custom/smf/o6h-memory-guard.xml
  36. echo 'Installed; service has NOT been imported or enabled. Next:'
  37. echo '/opt/custom/bin/o6h-memory-guard --probe --force-dry-run'
  38. echo 'svccfg import /opt/custom/smf/o6h-memory-guard.xml'
  39. echo 'svcadm enable -s svc:/site/o6h-memory-guard:default'