source: hybrid/branches/releng-9.0/nanobsd/files/etc/local/rc.d/nanobsd-save-sshkeys@ 10417

Last change on this file since 10417 was 10417, checked in by rick, 13 years ago

Merging and cleanups of files found in various other places and trees of SVN.

  • Property svn:executable set to *
File size: 898 bytes
Line 
1#!/bin/sh
2#
3# $FreeBSD: ports/net/pen/files/pen.sh.in,v 1.1 2006/09/24 14:34:36 clement Exp $
4#
5
6# PROVIDE: pen
7# REQUIRE: NETWORKING SERVERS sshd
8# KEYWORD: shutdown
9
10#
11# Add the following line to /etc/rc.conf to enable nanobsd-save-sshkeys:
12#
13# nanobsd_save_sshkeys_enable="YES"
14#
15
16. /etc/rc.subr
17
18name=nanobsd_save_sshkeys
19rcvar=`set_rcvar`
20
21nanobsd_save_sshkeys_enable=${nanobsd_save_sshkeys_enable:-"NO"}
22
23start_cmd="save_sshkeys"
24stop_cmd="save_sshkeys"
25
26save_sshkeys() {
27 MOUNTED_RW=0
28 trap "umount /cfg" 1 2 15 EXIT
29 mount -ro noatime /cfg
30 for FILE in /etc/ssh/ssh_host_*; do
31 cmp -s $FILE /cfg/ssh/`basename ${FILE}`
32 if [ $? -ne 0 ]; then
33 if [ ${MOUNTED_RW} -eq 0 ]; then
34 mount -uwo noatime /cfg
35 mkdir -p /cfg/ssh
36 MOUNTED_RW=1
37 fi
38 cp $FILE /cfg/ssh/`basename ${FILE}`
39 fi
40 done
41
42 umount /cfg
43 trap 1 2 15 EXIT
44}
45
46
47load_rc_config $name
48run_rc_command "$1"
49
Note: See TracBrowser for help on using the repository browser.