summaryrefslogtreecommitdiff
path: root/templates/service
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-06 14:22:11 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-06 14:22:11 -0800
commit1c0e75890bc02e85754ed0e1d8d83252871734d0 (patch)
treee81d7913f86a3d60d9e137c56e6eaecbbbeda0b1 /templates/service
parentfdab2e3a0a1f9bc658df46a2a29bccb8aa5b0f05 (diff)
downloadvyatta-cfg-system-1c0e75890bc02e85754ed0e1d8d83252871734d0.tar.gz
vyatta-cfg-system-1c0e75890bc02e85754ed0e1d8d83252871734d0.zip
Don't restart sshd if not needed
If configuration doesn't change (ie during boot), then do not need to restart sshd. Also use newer format configuration file syntax.
Diffstat (limited to 'templates/service')
-rw-r--r--templates/service/ssh/node.def33
1 files changed, 17 insertions, 16 deletions
diff --git a/templates/service/ssh/node.def b/templates/service/ssh/node.def
index fbb29687..585357dd 100644
--- a/templates/service/ssh/node.def
+++ b/templates/service/ssh/node.def
@@ -1,17 +1,18 @@
help: Enable/disable Secure SHell (SSH) protocol
-delete:expression: "sudo /usr/sbin/invoke-rc.d ssh stop && \
- sudo sh -c \"echo 'SSHD_OPTS=' > /etc/default/ssh\" "
-end:expression: "if [ -z \"$VAR(port/@)\" ]; then exit 0; fi; \
- sudo sh -c \
- \"[ -f /etc/ssh/ssh_host_key ] \
- || sudo ssh-keygen -t rsa1 -N '' -f /etc/ssh/ssh_host_key\"; \
- case \"$VAR(protocol-version/@)\" in \
- v2) VER=2;; \
- v1) VER=1;; \
- all) VER=\"1,2\";; \
- *) VER=2;; \
- esac; \
- STR=\"SSHD_OPTS=\\\"-p $VAR(port/@) -o HostKey=/etc/ssh/ssh_host_key \
--o Protocol=${VER}\\\"\"; \
- sudo sh -c \"echo '$STR' > /etc/default/ssh\"; \
- sudo /usr/sbin/invoke-rc.d ssh restart"
+delete:sudo /usr/sbin/invoke-rc.d ssh stop
+ sudo sh -c "echo 'SSHD_OPTS=' > /etc/default/ssh"
+end: if [ -z "$VAR(port/@)" ]; then exit 0; fi;
+ if [ ! -f /etc/ssh/ssh_host_key ]; then
+ sudo ssh-keygen -q -t rsa1 -N '' -f /etc/ssh/ssh_host_key
+ fi
+ case $VAR(protocol-version/@) in
+ v2) VER=2;;
+ v1) VER=1;;
+ all) VER="1,2";;
+ *) VER=2;;
+ esac;
+ STR="SSHD_OPTS=\"-p $VAR(port/@) -o Hostkey=/etc/ssh/ssh_host_key -o Protocol=${VER}\""
+ if ! grep -q -s "^$STR" /etc/default/ssh; then
+ sudo sh -c "echo '$STR' > /etc/default/ssh"
+ sudo /usr/sbin/invoke-rc.d ssh restart
+ fi