-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovision.sh
executable file
·73 lines (60 loc) · 1.43 KB
/
provision.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
#!/bin/bash
install_dependencies(){
sudo apt-get update
sudo apt-get install -y curl quilt parted realpath \
qemu-user-static debootstrap zerofree pxz zip \
dosfstools bsdtar libcap2-bin grep rsync xz-utils
}
create_basic_configuration(){
echo 'IMG_NAME=Raspbian' >> config
}
create_installation_customization_demo(){
files_path="$(pwd)/stage2/03-custom-installations/files"
mkdir -p $files_path
cd $script_path
dpkg-deb --build helloworld
cd - > /dev/null
mv $script_path/helloworld.deb $files_path/
cp $script_path/00-run.sh $(dirname $files_path)/
}
prepare_upstream_source(){
git clone https://github.com/RPi-Distro/pi-gen.git
cd pi-gen/
rm -rf ./stage[345]
create_basic_configuration
}
customize_user_environment(){
(cat | tee -a ~/.bashrc | sudo tee -a ~root/.bashrc > /dev/null) <<EOF
export EDITOR=vim
set -o vi
alias ll='ls -la'
EOF
}
provision(){
install_dependencies
prepare_upstream_source
create_installation_customization_demo
}
provision_vagrant(){
provision
customize_user_environment
}
is_being_sourced(){
[[ "${BASH_SOURCE[0]}" != "${0}" ]]
}
script_path(){
if is_being_sourced; then
echo $(pwd)
else
cd $(dirname "$0")
echo $(pwd)
cd - > /dev/null
fi
}
script_path=$(script_path)
if is_being_sourced; then
echo "Script ${BASH_SOURCE[0]} is being sourced. Functions defined but not called."
echo 'Try calling `provision`, and then './build.sh' in the pi-gen directory.'
else
provision_vagrant
fi