Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# rc.update_pkg_metadata
4
#
5
# Copyright (c) 2017-2024 Rubicon Communications, LLC (Netgate)
6
# All rights reserved.
7
#
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
product_name="$(/usr/local/sbin/read_global_var product_name pfSense)"
28

    
29
tmp_version="$(mktemp -q "/tmp/${product_name}_version.XXXXXXXX")" \
30
	|| exit 1
31

    
32
( \
33
	sleep "${sleep_time}" \
34
	&& "/usr/local/sbin/${product_name}-upgrade" -uf \
35
	&& ( \
36
		"/usr/local/sbin/${product_name}-upgrade" -C > "${tmp_version}.tmp" \
37
		; 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
	) \
43
	&& ( \
44
		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
) >/dev/null 2>&1 &
48

    
49
exit 0
(82-82/85)