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.

44 lines
815 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. START=50
  4. STOP=50
  5. USE_PROCD=1
  6. PROG=/usr/sbin/sshd
  7. start_service() {
  8. for type in rsa dsa; do {
  9. # check for keys
  10. key=/etc/ssh/ssh_host_${type}_key
  11. [ ! -f $key ] && {
  12. # generate missing keys
  13. [ -x /usr/bin/ssh-keygen ] && {
  14. /usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&-
  15. }
  16. }
  17. }; done
  18. user_exists sshd 22 || user_add sshd 22 22 sshd /var/empty
  19. group_exists sshd 22 || group_add sshd 22
  20. mkdir -m 0700 -p /var/empty
  21. procd_open_instance
  22. procd_set_param command $PROG -D
  23. procd_close_instance
  24. }
  25. shutdown() {
  26. local pid
  27. local pids
  28. local pid_mine
  29. stop
  30. # kill active clients
  31. pid_mine="$$"
  32. pids="$(pidof sshd)"
  33. for pid in $pids; do
  34. [ "$pid" = "$pid_mine" ] && continue
  35. [ -e "/proc/$pid/stat" ] && kill $pid
  36. done
  37. }