1
0

install.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. HERE=$(dirname $0)
  3. TOP=$(cd $HERE/.. ; pwd)
  4. OUTPUT=$HERE/output
  5. GZ_SMF=/opt/custom/smf
  6. MASTER=$1
  7. # process the manifests
  8. mkdir $OUTPUT
  9. for file in $HERE/*.xml
  10. do
  11. sed "s#SALT_PREFIX#$TOP#" <$file >$OUTPUT/$(basename $file)
  12. done
  13. # detect global or non-global zone
  14. if [[ $(zonename) == global ]]
  15. then
  16. # we assume global zones are always minions only
  17. # and we assume that they want to have the service come back on reboot
  18. mkdir -p $GZ_SMF
  19. sed 's/false/true/' < $OUTPUT/salt-minion.xml > $GZ_SMF/salt-minion.xml
  20. svccfg import $OUTPUT/salt-minion.xml
  21. echo "Minion is set to be launched at boot"
  22. else
  23. # non global zones get all three services imported
  24. # and the user can enable whichever ones they want
  25. for file in $OUTPUT/*.xml
  26. do
  27. svccfg import $file
  28. done
  29. echo "To enable master service, invoke either of"
  30. echo " svcadm enable salt-master"
  31. echo " svcadm enable salt-syndic"
  32. echo "as appropriate"
  33. fi
  34. # if the user provided the name of the master as an argument
  35. # configure a minimal minion file and start the minion
  36. if [[ -n $MASTER ]]
  37. then
  38. [[ -f $TOP/etc/minion.example ]] || mv $TOP/etc/minion{,.example}
  39. echo "master: $MASTER" > $TOP/etc/minion
  40. echo "Minion configured to talk to master $MASTER. Enabling minion now."
  41. svcadm enable salt-minion
  42. else
  43. echo "To enable minion service, invoke:"
  44. echo " svcadm enable salt-minion"
  45. fi
  46. rm -rf $OUTPUT