Changeset 28899


Ignore:
Timestamp:
2011-11-10T00:11:43+01:00 (6 years ago)
Author:
nico
Message:

packages/openssh: use new service functions, move user/group creation from postinst to initscript

Location:
packages/net/openssh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • packages/net/openssh/Makefile

    r28312 r28899  
    11# 
    2 # Copyright (C) 2006,2008-2011 OpenWrt.org 
     2# Copyright (C) 2006-2011 OpenWrt.org 
    33# 
    44# This is free software, licensed under the GNU General Public License v2. 
     
    1010PKG_NAME:=openssh 
    1111PKG_VERSION:=5.9p1 
    12 PKG_RELEASE:=1 
     12PKG_RELEASE:=2 
    1313 
    1414PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 
     
    180180endef 
    181181 
    182 define Package/openssh-server/postinst 
    183 #!/bin/sh 
    184  
    185 name=sshd 
    186 id=22 
    187  
    188 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then 
    189         echo "adding group $$name to /etc/group" 
    190         echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group 
    191 fi 
    192  
    193 if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then 
    194         echo "adding user $$name to /etc/passwd" 
    195         echo "$${name}:x:$${id}:$${id}:$${name}:/var/empty/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd 
    196 fi 
    197 endef 
    198  
    199182define Package/openssh-sftp-client/install 
    200183        $(INSTALL_DIR) $(1)/usr/bin 
  • packages/net/openssh/files/sshd.init

    r24549 r28899  
    11#!/bin/sh /etc/rc.common 
    2 # Copyright (C) 2006 OpenWrt.org 
     2# Copyright (C) 2006-2011 OpenWrt.org 
     3 
    34START=50 
    45STOP=50 
     6 
     7SERVICE_USE_PID=1 
    58 
    69start() { 
     
    1619                } 
    1720        }; done 
    18         mkdir -p /var/empty 
    19         chmod 0700 /var/empty 
    20         /usr/sbin/sshd 
     21        user_exists sshd 22 || user_add sshd 22 
     22        group_exists sshd 22 || group_add ssh 22 
     23        mkdir -m 0700 -p /var/empty 
     24        mkdir -m 0755 -p /var/run/sshd 
     25        service_start /usr/sbin/sshd 
    2126} 
    2227 
    2328stop() { 
    24         kill $(cat /var/run/sshd.pid) 
     29        service_stop /usr/sbin/sshd 
    2530} 
    2631 
    2732shutdown() { 
    28         killall sshd 
     33        local pid 
     34        local pids 
     35        local pid_mine 
     36 
     37        stop 
     38 
     39        # kill active clients 
     40        pid_mine="$$" 
     41        pids="$(pidof sshd)" 
     42        for pid in $pids; do 
     43                [ "$pid" = "$pid_mine" ] && continue 
     44                [ -e "/proc/$pid/stat" ] && kill $pid 
     45        done 
    2946} 
Note: See TracChangeset for help on using the changeset viewer.