2006-10-04 20:57:49 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2011-11-09 23:11:43 +00:00
|
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
|
|
|
|
2007-05-10 10:38:53 +00:00
|
|
|
START=50
|
2010-01-30 18:12:57 +00:00
|
|
|
STOP=50
|
2006-07-24 18:14:09 +00:00
|
|
|
|
2013-09-22 17:41:58 +00:00
|
|
|
USE_PROCD=1
|
|
|
|
PROG=/usr/sbin/sshd
|
2011-11-09 23:11:43 +00:00
|
|
|
|
2013-09-22 17:41:58 +00:00
|
|
|
start_service() {
|
2006-10-04 20:57:49 +00:00
|
|
|
for type in rsa dsa; do {
|
|
|
|
# check for keys
|
|
|
|
key=/etc/ssh/ssh_host_${type}_key
|
|
|
|
[ ! -f $key ] && {
|
|
|
|
# generate missing keys
|
|
|
|
[ -x /usr/bin/ssh-keygen ] && {
|
2012-05-04 00:53:27 +00:00
|
|
|
/usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&-
|
|
|
|
}
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|
|
|
|
}; done
|
2011-11-10 00:10:24 +00:00
|
|
|
user_exists sshd 22 || user_add sshd 22 22 sshd /var/empty
|
|
|
|
group_exists sshd 22 || group_add sshd 22
|
2011-11-09 23:11:43 +00:00
|
|
|
mkdir -m 0700 -p /var/empty
|
2006-10-04 20:57:49 +00:00
|
|
|
|
2013-09-22 17:41:58 +00:00
|
|
|
procd_open_instance
|
|
|
|
procd_set_param command $PROG -D
|
|
|
|
procd_close_instance
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|
2010-12-13 18:39:14 +00:00
|
|
|
|
|
|
|
shutdown() {
|
2011-11-09 23:11:43 +00:00
|
|
|
local pid
|
|
|
|
local pids
|
|
|
|
local pid_mine
|
|
|
|
|
|
|
|
stop
|
|
|
|
|
|
|
|
# kill active clients
|
|
|
|
pid_mine="$$"
|
|
|
|
pids="$(pidof sshd)"
|
|
|
|
for pid in $pids; do
|
|
|
|
[ "$pid" = "$pid_mine" ] && continue
|
|
|
|
[ -e "/proc/$pid/stat" ] && kill $pid
|
|
|
|
done
|
2010-12-13 18:39:14 +00:00
|
|
|
}
|