packages/openssh: use new service functions, move user/group creation from postinst to initscript
git-svn-id: svn://svn.openwrt.org/openwrt/packages@28899 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
9a9089341f
commit
83e86898b7
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2006,2008-2011 OpenWrt.org
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=openssh
|
||||
PKG_VERSION:=5.9p1
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/ \
|
||||
@ -179,23 +179,6 @@ define Package/openssh-server/install
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/sshd $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/openssh-server/postinst
|
||||
#!/bin/sh
|
||||
|
||||
name=sshd
|
||||
id=22
|
||||
|
||||
if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
|
||||
echo "adding group $$name to /etc/group"
|
||||
echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
|
||||
fi
|
||||
|
||||
if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
|
||||
echo "adding user $$name to /etc/passwd"
|
||||
echo "$${name}:x:$${id}:$${id}:$${name}:/var/empty/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd
|
||||
fi
|
||||
endef
|
||||
|
||||
define Package/openssh-sftp-client/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sftp $(1)/usr/bin/
|
||||
|
@ -1,8 +1,11 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
|
||||
START=50
|
||||
STOP=50
|
||||
|
||||
SERVICE_USE_PID=1
|
||||
|
||||
start() {
|
||||
for type in rsa dsa; do {
|
||||
# check for keys
|
||||
@ -15,15 +18,29 @@ start() {
|
||||
exit 0
|
||||
}
|
||||
}; done
|
||||
mkdir -p /var/empty
|
||||
chmod 0700 /var/empty
|
||||
/usr/sbin/sshd
|
||||
user_exists sshd 22 || user_add sshd 22
|
||||
group_exists sshd 22 || group_add ssh 22
|
||||
mkdir -m 0700 -p /var/empty
|
||||
mkdir -m 0755 -p /var/run/sshd
|
||||
service_start /usr/sbin/sshd
|
||||
}
|
||||
|
||||
stop() {
|
||||
kill $(cat /var/run/sshd.pid)
|
||||
service_stop /usr/sbin/sshd
|
||||
}
|
||||
|
||||
shutdown() {
|
||||
killall sshd
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user