forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-11-20 5a4414d1fd83d52b073fc27f6e12dc9fe3b32766
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /bin/sh
set -e
 
PIDFILE=/var/run/sshd.pid
 
# source function library
. /etc/init.d/functions
 
# /etc/init.d/ssh: start and stop the OpenBSD "secure shell" daemon
 
test -x /usr/sbin/sshd || exit 0
( /usr/sbin/sshd -\? 2>&1 | grep -q OpenSSH ) 2>/dev/null || exit 0
 
# /etc/default/ssh may set SYSCONFDIR and SSHD_OPTS
if test -f /etc/default/ssh; then
    . /etc/default/ssh
fi
 
[ -z "$SYSCONFDIR" ] && SYSCONFDIR=/etc/ssh
mkdir -p $SYSCONFDIR
 
check_for_no_start() {
    # forget it if we're trying to start, and /etc/ssh/sshd_not_to_be_run exists
    if [ -e $SYSCONFDIR/sshd_not_to_be_run ]; then
   echo "OpenBSD Secure Shell server not in use ($SYSCONFDIR/sshd_not_to_be_run)"
   exit 0
    fi
}
 
check_privsep_dir() {
    # Create the PrivSep empty dir if necessary
    if [ ! -d /var/run/sshd ]; then
   mkdir /var/run/sshd
   chmod 0755 /var/run/sshd
    fi
}
 
check_config() {
    /usr/sbin/sshd $SSHD_OPTS -t || exit 1
}
 
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
 
case "$1" in
  start)
   check_for_no_start
   echo "Starting OpenBSD Secure Shell server: sshd"
   @LIBEXECDIR@/sshd_check_keys
   check_privsep_dir
   start-stop-daemon -S -p $PIDFILE -x /usr/sbin/sshd -- $SSHD_OPTS
   echo "done."
   ;;
  stop)
   echo -n "Stopping OpenBSD Secure Shell server: sshd"
   start-stop-daemon -K -p $PIDFILE -x /usr/sbin/sshd
   echo "."
   ;;
 
  reload|force-reload)
   check_for_no_start
   @LIBEXECDIR@/sshd_check_keys
   check_config
   echo -n "Reloading OpenBSD Secure Shell server's configuration"
   start-stop-daemon -K -p $PIDFILE -s 1 -x /usr/sbin/sshd
   echo "."
   ;;
 
  restart)
   @LIBEXECDIR@/sshd_check_keys
   check_config
   echo -n "Restarting OpenBSD Secure Shell server: sshd"
   start-stop-daemon -K -p $PIDFILE --oknodo -x /usr/sbin/sshd
   check_for_no_start
   check_privsep_dir
   sleep 2
   start-stop-daemon -S -p $PIDFILE -x /usr/sbin/sshd -- $SSHD_OPTS
   echo "."
   ;;
 
  status)
   status /usr/sbin/sshd
   exit $?
  ;;
 
  *)
   echo "Usage: /etc/init.d/ssh {start|stop|status|reload|force-reload|restart}"
   exit 1
esac
 
exit 0