#!/usr/bin/perl

# During install, we're going to end up installing two prefpanes:
# SharingPref.prefPane in the usual spot (for Panther) and
# ARDPref.prefPane (for 10.2.) hidden inside the app.

# Now, on 10.2, we always want to keep the original SharingPref file, and on 
# 10.3, we want to keep the later version. So in order to do these things,
# we need to move aside SharingPref.prefPane during preflight, allow install
# to place stuff, then adjudicate later.

# There's also a file called /System/Library/PrivateFrameworks/NetworkConfig.framework/Resources/DefaultFirewallInfo.plist
# We need to make a copy somewhere, and if we're Panther and we're NOT updating
# SharingPref, we need to move this file back, stomping over the one we just installed.

use File::Spec;
use File::Path;

my $TARGET			= $ARGV[2];
my $SHARING_PREFS		= File::Spec->canonpath($TARGET . "/System/Library/PreferencePanes/SharingPref.prefPane/");
my $TEMP_SHARING_PREFS	= File::Spec->canonpath($TARGET . "/System/Library/PreferencePanes/SharingPref.tempSave/");

my $DEFAULT_FW			= File::Spec->canonpath($TARGET . "/System/Library/PrivateFrameworks/NetworkConfig.framework/Resources/DefaultFirewallInfo.plist");
my $TEMP_DEFAULT_FW		= File::Spec->canonpath($TARGET . "/System/Library/PrivateFrameworks/NetworkConfig.framework/Resources/DefaultFirewallInfo.tempSave");


print "/bin/mv " . $SHARING_PREFS . " " . $TEMP_SHARING_PREFS . "\n";
system( "/bin/mv",
		$SHARING_PREFS,
		$TEMP_SHARING_PREFS
		);

print "/bin/mv " . $DEFAULT_FW . " " . $TEMP_DEFAULT_FW . "\n";
system( "/bin/mv",
		$DEFAULT_FW,
		$TEMP_DEFAULT_FW
		);

exit(0);
