1 |
e506cc8a
|
Renato Botelho
|
#!/bin/sh
|
2 |
|
|
#
|
3 |
|
|
# rc.update_pkg_metadata
|
4 |
|
|
#
|
5 |
37d60e23
|
Luiz Souza
|
# Copyright (c) 2017-2025 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 |
71f43603
|
Luiz Souza
|
if [ "${1}" = "now" ]; then
|
21 |
|
|
sleep_time="0"
|
22 |
e506cc8a
|
Renato Botelho
|
else
|
23 |
71f43603
|
Luiz Souza
|
sleep_time="$(jot -r 1 1 86399)"
|
24 |
e506cc8a
|
Renato Botelho
|
fi
|
25 |
|
|
|
26 |
|
|
# Read product_name from $g, defaults to pfSense
|
27 |
71f43603
|
Luiz Souza
|
product_name="$(/usr/local/sbin/read_global_var product_name pfSense)"
|
28 |
e506cc8a
|
Renato Botelho
|
|
29 |
71f43603
|
Luiz Souza
|
tmp_version="$(mktemp -q "/tmp/${product_name}_version.XXXXXXXX")" \
|
30 |
e506cc8a
|
Renato Botelho
|
|| exit 1
|
31 |
|
|
|
32 |
|
|
( \
|
33 |
71f43603
|
Luiz Souza
|
sleep "${sleep_time}" \
|
34 |
|
|
&& "/usr/local/sbin/${product_name}-upgrade" -uf \
|
35 |
e506cc8a
|
Renato Botelho
|
&& ( \
|
36 |
b282c329
|
Luiz Souza
|
"/usr/local/sbin/${product_name}-upgrade" -C > "${tmp_version}.tmp" \
|
37 |
71f43603
|
Luiz Souza
|
; rc="${?}" \
|
38 |
|
|
; tail -n 1 "${tmp_version}.tmp" > "${tmp_version}" \
|
39 |
|
|
; rm -f "${tmp_version}.tmp" \
|
40 |
|
|
; echo "${rc}" > "${tmp_version}.rc" \
|
41 |
|
|
; test "${rc}" -eq 2 && return 0 || return "${rc}" \
|
42 |
e506cc8a
|
Renato Botelho
|
) \
|
43 |
ca773220
|
Renato Botelho
|
&& ( \
|
44 |
71f43603
|
Luiz Souza
|
mv "${tmp_version}" "/var/run/${product_name}_version" \
|
45 |
|
|
&& mv "${tmp_version}.rc" "/var/run/${product_name}_version.rc" \
|
46 |
|
|
) || rm -f "${tmp_version}" "${tmp_version}.rc"
|
47 |
e506cc8a
|
Renato Botelho
|
) >/dev/null 2>&1 &
|
48 |
|
|
|
49 |
|
|
exit 0
|