summaryrefslogtreecommitdiff
path: root/continuous_integration/debian_stretch_setup.mdwn
blob: c20abee076139f9710eb8fab04fc03ea63b30869 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
[[!meta title="Continuous Integration Debian Stretch Setup"]]
[[!meta author="Kyllikki"]]
[[!meta date="2017-05-28T12:46:14Z"]]


[[!toc]]

## Debian 9 (Stretch) OS install

### amd64 VDS install from media

[[Virtual server setup|virtual_host_server]]

Install minimal system from netinst CD (attached when VDS is created on
phoenix) Config options:

-   In the "role" selection select "ssh server" and "system utilities" only.
-   The whole disc default partitioning is fine
-   The base user the install insists on creating should be the netsurf user.
-   Boot loader in MBR

Once installed:

-   install sudo package and add netsurf user to sudo group
-   edit /etc/default/grub

`GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"`

`# update-grub2`

### arm64 VDS install

[[ARM64 virtual server setup|virtual_host_server_arm64]]

Once installed:

-   create netsurf user
-   install sudo package and add netsurf user to sudo group
-   edit /etc/inittab comment pty 3 through 6 and uncomment serial T0
-   enable backports

`echo "deb `[`http://http.debian.net/debian`](http://http.debian.net/debian)` stretch-backports main" > /etc/apt/sources.list.d/backports.list`  
`apt-get update`

-   install updated kernel

`apt-get install linux-image-4.3.0-0.bpo.1-arm64`

### Scaleway node

Scaleway servers are currently used for ARM64 and armhf
workers. Although we have self-hosted hardware for both of these node
types these nodes are conveniant alternatives. For AMD64 workers
just create zero cost instances on phoenix!

Use the scaleway dashboard to create a server of the correct
architecture and Debian jessie image (it has to be upgraded currently)
a minimal 50G root volume is plenty of storage.

once started ssh to the image using the appropriate ssh key

`ssh -i .ssh/keys/id_rsa.netsurf root@1.2.3.4`

edit \etc\hostname to contain nsciworker17

edit \etc\hosts to set loopback name resolution

    127.0.1.1       nsciworker17
    127.0.0.1       localhost
    ::1             localhost ip6-localhost ip6-loopback
    ff02::1         ip6-allnodes
    ff02::2         ip6-allrouters
    
    192.168.211.1   ci.netsurf-browser.org
    93.93.129.191   vpn.netsurf-browser.org

`adduser netsurf`

ensure netsurf user has ssh key installed

edit /etc/group to add netsurf to sudo group

edit /etc/apt/sources/list to be stretch

    # apt-get update
    # apt-get dist-upgrade
    # apt-get clean
    # halt

use dashboard power toggle to force a hard reboot

login as netsurf and use `sudo -i` to get root terminal

something in the update appears to break journalctl

    # mkdir -p /var/log/journal
    # rm /etc/machine-id
    # systemd-machine-id-setup
    # systemd-tmpfiles --create --prefix /var/log/journal
    # service systemd-journald restart

edit /etc/ssh/sshd_config to disable password login. ensure you can login using certificates *before* you do this!

    # To disable tunneled clear text passwords, change to no here!
    PasswordAuthentication no

`# apt-get install fail2ban`

edit /etc/fail2ban/jail.local

    [DEFAULT]
    
    # "bantime" is the number of seconds that a host is banned.
    bantime  = 1200
    
    # A host is banned if it has generated "maxretry" during the last "findtime"
    # seconds.
    findtime = 1200
    maxretry = 3
    
    [ssh]
    
    enabled  = true
    port     = ssh
    filter   = sshd
    logpath  = /var/log/auth.log
    maxretry = 2
    

`# apt-get install openvpn`

create /etc/openvpn/netsurf.conf

    client
    dev tap_netsurf
    proto tcp
    remote vpn.netsurf-browser.org 1194
    resolv-retry infinite
    nobind
    user nobody
    group nogroup
    persist-key
    persist-tun
    lladdr 0E:00:00:00:03:17
    
    ca      /etc/openvpn/netsurf-keys/ca.crt
    cert    /etc/openvpn/netsurf-keys/ciworker17.crt
    key     /etc/openvpn/netsurf-keys/ciworker17.key
    
    ns-cert-type server
    
    comp-lzo
    
    # Set log file verbosity.
    verb 3
    
    script-security 2
    up /etc/openvpn/netsurf-up
    down /etc/openvpn/netsurf-down

create /etc/openvpn/netsurf-up

    #!/bin/sh
    
    ifup tap_netsurf

create /etc/openvpn/netsurf-down

    #!/bin/sh
    
    ifdown tap_netsurf

edit /etc/network/interfaces and add

    # netsurf
    auto tap_netsurf
    iface tap_netsurf inet dhcp

`mkdir /etc/openvpn/netsurf-keys`

copy openvpn keys from master node into /etc/openvpn/netsurf-keys

edit /etc/default/openvpn to have

    AUTOSTART="netsurf"

reload config and restart openvpn

    # systemctl daemon-reload
    # service restart openvpn
    # systemctl status openvpn@netsurf.service

### Banana Pi

This system is a dual core ARMv7 allwinner using the armhf ABI

Used the install SD media from
[[armbian|https://dl.armbian.com/bananapi/Debian_jessie_next.7z]]

-   unzip and write raw file to full size SD card.

Once installed:

-   first login as root:1234 which will need to be immediately changed
-   use the nand-sata-install script and moved the install to sata disc.
    The drive needs to be a clean drive with a recognised partition
    table (DOS or GPT) and a single partition where the OS will be
    installed.
-   edit /etc/init.d/armhwinfo to remove the toilet dynamic MOTD banner
-   (re)move /etc/bash.bashrc.custom as it issues a lot of unnecessary
    commands
-   adduser netsurf
-   change /etc/apt/sources.list to point at a local mirror
-   apt-get update
-   apt-get upgrade
-   install sudo package and add netsurf user to sudo group

### Raspberry Pi 2

This system is a quad core ARMv7 Broadcom using the armhf ABI

Used install media from [[http://sjoerd.luon.net/posts/2015/02/debian-stretch-on-rpi2/ Sjored|http///sjoerd.luon.net/posts/2015/02/debian-stretch-on-rpi2/_sjored]]

-   unpack onto micro SD card with bmap-tools

`On any debian-based linux type "sudo apt-get install bmap-tools" and install it.`  
`Then type "sudo bmaptool copy --nobmap 'yourlocation/stretch-rpi2.img' /dev/sdx" (Change yourlocation to the location of the .img file and sdx for the letter where the SD is mounted, if you don't know it type "sudo fdisk -l" and look for it).`

Once installed:

-   first login as root:debian which will need to be immediately changed
-   Prevent package FLASH-KERNEL UPDATING FROM OFFICIAL REPO WITH APT
    PINNING

`'touch /etc/apt/preferences.d/flash-kernel' create a new file`  
`'vi /etc/apt/preferences.d/flash-kernel' edit it an add the following lines to it:`  
`Package: flash-kernel`  
`Pin: origin repositories.collabora.co.uk`  
`Pin-Priority: 1000`  
`'apt-cache policy flash-kernel' check if the package is pinned`

-   change /etc/apt/sources.list to point at a local mirror
-   apt-get update
-   apt-get upgrade
-   adduser netsurf
-   install sudo package and add netsurf user to sudo group

### Orange Pi PC

This system is a quad core ARMv7 allwinner H3 using the armhf ABI

Use [[armbian||https://dl.armbian.com/orangepipc/Debian_jessie_default.7z]]

-   unpack image and write to micro SD card and configure as per banana pi
    instructions

Once installed:

-   first login as root:1234 which will need to be immediately changed

`* superuser available via sudo -i`

-   change /etc/apt/sources.list to point at a local mirror
-   apt-get update
-   apt-get upgrade
-   alter orangepi user to netsurf by editing

`/etc/group (dont forget to replace orangepi on the sudo group)`  
`/etc/passwd`  
`/etc/shadow`  
`mv /home/orangepi /home/netsurf`


## Packaged CI worker install

Do a base OS install

The recommended hostname for CI workers is "nsciworker17" this allows us
to clearly identify CI worker nodes. Note historically we have used
"cislave1" which has been objected to by several users. See
[[changing hostname|https://wiki.debian.org/howto/changehostname_changing_hostname]] on how to achive this.

On master jenkins use "manage nodes" to create new node. Ensure "remote
fs root" is set to /var/lib/jenkins add variable JENKINS\_HOME set to
/var/lib/jenkins

Note: replace arm64 with architecture name as required (armhf etc.)

When configuring a scaleway instance the "Launch method" should be set to "start and stop this node on-demand" with the "Start script" set to `perl /usr/bin/pscw.pl start netsurf-ciworker17` and "Stop script" set to `perl /usr/bin/pscw.pl stop netsurf-ciworker17`. The Availability set to "Take this slave on-line when in demand and off-line when idle" and "in demand delay" set to 0 and "idle delay" set to 15. This will mean the node is turned off and not charged for when idle.

As superuser:

-   create jenkins user

`adduser --system --group --home /var/lib/jenkins/ --disabled-login jenkins`

-   Add CI server repo to slave apt sources

`echo "deb `[`http://ci.netsurf-browser.org/debian/`](http://ci.netsurf-browser.org/debian/)` stretch/amd64/" >> /etc/apt/sources.list.d/netsurf-browser.list`

-   update repos

`apt-get update`

-   install ns-ci-worker package. accept the large package list and the
    unsigned package install for gcovr and ns-ci-slave

`apt-get install ns-ci-worker`

-   edit /etc/default/ns-ci-worker to set the correct url and secret parameters
-   ensure /opt is setup correctly to allow toolchains to be built on the node 

`mkdir -p /opt/netsurf`  
`chown jenkins:jenkins /opt/netsurf`

-   become jenkins user

`su -s/bin/bash - jenkins`

-   create ssh keypair (accept defaults - no password)

`ssh-keygen -t rsa -C "netsurf@nsciworker17.netsurf-browser.org"`

-   copy .ssh/id\_rsa.pub from worker to jenkins master node and append
    to /home/netsurf/.ssh/authorized\_keys

`scp /home/jenkins/.ssh/id_rsa.pub netsurf@ci.netsurf-browser.org:nsciworker17_id_rsa.pub`

-   exit jenkins user shell
-   start CI worker daemon

`/etc/init.d/ns-ci-worker start`



## Pbuilder setup

This allows a worker to build Debian packages. The worker should be
installed as a normal CI worker node and then:

as superuser on node:

    # apt-get install pbuilder
    # addgroup pbuilder
    # addgroup jenkins pbuilder

create /etc/sudoers.d/pbuilder

    jenkins  ALL = NOPASSWD:/usr/sbin/pbuilder

`visudo` and alter Defaults

`Defaults        env_reset,env_keep="DIST ARCH"`

replace /etc/pbuilderrc

    # this is your configuration file for pbuilder.
    # the file in /usr/share/pbuilder/pbuilderrc is the default template.
    # /etc/pbuilderrc is the one meant for overwriting defaults in
    # the default template
    #
    # read pbuilderrc.5 document for notes on specific options.
    
    # List of Debian suites.
    DEBIAN_SUITES=("sid", "stretch", "jessie", "wheezy", "squeeze")
    
    # List of Ubuntu suites.
    UBUNTU_SUITES=("vivid" "utopic" "trusty" "saucy" "raring" "quantal" "precise" "oneiric" "natty" "lucid" "hardy")
    
    # Mirrors to use. Update these to your preferred mirror.
    DEBIAN_MIRROR="ftp.uk.debian.org"
    UBUNTU_MIRROR="mirrors.kernel.org"
    
    # set a default distribution if none is used.
    : ${DIST:="$(lsb_release --short --codename)"}
    
    # set the architecture to the host architecture if none set.
    : ${ARCH:="$(dpkg --print-architecture)"}
    
    NAME="$DIST"
    if [ -n "${ARCH}" ]; then
        NAME="$NAME-$ARCH"
        DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")
    fi
    BASETGZ="/var/cache/pbuilder/$NAME-base.tgz"
    DISTRIBUTION="$DIST"
    BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
    APTCACHE="/var/cache/pbuilder/$NAME/aptcache/"
    BUILDPLACE="/var/cache/pbuilder/build/"
    
    if $(echo ${DEBIAN_SUITES[@]} | grep -q $DIST); then
        # Debian configuration
        MIRRORSITE="http://$DEBIAN_MIRROR/debian/"
        COMPONENTS="main contrib non-free"
        if $(echo "$STABLE_CODENAME stable" | grep -q $DIST); then
            OTHERMIRROR="$OTHERMIRROR | deb $MIRRORSITE $STABLE_BACKPORTS_SUITE $COMPONENTS"
        fi
    elif $(echo ${UBUNTU_SUITES[@]} | grep -q $DIST); then
        # Ubuntu configuration
        MIRRORSITE="http://$UBUNTU_MIRROR/ubuntu/"
        COMPONENTS="main restricted universe multiverse"
    else
        echo "Unknown distribution: $DIST"
        exit 1
    fi

The architecture is assumed to be the native one from

`dpkg --print-architecture`

This can be set by passing ARCH to pbuilder (useful for i386 maybe?)

for each distribution this node will build for:

create pbuilder result directory and set ownership permissions

    # mkdir -p /var/cache/pbuilder/stretch-armhf/result
    # chown root:pbuilder /var/cache/pbuilder/stretch-armhf/result
    # chmod g+w /var/cache/pbuilder/stretch-armhf/result

become jenkins user

`su -s/bin/bash - jenkins`

create pbuilder base for distribution

`sudo DIST=stretch pbuilder create`

if desired additional packages and config can be made to the base with

`sudo DIST=stretch pbuilder login --save-after-login`

## distcc worker node

Do a basic OS install but \*not\* a CI worker setup.

A recommended hostname for distcc worker is something like "cicpu0" this
allows us to use systems as processing node for other purposes than just
distcc in future. See debians
[[changing hostname|https://wiki.debian.org/howto/changehostname_changing_hostname]] on how to achive this.

The Netsurf repository has necessary updated packages in it and can be
accessed by doing the following:

Add CI server repo to worker apt sources

`echo "deb `[`http://ci.netsurf-browser.org/builds/debian/`](http://ci.netsurf-browser.org/builds/debian/)` stretch/amd64/" >> /etc/apt/sources.list`

update repos

`apt-get update`

use apt to install these packages:

`build-essential`  
`gcc`  
`clang`  
`distcc`

edit /etc/default/distcc

    STARTDISTCC="true"
    ALLOWEDNETS="192.168.211.0/24"
    LISTEN="0.0.0.0"
    JOBS="8"

start the service

`service distcc start`

ensure the client has hosts set to use the new worker



## Manual CI worker install

Caution these instructions may not be up to date.

### required packages

The Netsurf repository has necessary updated packages in it and can be
accessed by doing the following:

-   Add CI server repo to slave apt sources

`echo "deb `[`http://ci.netsurf-browser.org/builds/debian/`](http://ci.netsurf-browser.org/builds/debian/)` stretch/amd64/" >> /etc/apt/sources.list`

-   update repos

`apt-get update`

use apt to install these packages:

`openjdk-7-jre-headless `  
`screen `  
`build-essential`  
`ccache`  
`clang`  
`git`  
`pkg-config`  
`check`  
`doxygen`  
`libjson0-dev (from our repo - needs bugfixes `[`http://ci.netsurf-browser.org/builds/debian/`](http://ci.netsurf-browser.org/builds/debian/)`)`  
`libexpat1-dev`  
`libxml-perl`  
`libxml-xpath-perl`  
`lcov`  
`gcovr (from our repo)`  
`gperf`  
`flex`  
`bison`  
`libpng-dev`  
`libjpeg-dev`  
`libmozjs185-dev`  
`libglib2.0-dev`  
`libcurl4-openssl-dev`  
`liblcms1-dev`  
`libxml2-dev`  
`librsvg2-dev`  
`libmng-dev`  
`libgtk2.0-dev`  
`libmozjs-dev`

### config

-   on master jenkins use "manage nodes" to create new node. Ensure
    "remote fs root" is set to /home/netsurf/jenkins
-   create netsurf user
-   as netsurf user:
    -   wget <http://ci.netsurf-browser.org/jenkins/jnlpJars/slave.jar>
    -   run screen
    -   create jenkins-slave.sh

`#!/bin/bash`  
  
`java -Djava.awt.headless=true -jar slave.jar -jnlpUrl `[`http://ci.netsurf-browser.org/jenkins/computer/chimera/slave-agent.jnlp`](http://ci.netsurf-browser.org/jenkins/computer/chimera/slave-agent.jnlp)` -secret 0123456789abcdef01234567890abcdef`

-   -   run jenkins-slave.sh
    -   create new screen tab
    -   create ssh keypair (accept defaults - no password)

`ssh-keygen -t rsa -C "netsurf@cislave0.netsurf-browser.org"`

-   -   copy .ssh/id\_rsa.pub from slave to jenkins master node and
        append to /home/netsurf/.ssh/authorized\_keys

`scp ci.netsurf-browser.org:.ssh/id_rsa.pub .id_rsa.pub`  
`cat id_rsa.pub >> .ssh/authorized_keys`

-   -   copy .ssh/id\_rsa.pub from master node to slave and append to
        /home/netsurf/.ssh/authorized\_keys
    -   create reverse-ssh.sh (change tunnel port number!)

`#!/bin/sh`  
  
`ssh -R 22224:localhost:22 netsurf@ci.netsurf-browser.org 'bash -c "while true; do echo .; sleep 60; done"'`

-   -   run reverse-ssh.sh
    -   on the master create a shell script to use the ssh tunnel
        connection, thus firewalls etc are moot as long as the slave can
        connect to the master

`ssh netsurf@localhost -p 22223`