File: create_sbox_bootstrap_copy

package info (click to toggle)
dtc 0.35.5-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 18,824 kB
  • sloc: php: 50,739; sh: 8,596; makefile: 572; perl: 148; xml: 25
file content (79 lines) | stat: -rwxr-xr-x 1,926 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh

# copy_path
sbox_copy_disk_path=/var/lib/dtc/sbox_copy

usage () {
	echo "Usage: ${0} [debian-repository]"
	exit 1
}

if [ $# -gt 1 ] ; then
	usage
fi

if [ $# = 1 ] ; then
	DEBIAN_REPOSITORY=${1}
else
	DEBIAN_REPOSITORY="http://cdn.debian.net/debian"
fi

FOUNDED_ARCH=`uname -m`

case "$FOUNDED_ARCH" in
i386)
	DEBIAN_BINARCH=i386
	CENTOS_BINARCH=i386
;;
i436)
	DEBIAN_BINARCH=i386
	CENTOS_BINARCH=i386
;;
i586)
	DEBIAN_BINARCH=i386
	CENTOS_BINARCH=i386
;;
i686)
	DEBIAN_BINARCH=i386
	CENTOS_BINARCH=i386
;;
x86_64)
	DEBIAN_BINARCH=amd64
	CENTOS_BINARCH=x86_64
;;
*)
echo "Unrecognized arch: exiting!"
	exit 1
;;
esac


# If we are on a Debian system, let's bootstrap the current stable
if [ -f /etc/debian_version ] ; then
	mkdir -p /var/lib/dtc/sbox_copy
	RELEASE=`lsb_release -c | awk '{print $2}'`
	debootstrap --verbose --include=php5-cgi,locales-all --arch ${DEBIAN_BINARCH} ${RELEASE} ${sbox_copy_disk_path} ${DEBIAN_REPOSITORY} || debret=$?
	if [ "$debret" != "" ]; then
		echo "create_sbox_bootstrap_copy: Failed to debootstrap"
		exit 1
	else
		cp /etc/apt/sources.list ${sbox_copy_disk_path}/etc/apt/
	fi
	# Some stuff on the target php.ini:
	if [ -f ${sbox_copy_disk_path}/etc/php5/cgi-bin/php.ini ] ; then
		# doc_root=/var/www
		if grep "^doc_root =$" ${sbox_copy_disk_path}/etc/php5/cgi/php.ini ; then
			sed -i "s/doc_root =/doc_root = \/var\/www/" ${sbox_copy_disk_path}/etc/php5/cgi-bin/php.ini
		fi
		if grep "^; cgi.force_redirect = 1$" ${sbox_copy_disk_path}/etc/php5/cgi/php.ini ; then
			sed -i "s/; cgi.force_redirect = 1/cgi.force_redirect = 0" ${sbox_copy_disk_path}/etc/php5/cgi-bin/php.ini
		fi
		if grep "^; cgi.fix_pathinfo=0$" ${sbox_copy_disk_path}/etc/php5/cgi/php.ini ; then
			sed -i "s/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=1/" ${sbox_copy_disk_path}/etc/php5/cgi-bin/php.ini
		fi
	fi
	# cgi.force_redirect=0
else
	echo "Currently only supported in Debian: sorry..."
	exit 1
fi