-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·99 lines (84 loc) · 2.33 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·99 lines (84 loc) · 2.33 KB
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
#!/bin/bash
set -e
source lepidopter-fh/etc/default/lepidopter
source conf/lepidopter-image.conf
image_file="lepidopter-${LEPIDOPTER_BUILD}-${ARCH}.img"
function usage() {
echo "usage: setup.sh [options]"
echo "with no options the script installs the dependencies and builds" \
"lepidopter image"
echo "-c compress lepidopter image with xz or zip compression (eg. -c xz)"
echo "-t create a torrent file of the image and the digests"
}
while getopts "c:ht" opt; do
case $opt in
c)
compression_method+=("$OPTARG")
;;
t)
build_torrent=true
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
exit 1
esac
done
# Create a torrent of the xz image file
mk_torrent() {
apt-get install -y mktorrent bittornado
cd images && \
mktorrent -a 'udp://tracker.torrent.eu.org:451' \
-a 'udp://tracker.coppersurfer.tk:6969' \
-n ${image_file:-4} SHA* ${image_file}.xz
btshowmetainfo ${image_file:-4}.torrent
}
# Compress lepidopter img
xz_archive() {
apt-get install -y pxz
pxz --keep --verbose -D 12 images/${image_file}
}
zip_archive() {
apt-get install -y zip
zip --verbose -9 images/${image_file}.zip images/${image_file}
}
if [ "$( lsb_release -is )" == "Debian" ]; then
# Add backports APT repository
echo "deb $APT_MIRROR ${DEB_RELEASE}-backports main" > \
/etc/apt/sources.list.d/${DEB_RELEASE}-backports.list
apt-get update -q
apt-get install -t ${DEB_RELEASE}-backports -y vmdebootstrap qemu-utils
else
apt-get install -y vmdebootstrap qemu-utils
fi
# Copy know working vmdebootstrap version 0.10 from git
cd $HOME
git clone git://git.liw.fi/vmdebootstrap
cd vmdebootstrap
git checkout tags/vmdebootstrap-0.10
cp vmdebootstrap /usr/sbin/vmdebootstrap
cd $HOME
git clone https://github.com/TheTorProject/lepidopter.git
# Add loop kernel module required to mount loop devices
modprobe loop
cd lepidopter/
./lepidopter-vmdebootstrap_build.sh
if [ "${#compression_method[@]}" -ne 0 ] ; then
for cmp in "${compression_method[@]}"; do
${cmp}_archive
done
fi
if [ "$build_torrent" = true ] ; then
mk_torrent
fi
# Remove all device mappings
dmsetup remove_all