-
Notifications
You must be signed in to change notification settings - Fork 20
/
customize
executable file
·87 lines (70 loc) · 2.72 KB
/
customize
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
#!/bin/sh
set -x
set -e # Exit on first error
ROOTDIR="$1"
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
export LC_ALL=C LANGUAGE=C LANG=C
# Install non-free binary blob and kernel needed to boot Raspberry Pi
wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update \
-O ${ROOTDIR}/usr/local/sbin/rpi-update
chmod a+x ${ROOTDIR}/usr/local/sbin/rpi-update
mkdir -p ${ROOTDIR}/lib/modules
touch ${ROOTDIR}/boot/start.elf
# Do not try to update itself, avoid making backups, skip warnings
export UPDATE_SELF=0 SKIP_BACKUP=1 SKIP_WARNING=1
chroot ${ROOTDIR} rpi-update
# Add Raspberry Pi 3 wireless chipset firmware
wget --directory-prefix=${ROOTDIR}/lib/firmware/brcm/ \
https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin \
https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt
# Add an apt repository with apt preferences
set_apt_sources() {
SUITE="$1"
PIN_PRIORITY="$2"
COMPONENTS="main"
cat <<EOF >> ${ROOTDIR}/etc/apt/sources.list
# Repository: $SUITE
deb $APT_MIRROR $SUITE $COMPONENTS
EOF
if [ -n "$PIN_PRIORITY" ]
then
cat <<EOF > ${ROOTDIR}/etc/apt/preferences.d/${SUITE}.pref
Package: *
Pin: release n=$SUITE
Pin-Priority: $PIN_PRIORITY
EOF
fi
}
echo "Add Debian ${DEB_RELEASE}-backports repository"
set_apt_sources ${DEB_RELEASE}-backports
echo "Add Debian stretch repository"
set_apt_sources stretch 100
# Create ooniprobe log directory
mkdir -p ${ROOTDIR}/var/log/ooni/
# Copy required scripts, cronjobs and config files to lepidopter
# Rsync Directory/file hieratchy to image
rsync -avp lepidopter-fh/ ${ROOTDIR}/
# Install ooniprobe via setup script
chroot ${ROOTDIR} /setup-ooniprobe.sh
rm ${ROOTDIR}/setup-ooniprobe.sh
# OS configure script
chroot ${ROOTDIR} /configure.sh
rm ${ROOTDIR}/configure.sh
# Execute cleanup script
chroot ${ROOTDIR} /cleanup.sh
rm ${ROOTDIR}/cleanup.sh
# Remove SSH host keys and add regenerate_ssh_host_keys SYSV script
chroot ${ROOTDIR} /remove_ssh_host_keys.sh
rm ${ROOTDIR}/remove_ssh_host_keys.sh
# Remove motd file and create symlink for lepidopter dynamic MOTD
rm ${ROOTDIR}/etc/motd
chroot ${ROOTDIR} ln -s /var/run/motd /etc/motd
# Add (optional) pluggable transport support in tor config
cat conf/tor-pt.conf >> ${ROOTDIR}/etc/tor/torrc
# Get list of apt and Python packages from lepidopter image
rsync -av --no-R --no-implied-dirs --remove-source-files \
${ROOTDIR}/lepidopter-apt-packages pkglist/lepidopter-${LEPIDOPTER_BUILD}-${ARCH}-apt-packages
rsync -av --no-R --no-implied-dirs --remove-source-files \
${ROOTDIR}/lepidopter-pip-packages pkglist/lepidopter-${LEPIDOPTER_BUILD}-${ARCH}-pip-packages
echo "Customize script finished successfully."
exit 0