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