lib_valkey.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. valkey.distro.setup() {
  4. # shellcheck disable=SC2034
  5. case $DIST_ID in
  6. ubuntu|debian)
  7. VALKEY_PACKAGES="valkey-server"
  8. ;;
  9. arch|fedora|centos)
  10. VALKEY_PACKAGES="valkey"
  11. ;;
  12. *)
  13. err_msg "$DIST_ID: valkey not yet implemented"
  14. ;;
  15. esac
  16. }
  17. valkey.backports() {
  18. case $DIST_ID in
  19. debian)
  20. info_msg "APT:: install debian-stable-backports.source / ${DIST_ID}-${DIST_VERS} (${DIST_VERSION_CODENAME})"
  21. install_template /etc/apt/sources.list.d/debian-stable-backports.sources
  22. apt update
  23. ;;
  24. ubuntu)
  25. info_msg "APT:: install ubuntu-stable-backports.source / ${DIST_ID}-${DIST_VERS} (${DIST_VERSION_CODENAME})"
  26. install_template /etc/apt/sources.list.d/ubuntu-stable-backports.sources
  27. apt update
  28. ;;
  29. *)
  30. info_msg "APT:: valkey.backports no implementation / ${DIST_ID}-${DIST_VERS} (${DIST_VERSION_CODENAME})"
  31. ;;
  32. esac
  33. }
  34. valkey.install(){
  35. info_msg "installing valkey ..."
  36. valkey.distro.setup
  37. case $DIST_ID in
  38. debian|ubuntu)
  39. apt-cache show "${VALKEY_PACKAGES}" &> /dev/null || valkey.backports
  40. pkg_install "${VALKEY_PACKAGES}"
  41. # do some fix ...
  42. # chown -R valkey:valkey /var/log/valkey/ /var/lib/valkey/ /etc/valkey/
  43. # https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#PrivateUsers=
  44. sed -i 's/PrivateUsers=true/# PrivateUsers=true/' /lib/systemd/system/valkey-server.service
  45. sed -i 's/PrivateUsers=true/# PrivateUsers=true/' /lib/systemd/system/valkey-server@.service
  46. systemd_activate_service valkey-server
  47. ;;
  48. arch|fedora|centos)
  49. pkg_install "${VALKEY_PACKAGES}"
  50. systemd_activate_service valkey
  51. ;;
  52. *)
  53. # install backports if package is not in the current APT repos
  54. pkg_install "${VALKEY_PACKAGES}"
  55. ;;
  56. esac
  57. # case $DIST_ID-$DIST_VERS in
  58. # arch-*|fedora-*|centos-7)
  59. # systemctl enable nginx
  60. # systemctl start nginx
  61. # ;;
  62. # esac
  63. }