install.sh 988 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. branch="master"
  3. tar="https://codeload.github.com/calmh/zsnapper/tar.gz/$branch"
  4. instdir="/opt/local"
  5. configdir="/opt/local/etc"
  6. configfile="zsnapper.ini"
  7. config="$configdir/$configfile"
  8. smf="/opt/custom/smf/zsnapper.xml"
  9. fail() {
  10. echo Installation failed
  11. exit -1
  12. }
  13. echo "Installing into $instdir/zsnapper."
  14. mkdir -p $instdir
  15. cd "$instdir" || fail
  16. [ -d zsnapper.previous ] && rm -rf zsnapper.previous
  17. [ -d zsnapper ] && mv zsnapper zsnapper.previous
  18. ( curl -sk "$tar" | gtar zxf - ) || fail
  19. mv "zsnapper-$branch" zsnapper || fail
  20. if [ ! -f "$config" ] ; then
  21. echo "No config file, installing default into $config."
  22. mkdir -p "$configdir"
  23. cp zsnapper/zsnapper.ini "$config" || fail
  24. fi
  25. if [ ! -f "$smf" ] ; then
  26. echo "No SMF manifest, installing into $smf."
  27. cp zsnapper/zsnapper.xml "$smf" || fail
  28. fi
  29. echo
  30. echo "Installation complete."
  31. echo " 1. Edit the config file $config to taste."
  32. echo " 2. Import the SMF manifest to start the service:"
  33. echo " svccfg import $smf"