-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup-system
executable file
·153 lines (128 loc) · 4.28 KB
/
setup-system
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
set -e
##### Basic initialization #####
if [[ `id -u` != 0 ]]; then
echo "You MUST run this script as root."
exit 1
fi
if [[ -e /etc/vagrant_box_build_time ]]; then
in_vagrant=true
else
in_vagrant=false
dir=`dirname "$0"`
cd "$dir"
if "`pwd`" != /srv/passenger_autobuilder/appv5; then
echo "passenger_autobuilder MUST be located in /srv/passenger_autobuilder/appv5."
exit 1
fi
fi
##### Functions #####
function run()
{
echo "# $@"
"$@"
}
function create_user()
{
local name="$1"
local full_name="$2"
local id="$3"
echo "Creating group: $name"
create_group $name $id
if ! grep -q "^$name:" /etc/passwd; then
run adduser --uid $id --gid $id --disabled-password --gecos "$full_name" $name
fi
run usermod -L $name
}
function create_group()
{
local name="$1"
local id="$2"
if ! grep -q "^$name:" /etc/group >/dev/null; then
run addgroup --gid $id $name
fi
}
##### Main script #####
echo " --> Entering /srv/passenger_autobuilder"
cd /srv/passenger_autobuilder
umask u=rwx,g=rwx,o=rx
echo " --> Creating users, directories and files"
create_user psg_autobuilder "Passenger Autobuilder" 2456
create_user psg_autobuilder_chroot "Passenger Autobuilder Chroot" 2457
create_user psg_autobuilder_run "Passenger Autobuilder Run" 2458
create_group passenger_ci 2450
run chown root: /srv/passenger_autobuilder
run chmod g-w,o-w /srv/passenger_autobuilder
run usermod -a -G passenger_ci psg_autobuilder_run
run mkdir -p /var/cache/passenger_ci
run touch /var/cache/passenger_ci/lock
run chown -R root:passenger_ci /var/cache/passenger_ci
run chmod 770 /var/cache/passenger_ci
run chmod 660 /var/cache/passenger_ci/lock
run mkdir -p output repos images run config
run mkdir -p ccache ccache/pbuilder ccache/psg_autobuilder_chroot
run chown -R psg_autobuilder_chroot:psg_autobuilder_chroot repos ccache/psg_autobuilder_chroot
run chown -R psg_autobuilder_chroot:psg_autobuilder_run output
run chown -R psg_autobuilder_run:psg_autobuilder_chroot run
run chown psg_autobuilder_run:psg_autobuilder_chroot config
run chmod o-rx ccache/pbuilder ccache/psg_autobuilder_chroot repos
run chmod u=rwx,g=rwxs,o=x output
run chmod 770 run
run chmod u=rwx,g=x,o= config
run touch run/sync_to_s3.lock
run chown psg_autobuilder_run:psg_autobuilder_chroot run/sync_to_s3.lock
run chmod u=rw,g=rw,o= run/sync_to_s3.lock
if ! $is_vagrant; then
run chown -R psg_autobuilder:psg_autobuilder app
run chmod 755 app
fi
echo " --> Adding third-party APT repositories"
echo "Installing Jenkins public key"
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
echo "Adding Jenkins APT repository"
echo deb http://pkg.jenkins-ci.org/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
echo " --> Installing dependencies"
run apt-get update
run apt-get install -y ubuntu-dev-tools pbuilder runit sudo s3cmd gnupg jenkins
echo " --> Configuring system"
run usermod -a -G passenger_ci jenkins
run cp appv5/sudoers.conf /etc/sudoers.d/passenger_autobuilder
run chown root: /etc/sudoers.d/passenger_autobuilder
run chmod 440 /etc/sudoers.d/passenger_autobuilder
if ! $in_vagrant; then
if [[ ! -e config/signing ]] && tty -s; then
run cp appv5/config.example/signing config/signing
run nano config/signing
fi
if [[ ! -e config/s3 ]] && tty -s; then
run cp appv5/config.example/s3 config/s3
run nano config/s3
fi
else
if ! sudo -H -u psg_autobuilder_run gpg --list-keys | grep -q Vagrant; then
run sudo -H -u psg_autobuilder_run gpg --import /srv/passenger_autobuilder/appv5/dev/vagrant-gpg-key.asc
fi
run sudo -H -u psg_autobuilder_run gpg --import-ownertrust <<EOF
# List of assigned trustvalues, created Mon 29 Sep 2014 10:13:25 AM UTC
# (Use "gpg --import-ownertrust" to restore them)
8A926F06B0051E4DD9EE9C8B92315E32E0939C0A:6:
EOF
if [[ ! -e config/signing ]]; then
run cp appv5/config.example/signing.vagrant config/signing
fi
fi
run chown psg_autobuilder_run:psg_autobuilder_run config/signing
run chmod 600 config/signing
if [[ -e config/s3 ]]; then
run chown psg_autobuilder_run:psg_autobuilder_chroot config/s3
run chmod 640 config/s3
fi
echo "--------------"
echo "Setup finished."
echo
if [[ ! -e images/lucid-amd64.tgz ]]; then
echo "**** WARNING: you haven't setup any images yet. Please set them up by running:"
echo
echo " sudo /srv/passenger_autobuilder/appv5/setup-images"
echo
fi