]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/initscripts/init.d/sshd
Firewall: Fix errormessages on rulecreation when red has no IP
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / sshd
CommitLineData
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
13case "$1" in
14 start)
167e6ec7
MT
15 if [ ! -e "/etc/ssh/ssh_host_key" ]; then
16 boot_mesg "Generating SSH host key..."
17 ssh-keygen -qf /etc/ssh/ssh_host_key -N '' -t rsa1
18 evaluate_retval
19 fi
20
21 for algo in rsa dsa ecdsa ed25519; do
22 keyfile="/etc/ssh/ssh_host_${algo}_key"
23
24 # If the key already exists, there is nothing to do.
25 [ -e "${keyfile}" ] && continue
26
27 case "${algo}" in
28 rsa)
29 algo="rsa1"
30 ;;
31 esac
32
33 boot_mesg "Generating SSH key (${algo})..."
34 ssh-keygen -qf "${keyfile}" -N '' -t ${algo}
35 evaluate_retval
36 done
c81e9e43
CS
37
38 [ -e "/var/ipfire/remote/enablessh" ] || exit 0 # SSH is not enabled
23104841
MT
39 boot_mesg "Starting SSH Server..."
40 # Also prevent ssh from being killed by out of memory conditions
41 loadproc /usr/sbin/sshd
cb5e9c6c 42 sleep 3
23104841
MT
43 echo "-16" >/proc/`cat /var/run/sshd.pid`/oom_adj
44 ;;
45
46 stop)
47 boot_mesg "Stopping SSH Server..."
48 killproc /usr/sbin/sshd
49 ;;
50
51 reload)
52 boot_mesg "Reloading SSH Server..."
53 reloadproc /usr/sbin/sshd
54 ;;
55
56 restart)
57 $0 stop
58 sleep 1
59 $0 start
60 ;;
61
62 status)
63 statusproc /usr/sbin/sshd
64 ;;
65
66 *)
67 echo "Usage: $0 {start|stop|reload|restart|status}"
68 exit 1
69 ;;
70esac
71
72# End $rc_base/init.d/sshd