-
Notifications
You must be signed in to change notification settings - Fork 9
/
wizard.sh
executable file
·84 lines (74 loc) · 2.37 KB
/
wizard.sh
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
#!/usr/bin/env bash
# This Bash script to build the latest Raspbian release of FlyDog SDR:
# https://github.com/flydog-sdr/FlyDog_SDR_GPS
# The URL of the script project is:
# https://github.com/flydog-sdr/raspbian-builder
# The URL of the script is:
# https://raw.githubusercontent.com/flydog-sdr/raspbian-builder/master/wizard.sh
# Define basic variables
BASE_PATH=$(cd `dirname $0`; pwd)
DOCKER_ARCHIVE="${BASE_PATH}/builder/stage2/00-copies-and-fills/docker_volume.tar.gz"
BUILD_DEPENDS="binfmt-support coreutils quilt parted qemu-user-static debootstrap zerofree zip dosfstools libarchive-tools libcap2-bin rsync xz-utils file git curl bc"
check_environment() {
if [[ ${UID} -ne '0' ]]; then
echo "Not running with root, exiting..."
exit 1
fi
if [[ ! -f /usr/bin/apt-get ]]; then
echo "Not Debian or Ubuntu Linux distributions, exiting..."
exit 1
fi
}
initialise_environment() {
modprobe binfmt_misc
apt-get update
apt-get install -y ${BUILD_DEPENDS}
curl https://get.docker.com \
| sed "s/20/1/g" \
| sed "s/mirrors.aliyun.com/mirrors.bfsu.edu.cn/g" > /tmp/docker.sh
sh /tmp/docker.sh --mirror Aliyun
/etc/init.d/docker restart
apt-get autoremove --purge -y
rm -rf /tmp/docker.sh \
/var/lib/docker/* \
${DOCKER_ARCHIVE}
echo y | docker system prune
/etc/init.d/docker restart
sleep 3s
}
deploy_apps() {
docker network create -d bridge flydog-sdr
docker run -d \
--name flydog-sdr \
--network host \
--privileged \
--restart always \
--volume kiwi.config:/root/kiwi.config \
registry.cn-shanghai.aliyuncs.com/flydog-sdr/flydog-sdr:latest
docker run -d \
--name admin \
--network flydog-sdr \
--publish 3708:3708 \
--restart always \
--volume /usr/bin/docker:/usr/bin/docker \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume kiwi.config:/etc/kiwi.config \
registry.cn-shanghai.aliyuncs.com/flydog-sdr/admin:latest
/etc/init.d/docker stop
}
archive_docker_volume() {
tar -czf ${DOCKER_ARCHIVE} /var/lib/docker
}
execute_build() {
cd ${BASE_PATH}/builder
chmod +x build.sh
bash -c "./build.sh -c ../config"
}
main() {
check_environment
initialise_environment
deploy_apps
archive_docker_volume
execute_build
}
main "$@"; exit