1 |
0c48d845
|
Scott Ullrich
|
#!/bin/sh
|
2 |
ac24dc24
|
Renato Botelho
|
#
|
3 |
|
|
# pfSense-rc.shutdown
|
4 |
|
|
#
|
5 |
|
|
# part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
# Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
# Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
8f2f85c3
|
Luiz Otavio O Souza
|
# Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
|
9 |
ac24dc24
|
Renato Botelho
|
# All rights reserved.
|
10 |
|
|
#
|
11 |
b12ea3fb
|
Renato Botelho
|
# 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 |
ac24dc24
|
Renato Botelho
|
#
|
15 |
b12ea3fb
|
Renato Botelho
|
# http://www.apache.org/licenses/LICENSE-2.0
|
16 |
ac24dc24
|
Renato Botelho
|
#
|
17 |
b12ea3fb
|
Renato Botelho
|
# 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 |
5b237745
|
Scott Ullrich
|
|
23 |
7201ca27
|
jim-p
|
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 |
6995b4fc
|
Scott Ullrich
|
exit -1
|
26 |
|
|
fi
|
27 |
|
|
|
28 |
573ec19d
|
Renato Botelho do Couto
|
# Read product_label from $g, defaults to pfSense
|
29 |
|
|
product_label=$(/usr/local/sbin/read_global_var product_label pfSense)
|
30 |
e173dd74
|
Phil Davis
|
|
31 |
153c8601
|
Scott Ullrich
|
echo
|
32 |
573ec19d
|
Renato Botelho do Couto
|
echo "${product_label} is now shutting down ..."
|
33 |
153c8601
|
Scott Ullrich
|
echo
|
34 |
|
|
|
35 |
0c48d845
|
Scott Ullrich
|
stty status '^T'
|
36 |
5b237745
|
Scott Ullrich
|
|
37 |
|
|
# Set shell to ignore SIGINT (2), but not children;
|
38 |
0c48d845
|
Scott Ullrich
|
trap : 2
|
39 |
5b237745
|
Scott Ullrich
|
|
40 |
0c48d845
|
Scott Ullrich
|
HOME=/; export HOME
|
41 |
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
42 |
|
|
export PATH
|
43 |
5b237745
|
Scott Ullrich
|
|
44 |
dc61252a
|
Renato Botelho
|
# Remove temporary files on shutdown from /tmp/
|
45 |
|
|
find -x /tmp/* -type f -exec rm -f {} \; >/dev/null 2>&1
|
46 |
e92e83d4
|
jim-p
|
|
47 |
82bf21fc
|
jim-p
|
. /etc/rc.ramdisk_functions.sh
|
48 |
|
|
ramdisk_make_backup
|
49 |
902cbde8
|
Denny Page
|
|
50 |
|
|
# Invoke shutdown scripts if present
|
51 |
|
|
scripts=/usr/local/etc/rc.d/shutdown.*.sh
|
52 |
|
|
for script in $scripts
|
53 |
|
|
do
|
54 |
|
|
if [ -f "$script" -a -x "$script" ]
|
55 |
|
|
then
|
56 |
|
|
$script
|
57 |
|
|
fi
|
58 |
|
|
done
|