]>
Commit | Line | Data |
---|---|---|
23104841 MT |
1 | #!/bin/sh |
2 | # Begin $rc_base/init.d/sshd | |
3 | ||
4 | # Based on sysklogd script from LFS-3.1 and earlier. | |
5 | # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org | |
6 | ||
7 | #$LastChangedBy: bdubbs $ | |
8 | #$Date: 2006-04-15 17:34:16 -0500 (Sat, 15 Apr 2006) $ | |
9 | ||
10 | . /etc/sysconfig/rc | |
11 | . $rc_functions | |
12 | ||
13 | case "$1" in | |
14 | start) | |
04da8aa7 | 15 | for algo in rsa ecdsa ed25519; do |
167e6ec7 MT |
16 | keyfile="/etc/ssh/ssh_host_${algo}_key" |
17 | ||
18 | # If the key already exists, there is nothing to do. | |
19 | [ -e "${keyfile}" ] && continue | |
20 | ||
167e6ec7 MT |
21 | boot_mesg "Generating SSH key (${algo})..." |
22 | ssh-keygen -qf "${keyfile}" -N '' -t ${algo} | |
23 | evaluate_retval | |
24 | done | |
c81e9e43 CS |
25 | |
26 | [ -e "/var/ipfire/remote/enablessh" ] || exit 0 # SSH is not enabled | |
23104841 | 27 | boot_mesg "Starting SSH Server..." |
23104841 | 28 | loadproc /usr/sbin/sshd |
22fd89c6 MT |
29 | |
30 | # Also prevent ssh from being killed by out of memory conditions | |
31 | ( | |
32 | sleep 3 | |
33 | pid=$(cat /var/run/sshd.pid 2>/dev/null) | |
33df321e | 34 | [ -n "${pid}" ] && echo "-16" > "/proc/${pid}/oom_score_adj" |
22fd89c6 | 35 | ) & |
23104841 MT |
36 | ;; |
37 | ||
38 | stop) | |
39 | boot_mesg "Stopping SSH Server..." | |
40 | killproc /usr/sbin/sshd | |
41 | ;; | |
42 | ||
43 | reload) | |
44 | boot_mesg "Reloading SSH Server..." | |
45 | reloadproc /usr/sbin/sshd | |
46 | ;; | |
47 | ||
48 | restart) | |
49 | $0 stop | |
50 | sleep 1 | |
51 | $0 start | |
52 | ;; | |
53 | ||
54 | status) | |
55 | statusproc /usr/sbin/sshd | |
56 | ;; | |
57 | ||
58 | *) | |
59 | echo "Usage: $0 {start|stop|reload|restart|status}" | |
60 | exit 1 | |
61 | ;; | |
62 | esac | |
63 | ||
64 | # End $rc_base/init.d/sshd |