You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB

  1. #!/bin/sh
  2. set -e
  3. # POSIX-compliant maint function recommend by devref
  4. # to check for the existence of a command
  5. # https://www.debian.org/doc/manuals/developers-reference/ch06.html#bpp-debian-maint-scripts
  6. pathfind() {
  7. OLDIFS="$IFS"
  8. IFS=:
  9. for p in $PATH; do
  10. if [ -x "$p/$*" ]; then
  11. IFS="$OLDIFS"
  12. return 0
  13. fi
  14. done
  15. IFS="$OLDIFS"
  16. return 1
  17. }
  18. case "$1" in
  19. configure|reconfigure)
  20. pathfind setcap && setcap \
  21. cap_net_bind_service+ep /usr/bin/ss-local \
  22. cap_net_bind_service,cap_net_admin+ep /usr/bin/ss-redir \
  23. cap_net_bind_service+ep /usr/bin/ss-server \
  24. cap_net_bind_service+ep /usr/bin/ss-tunnel
  25. if [ ! -f /etc/shadowsocks-libev/config.json ]; then
  26. passwd=$(apg -n 1 -M ncl)
  27. mkdir -p /etc/shadowsocks-libev
  28. sed "s/barfoo!/$passwd/" /usr/share/shadowsocks-libev/config.json \
  29. > /etc/shadowsocks-libev/config.json
  30. fi
  31. ;;
  32. abort-upgrade|abort-remove|abort-deconfigure)
  33. exit 0
  34. ;;
  35. *)
  36. echo "postinst called with unknown argument \`$1'" >&2
  37. exit 0
  38. ;;
  39. esac
  40. #DEBHELPER#
  41. exit 0