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.

52 lines
1.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=90
  4. STOP=10
  5. USE_PROCD=1
  6. PROG=/usr/sbin/squid
  7. CONFIGFILE="/tmp/squid/squid.conf"
  8. validate_squid_section() {
  9. uci_validate_section squid squid "${1}" \
  10. 'config_file:string' \
  11. 'http_port:port:3128' \
  12. 'coredump_dir:string' \
  13. 'visible_hostname:string:OpenWrt' \
  14. 'pinger_enable:string:off'
  15. }
  16. start_service() {
  17. local config_file http_port coredump_dir visible_hostname pinger_enable
  18. validate_squid_section squid || {
  19. echo "validation failed"
  20. return 1
  21. }
  22. mkdir -p $(dirname $CONFIGFILE)
  23. cat $config_file > $CONFIGFILE
  24. echo http_port $http_port >> $CONFIGFILE
  25. echo coredump_dir $coredump_dir >> $CONFIGFILE
  26. echo visible_hostname $visible_hostname >> $CONFIGFILE
  27. echo pinger_enable $pinger_enable >> $CONFIGFILE
  28. procd_open_instance
  29. procd_set_param command $PROG -s -f $CONFIGFILE -N
  30. procd_set_param file $CONFIGFILE
  31. procd_set_param respawn
  32. procd_close_instance
  33. }
  34. stop_service()
  35. {
  36. ${PROG} -f $CONFIGFILE -N -k shutdown 2>/dev/null
  37. }
  38. service_triggers()
  39. {
  40. procd_add_reload_trigger "squid"
  41. procd_add_validation validate_squid_section
  42. }