Project

General

Profile

Download (3.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/*   cvs_sync
2
 *   Written by Scott Ullrich
3
 *   (C)2005 Scott Ullrich
4
 *   Part of the pfSense project
5
 *   For users of cvs accounts to keep your test machine up to date
6
 */
7

    
8
function create_supfile($branch) {
9

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

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

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

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

    
29
if(!file_exists("/usr/local/bin/cvsup")) {
30
	echo "Cannot find cvsup, pkg_add in progress...";
31
	system("/usr/sbin/pkg_add -r http://www.pfsense.com/packages/All/cvsup-without-gui-16.1h_2.tbz");
32
}
33

    
34
if(!file_exists("/usr/bin/cvs")) {
35
	echo "Cannot find cvs, fetching static cvs...";
36
	system("fetch -o /usr/bin/cvs http://www.pfsense.com/~sullrich/extra/cvs");
37
	system("chmod a+rx /usr/bin/cvs");
38
}
39

    
40
global $argv;
41

    
42
if(!$argv[3]) {
43
	echo "\nPlease select which branch you would like:\n\n";
44
	echo "RELENG_1_2  - 1.2 Release branch\n";
45
	echo "RELENG_1    - 1.3 branch\n";
46
	echo "HEAD        - Main development branch\n";
47
	
48
	$branch = readline("\n> ");
49
} else {
50
	$branch = $argv[3];
51
}
52

    
53
create_supfile($branch);
54

    
55
$CODIR =  "/home/pfsense/$branch";
56

    
57
exec("mkdir -p /home/pfsense/$BRANCHTAG");
58

    
59
$branches = array("HEAD","RELENG_1","RELENG_1_2");
60

    
61
if (!in_array("$branch", $branches)) {
62
	echo "Invalid branch.\n";
63
	exit;
64
}
65

    
66
echo "===> Checking out $branch\n";
67
exec("mkdir -p /home/pfsense/$branch");
68
system("cvsup /var/etc/pfSense-supfile");
69
exec("rm -rf /usr/local/www/includes/*");
70
exec("rm -rf /usr/local/www/javascript/*");
71
exec("find /usr/local/www -name \"*.js\" -exec rm {} \;");
72

    
73
exec("mkdir -p /tmp/lighttpd/cache/compress/");
74

    
75
exec("cd ${CODIR}/ && find . -name CVS -exec rm -rf {} \; 2>/dev/null");
76
exec("cd ${CODIR}/ && find . -name pfSense.tgz -exec rm {} \; 2>/dev/null");
77
exec("rm -rf ${CODIR}/conf*");
78
exec("rm ${CODIR}/pfSense/usr/local/www/trigger_initial_wizard 2>/dev/null");
79
exec("rm ${CODIR}/pfSense/etc/crontab 2>/dev/null");
80
exec("rm ${CODIR}/pfSense/etc/master.passwd 2>/dev/null");
81
exec("rm ${CODIR}/pfSense/etc/passwd 2>/dev/null");
82
exec("rm ${CODIR}/pfSense/etc/fstab 2>/dev/null");
83
exec("rm ${CODIR}/pfSense/etc/ttys 2>/dev/null");
84
exec("rm ${CODIR}/pfSense/etc/group 2>/dev/null");
85
exec("rm ${CODIR}/pfSense/etc/fstab 2>/dev/null");
86
exec("rm ${CODIR}/pfSense/boot/device.hints 2>/dev/null");
87
exec("rm ${CODIR}/pfSense/boot/loader.conf 2>/dev/null");
88
exec("rm ${CODIR}/pfSense/boot/loader.rc 2>/dev/null");
89
exec("rm -rf ${CODIR}/pfSense/conf/ 2>/dev/null");
90
exec("rm -rf ${CODIR}/pfSense/cf/ 2>/dev/null");
91
exec("rm -rf ${CODIR}/pfSense/root/.shrc");
92
exec("rm -rf ${CODIR}/pfSense/root/.tcshrc");
93

    
94
echo "Installing new files...\n";
95

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

    
98
echo "CVS Sync Complete\n";
99

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

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

    
105
echo "Upgrading configuration...\n";
106

    
107
convert_config();
108
/* setup php.ini */
109
convert_config();
110
sync_webgui_passwords();
111

    
112
echo "Restarting check_reload_status...\n";
113
exec("killall check_reload_status");
114
mwexec_bg("nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status");
115

    
116
echo "Configuring filter...";
117
exec("/etc/rc.filter_configure_sync");
118
exec("pfctl -f /tmp/rules.debug");
119
echo "\n";
120

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

    
123
exec("killall php");
124
touch("/tmp/restart_webgui");
125

    
(1-1/3)