Project

General

Profile

Download (1.69 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
 *
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

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

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

    
28
mark_subsystem_dirty('packagelock');
29

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

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

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

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

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

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