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
|
|
|
|
2011-11-09 23:11:43 +00:00
|
|
|
SERVICE_USE_PID=1
|
|
|
|
|
2006-10-04 20:57:49 +00:00
|
|
|
start() {
|
|
|
|
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 ] && {
|
2007-02-27 23:55:20 +00:00
|
|
|
/usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&- && exec /etc/rc.common "$initscript" start
|
2006-10-04 20:57:49 +00:00
|
|
|
} &
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
}; 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
|
|
|
|
service_start /usr/sbin/sshd
|
2006-10-04 20:57:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2011-11-09 23:11:43 +00:00
|
|
|
service_stop /usr/sbin/sshd
|
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
|
|
|
}
|