Conservative SmartOS global-zone memory pressure guard with dry-run-first policy and SMF integration.
Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- #!/bin/sh
- # First install only. Does not import, enable or signal any service.
- set -eu
- PATH=/usr/bin:/usr/sbin:/sbin
- export PATH
- umask 077
- cd "$(dirname "$0")"
- if [ "$(uname -s)" != SunOS ] || [ "$(id -u)" != 0 ] || [ "$(zonename)" != global ]; then
- echo 'Run as root in the SmartOS global zone.' >&2
- exit 1
- fi
- if [ ! -f ./o6h-memory-guard ] || [ ! -x ./o6h-memory-guard ]; then
- echo 'Build the native 64-bit binary first (gmake).' >&2
- exit 1
- fi
- for target in /opt/custom/bin/o6h-memory-guard /opt/custom/etc/o6h-memory-guard.conf /opt/custom/smf/o6h-memory-guard.xml; do
- if [ -e "$target" ] || [ -L "$target" ]; then
- echo "Refusing to overwrite $target; see README upgrade/rollback." >&2
- exit 1
- fi
- done
- # Do not change existing /opt/custom permissions or follow destination symlinks.
- 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
- if [ ! -d "$dir" ]; then mkdir "$dir"; chmod 0755 "$dir"; fi
- done
- ./o6h-memory-guard --check-install-dirs
- cp ./o6h-memory-guard /opt/custom/bin/o6h-memory-guard
- chmod 0755 /opt/custom/bin/o6h-memory-guard
- cp ./etc/o6h-memory-guard.conf /opt/custom/etc/o6h-memory-guard.conf
- chmod 0600 /opt/custom/etc/o6h-memory-guard.conf
- # The binary validates root ownership and all resolved parent permissions.
- /opt/custom/bin/o6h-memory-guard --check-config --config /opt/custom/etc/o6h-memory-guard.conf
- cp ./smf/o6h-memory-guard.xml /opt/custom/smf/o6h-memory-guard.xml
- chmod 0644 /opt/custom/smf/o6h-memory-guard.xml
- svccfg validate /opt/custom/smf/o6h-memory-guard.xml
- echo 'Installed; service has NOT been imported or enabled. Next:'
- echo '/opt/custom/bin/o6h-memory-guard --probe --force-dry-run'
- echo 'svccfg import /opt/custom/smf/o6h-memory-guard.xml'
- echo 'svcadm enable -s svc:/site/o6h-memory-guard:default'
|