Project

General

Profile

Download (3.89 KB) Statistics
| Branch: | Tag: | Revision:
1
/*   cvs_sync
2
 *   Written by Scott Ullrich
3
 *   (C)2005-2007 Scott Ullrich
4
 *   Part of the pfSense project pfSsh.php subsystem
5
 */
6

    
7
function create_supfile($branch) {
8

    
9
	if($branch == "HEAD") 
10
		$BRANCHTAG = ".";
11
	else
12
		$BRANCHTAG = $branch;
13

    
14
	$supfile = "
15
*default host=cvs.pfsense.com
16
*default base=/home/pfsense/$branch
17
*default release=cvs tag=$BRANCHTAG
18
*default delete use-rel-suffix
19
pfSense
20
*default compress
21
";
22

    
23
	file_put_contents("/var/etc/pfSense-supfile", $supfile);
24
}
25

    
26
unlink_if_exists("/tmp/config.cache");
27

    
28
if(!file_exists("/usr/local/bin/cvsup")) {
29
	echo "Cannot find cvsup, pkg_add in progress...";
30
	system("/usr/sbin/pkg_add -r cvsup-without-gui");
31
}
32

    
33
if(!file_exists("/usr/bin/cvs")) {
34
	echo "Cannot find cvs, fetching static cvs...";
35
	system("fetch -o /usr/bin/cvs http://files.pfsense.org/extras/7/cvs");
36
	system("chmod a+rx /usr/bin/cvs");
37
}
38

    
39
if(!file_exists("/usr/bin/cvs") or !file_exists("/usr/local/bin/cvsup")) {
40
	echo "Could not fetch cvs or cvsup.   exiting.";
41
	exit;
42
}
43

    
44
global $argv;
45
global $command_split;
46

    
47
/* NOTE: Set branches here */
48
$branches = array("HEAD" => "Main development branch",
49
				  "RELENG_1" => "1.3 development branch",
50
				  "RELENG_1_2" => "1.2 release branch");
51

    
52
if($command_split[2]) {
53
	$branch = $command_split[2];
54
} else {
55
	if(!$argv[3]) {
56
		echo "\nPlease select which branch you would like:\n\n";
57
		foreach($branches as $branchname => $branchdesc) {
58
			echo "{$branchname} - {$branchdesc}\n";
59
		}
60
		$branch = readline("\n> ");
61
		echo "\n";
62
	} else {
63
		$branch = $argv[3];
64
	}
65
}
66
create_supfile($branch);
67

    
68
$CODIR =  "/home/pfsense/$branch";
69

    
70
exec("mkdir -p /home/pfsense/$BRANCHTAG");
71

    
72
$found = false;
73
foreach($branches as $branchname => $branchdesc) {
74
	if($branchname == $branch) 
75
		$found = true;
76
}
77
if(!$found) {
78
	echo "\nInvalid branch.\n";
79
	exit;
80
}
81

    
82
echo "===> Checking out $branch\n";
83
exec("mkdir -p /home/pfsense/$branch");
84
system("cvsup /var/etc/pfSense-supfile");
85
exec("rm -rf /usr/local/www/includes/*");
86
exec("rm -rf /usr/local/www/javascript/*");
87
exec("find /usr/local/www -name \"*.js\" -exec rm {} \;");
88

    
89
exec("mkdir -p /tmp/lighttpd/cache/compress/");
90

    
91
exec("cd ${CODIR}/ && find . -name CVS -exec rm -rf {} \; 2>/dev/null");
92
exec("cd ${CODIR}/ && find . -name pfSense.tgz -exec rm {} \; 2>/dev/null");
93
exec("rm -rf ${CODIR}/conf*");
94
exec("rm ${CODIR}/pfSense/usr/local/www/trigger_initial_wizard 2>/dev/null");
95
exec("rm ${CODIR}/pfSense/etc/crontab 2>/dev/null");
96
exec("rm ${CODIR}/pfSense/etc/master.passwd 2>/dev/null");
97
exec("rm ${CODIR}/pfSense/etc/passwd 2>/dev/null");
98
exec("rm ${CODIR}/pfSense/etc/fstab 2>/dev/null");
99
exec("rm ${CODIR}/pfSense/etc/ttys 2>/dev/null");
100
exec("rm ${CODIR}/pfSense/etc/group 2>/dev/null");
101
exec("rm ${CODIR}/pfSense/etc/fstab 2>/dev/null");
102
exec("rm ${CODIR}/pfSense/boot/device.hints 2>/dev/null");
103
exec("rm ${CODIR}/pfSense/boot/loader.conf 2>/dev/null");
104
exec("rm ${CODIR}/pfSense/boot/loader.rc 2>/dev/null");
105
exec("rm -rf ${CODIR}/pfSense/conf/ 2>/dev/null");
106
exec("rm -rf ${CODIR}/pfSense/cf/ 2>/dev/null");
107
exec("rm -rf ${CODIR}/pfSense/root/.shrc");
108
exec("rm -rf ${CODIR}/pfSense/root/.tcshrc");
109
exec("rm -f ${CODIR}/pfSense/etc/syslog.conf 2>/dev/null");
110

    
111
echo "Installing new files...\n";
112

    
113
exec("cd $CODIR/pfSense ; tar -cpf - . | (cd / ; tar -Uxpf -)");
114

    
115
echo "CVS Sync Complete\n";
116

    
117
echo "Removing FAST-CGI temporary files...\n";
118
exec("find /tmp -name \"*php*\" -exec rm -rf {} \;");
119

    
120
exec("rm -rf /tmp/xcache/* 2>/dev/null");
121

    
122
echo "Upgrading configuration...\n";
123

    
124
convert_config();
125
/* setup php.ini */
126
convert_config();
127
sync_webgui_passwords();
128

    
129
echo "Restarting check_reload_status...\n";
130
exec("killall check_reload_status");
131
mwexec_bg("nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status");
132

    
133
echo "Configuring filter...";
134
exec("/etc/rc.filter_configure_sync");
135
exec("pfctl -f /tmp/rules.debug");
136
echo "\n";
137

    
138
echo "===> Checkout complete.  Your system is now sync'd.  Scripting terminating.\n";
139

    
140
touch("/tmp/restart_webgui");
141

    
142
exec("killall php");
143

    
(1-1/4)