9afc85bafc
* group_add sshd not ssh * dont create /var/run/sshd git-svn-id: svn://svn.openwrt.org/openwrt/packages@28931 3c298f89-4303-0410-b956-a3cf2f4a3e73
46 lines
841 B
Bash
46 lines
841 B
Bash
#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
|
|
|
START=50
|
|
STOP=50
|
|
|
|
SERVICE_USE_PID=1
|
|
|
|
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 ] && {
|
|
/usr/bin/ssh-keygen -N '' -t $type -f $key 2>&- >&- && exec /etc/rc.common "$initscript" start
|
|
} &
|
|
exit 0
|
|
}
|
|
}; done
|
|
user_exists sshd 22 || user_add sshd 22 22 sshd /var/empty
|
|
group_exists sshd 22 || group_add sshd 22
|
|
mkdir -m 0700 -p /var/empty
|
|
service_start /usr/sbin/sshd
|
|
}
|
|
|
|
stop() {
|
|
service_stop /usr/sbin/sshd
|
|
}
|
|
|
|
shutdown() {
|
|
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
|
|
}
|