Project

General

Profile

Download (2.08 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# pfSense-rc.shutdown
4
#
5
# part of pfSense (https://www.pfsense.org)
6
# Copyright (c) 2004-2013 BSD Perimeter
7
# Copyright (c) 2013-2016 Electric Sheep Fencing
8
# Copyright (c) 2014-2019 Rubicon Communications, LLC (Netgate)
9
# All rights reserved.
10
#
11
# Licensed under the Apache License, Version 2.0 (the "License");
12
# you may not use this file except in compliance with the License.
13
# You may obtain a copy of the License at
14
#
15
# http://www.apache.org/licenses/LICENSE-2.0
16
#
17
# Unless required by applicable law or agreed to in writing, software
18
# distributed under the License is distributed on an "AS IS" BASIS,
19
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
# See the License for the specific language governing permissions and
21
# limitations under the License.
22

    
23
if ! /usr/bin/lockf -s -t 30 /tmp/config.lock /usr/bin/true; then
24
	echo "Cannot shutdown at this moment, a config write operation is in progress and 30 seconds have passed."
25
	exit -1
26
fi
27

    
28
# Read product_name from $g, defaults to pfSense
29
product=$(/usr/local/sbin/read_global_var product_name pfSense)
30

    
31
echo
32
echo "${product} is now shutting down ..."
33
echo
34

    
35
stty status '^T'
36

    
37
# Set shell to ignore SIGINT (2), but not children;
38
trap : 2
39

    
40
HOME=/; export HOME
41
PATH=/sbin:/bin:/usr/sbin:/usr/bin
42
export PATH
43

    
44
# Remove temporary files on shutdown from /tmp/
45
find -x /tmp/* -type f -exec rm -f {} \; >/dev/null 2>&1
46

    
47
USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
48
DISK_NAME=`/bin/df /var/db/rrd | /usr/bin/tail -1 | /usr/bin/awk '{print $1;}'`
49
DISK_TYPE=`/usr/bin/basename ${DISK_NAME} | /usr/bin/cut -c1-2`
50
# If we are not on a full install, or if the full install wants RAM disks, or if the full install _was_ using RAM disks, but isn't for the next boot...
51
if [ "${USE_MFS_TMPVAR}" = "true" ] || [ "${DISK_TYPE}" = "md" ]; then
52
	/etc/rc.backup_aliastables.sh
53
	/etc/rc.backup_rrd.sh
54
	/etc/rc.backup_dhcpleases.sh
55
	/etc/rc.backup_logs.sh
56
fi
57

    
58
# Invoke shutdown scripts if present
59
scripts=/usr/local/etc/rc.d/shutdown.*.sh
60
for script in $scripts
61
do
62
	if [ -f "$script" -a -x "$script" ]
63
	then
64
		$script
65
	fi
66
done
(14-14/81)