-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild
executable file
·56 lines (44 loc) · 1.45 KB
/
build
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
#!/bin/bash
REV=$(tput rev)
BLD=$(tput bold)
GRY="\e[90m"
RED="\e[31m"
GRN="\e[32m"
WHT="\e[37m"
CLR="\e[0m"
if [[ -z "$PLATFORM" ]]; then PLATFORM=docker; fi
function err(){
echo -e "${RED}Error Building Image${CLR}"
exit $1
}
case $PLATFORM in
docker)
# if user is logged into docker index
# automatically prefix their name to built images
name=$(sudo docker info | grep ^Username | awk '{print $2}' )
if [[ -z "$name" ]]; then name=local; fi
NOSN=${name}/nodeos
;;
esac
# Build each layer up
(cd Layer1-linux && PLATFORM=${PLATFORM} ./build ) &&
(cd Layer2-nodejs && PLATFORM=${PLATFORM} ./build ) &&
(cd Layer3-base && PLATFORM=${PLATFORM} ./build ) &&
(cd Layer4-custom && PLATFORM=${PLATFORM} name=${NOSN} ./build ) || err $?
echo -e "${GRY}------------------------------------------${CLR}"
echo -e "${GRN}${BLD}Success!${CLR}"
echo -e "${GRN}You Just Built a Custom NodeOS Image ${WHT}$NOSN${CLR}"
echo -e "${GRY}------------------------------------------${CLR}"
echo
echo -e "- Interactively run your image with:"
case $PLATFORM in
docker)
echo -e "${WHT} sudo docker run -t -i $NOSN${CLR}"
echo
echo -e "- Share your creation with:"
echo -e "${WHT} sudo docker push $NOSN${CLR}"
;;
qemu)
echo -e "${WHT} sudo qemu-system-i386 --kernel /vmlinuz --initrd Layer3-base/layer3.cpio.gz -hda Layer4-custom/layer4.img -enable-kvm -nographic -append \"console=ttyS0 /bin/nodeos-boot /dev/sda\"${CLR}"
;;
esac