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.

54 lines
1.3 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. if pathfind setcap; then
  21. if ! setcap \
  22. cap_net_bind_service+ep /usr/bin/ss-local \
  23. cap_net_bind_service,cap_net_admin+ep /usr/bin/ss-redir \
  24. cap_net_bind_service+ep /usr/bin/ss-server \
  25. cap_net_bind_service+ep /usr/bin/ss-tunnel; then
  26. echo "Failed to set capabilities; ss-* will only be runnable by root."
  27. fi
  28. else
  29. echo "setcap not installed; ss-* will only be runnable by root."
  30. fi
  31. if [ ! -f /etc/shadowsocks-libev/config.json ]; then
  32. set +e
  33. passwd=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..12)')
  34. set -e
  35. mkdir -p /etc/shadowsocks-libev
  36. sed "s/barfoo!/$passwd/" /usr/share/shadowsocks-libev/config.json \
  37. > /etc/shadowsocks-libev/config.json
  38. fi
  39. ;;
  40. abort-upgrade|abort-remove|abort-deconfigure)
  41. exit 0
  42. ;;
  43. *)
  44. echo "postinst called with unknown argument \`$1'" >&2
  45. exit 0
  46. ;;
  47. esac
  48. #DEBHELPER#
  49. exit 0