Project

General

Profile

Download (1.71 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php-cgi -f
2
<?php
3
/*
4
 * rc.package_reinstall_all
5
 *
6
 * Copyright (c) 2018-2020 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21

    
22
require_once("util.inc");
23
require_once("notices.inc");
24
require_once("pkg-utils.inc");
25

    
26
$ntries = 1;
27
$max_tries = 5;
28

    
29
mark_subsystem_dirty('packagelock');
30

    
31
/* If it's still booting, give it a few seconds before start */
32
if (platform_booting()) {
33
	sleep(5);
34
}
35

    
36
while($ntries <= $max_tries) {
37
	if (package_reinstall_all()) {
38
		break;
39
	}
40
	log_error("Attempt #{$ntries} to reinstall packages FAILED.");
41
	$ntries++;
42
}
43

    
44
unlink_if_exists("{$g['conf_path']}/needs_package_sync");
45

    
46
if ($ntries > $max_tries) {
47
	file_notice(gettext("Package reinstall"), gettext("Package reinstall " .
48
	    "process was ABORTED due to lack of internet connectivity"));
49
} else {
50
	file_notice(gettext("Package reinstall"), gettext("Package reinstall " .
51
	    "process finished successfully"));
52
	mwexec_bg("{$g['etc_path']}/rc.start_packages");
53
}
54

    
55
/* Detect installed binary pkgs that are not registered in the system */
56
register_all_installed_packages();
57
clear_subsystem_dirty('packagelock');
58

    
59
if ($ntries <= $max_tries) {
60
	mwexec_bg("/etc/rc.filter_configure_sync");
61
}
(59-59/82)