diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2011-01-05 16:44:30 -0500 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2011-01-05 16:44:30 -0500 |
commit | 9b1936193f0adfda87b060a5fb19270232f169a5 (patch) | |
tree | 878b3f1dfc93ab0a1524a0fe53eb53d96255482f | |
parent | fe868e1d9d6fafc323356ab3422a00d415756e6b (diff) | |
download | pfsense-9b1936193f0adfda87b060a5fb19270232f169a5.zip pfsense-9b1936193f0adfda87b060a5fb19270232f169a5.tar.gz |
Reinstall packages on bootup during console. Ticket #1156
-rw-r--r-- | etc/inc/pkg-utils.inc | 22 | ||||
-rwxr-xr-x | etc/rc.bootup | 12 |
2 files changed, 33 insertions, 1 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index 708b897..8dc8ae4 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -1096,4 +1096,26 @@ function squash_from_bytes($size, $round = "") { return; } +function pkg_reinstall_all() { + global $g, $config; + $pkg_id = 0; + $todo = array(); + if ($config['installedpackages']['package']) + exec("rm -rf /var/db/pkg/*"); + if (is_array($config['installedpackages']['package'])) + foreach($config['installedpackages']['package'] as $package) + $todo[] = array('name' => $package['name'], 'version' => $package['version']); + echo "One moment please, reinstalling packages...\n"; + if(is_array($todo)) { + foreach($todo as $pkgtodo) { + $static_output = ""; + if($pkgtodo['name']) { + uninstall_package($pkgtodo['name']); + install_package($pkgtodo['name']); + $pkg_id++; + } + } + } +} + ?>
\ No newline at end of file diff --git a/etc/rc.bootup b/etc/rc.bootup index fe1faa3..047f4ef 100755 --- a/etc/rc.bootup +++ b/etc/rc.bootup @@ -381,6 +381,16 @@ activate_powerd(); if (file_exists("/sbin/shutdown.old")) @unlink("/sbin/shutdown.old"); +/* Resync / Reinstall packages if need be */ +if(file_exists('/conf/needs_package_sync')) { + if($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) { + if($g['platform'] == "pfSense" || $g['platform'] == "nanobsd") { + pkg_reinstall_all(); + unlink('/conf/needs_package_sync'); + } + } +} + /* done */ unset($g['booting']); @@ -388,4 +398,4 @@ led_normalize(); conf_mount_ro(); -?> +?>
\ No newline at end of file |