Project

General

Profile

Download (1.51 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2
#
3
# rc.update_pkg_metadata
4
#
5
# Copyright (c) 2017-2020 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/bin/php -r 'require_once("pkg-utils.inc");update_repos();' \
35
	&& /usr/local/sbin/${product_name}-upgrade -uf \
36
	&& ( \
37
		/usr/local/sbin/${product_name}-upgrade -Uc > ${tmp_version}.tmp \
38
		; rc=$? \
39
		; tail -n 1 ${tmp_version}.tmp > $tmp_version \
40
		; rm -f ${tmp_version}.tmp \
41
		; echo $rc > ${tmp_version}.rc \
42
		; test $rc -eq 2 && return 0 || return $rc \
43
	) \
44
	&& ( \
45
		mv $tmp_version /var/run/${product_name}_version \
46
		&& mv ${tmp_version}.rc /var/run/${product_name}_version.rc \
47
	) || rm -f $tmp_version ${tmp_version}.rc
48
) >/dev/null 2>&1 &
49

    
50
exit 0
(79-79/82)