1 |
e506cc8a
|
Renato Botelho
|
#!/bin/sh
|
2 |
|
|
#
|
3 |
|
|
# rc.update_pkg_metadata
|
4 |
|
|
#
|
5 |
|
|
# Copyright (c) 2017 Rubicon Communications, LLC (Netgate). All rights reserved.
|
6 |
|
|
#
|
7 |
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
8 |
|
|
# you may not use this file except in compliance with the License.
|
9 |
|
|
# You may obtain a copy of the License at
|
10 |
|
|
#
|
11 |
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
12 |
|
|
#
|
13 |
|
|
# Unless required by applicable law or agreed to in writing, software
|
14 |
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
15 |
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16 |
|
|
# See the License for the specific language governing permissions and
|
17 |
|
|
# limitations under the License.
|
18 |
|
|
|
19 |
|
|
if [ "$1" = "now" ]; then
|
20 |
|
|
sleep_time=0
|
21 |
|
|
else
|
22 |
|
|
sleep_time=$(jot -r 1 1 86399)
|
23 |
|
|
fi
|
24 |
|
|
|
25 |
|
|
# Read product_name from $g, defaults to pfSense
|
26 |
|
|
product=$(/usr/local/sbin/read_global_var product_name pfSense)
|
27 |
|
|
|
28 |
|
|
tmp_version=$(mktemp -q /tmp/${product}_version.XXXXXXXX) \
|
29 |
|
|
|| exit 1
|
30 |
|
|
|
31 |
|
|
( \
|
32 |
|
|
sleep $sleep_time \
|
33 |
|
|
&& /usr/local/sbin/${product}-upgrade -uf \
|
34 |
|
|
&& ( \
|
35 |
987865d1
|
Renato Botelho
|
/usr/local/sbin/${product}-upgrade -Uc > ${tmp_version}.tmp \
|
36 |
ca773220
|
Renato Botelho
|
; rc=$? \
|
37 |
987865d1
|
Renato Botelho
|
; tail -n 1 ${tmp_version}.tmp > $tmp_version \
|
38 |
|
|
; rm -f ${tmp_version}.tmp \
|
39 |
ca773220
|
Renato Botelho
|
; echo $rc > ${tmp_version}.rc \
|
40 |
|
|
; test $rc -eq 2 && return 0 || return $rc \
|
41 |
e506cc8a
|
Renato Botelho
|
) \
|
42 |
ca773220
|
Renato Botelho
|
&& ( \
|
43 |
|
|
mv $tmp_version /var/run/${product}_version \
|
44 |
|
|
&& mv ${tmp_version}.rc /var/run/${product}_version.rc \
|
45 |
|
|
) || rm -f $tmp_version ${tmp_version}.rc
|
46 |
e506cc8a
|
Renato Botelho
|
) >/dev/null 2>&1 &
|
47 |
|
|
|
48 |
|
|
exit 0
|