-
Notifications
You must be signed in to change notification settings - Fork 5
/
rebuild_and_copy.sh
executable file
·50 lines (40 loc) · 1.35 KB
/
rebuild_and_copy.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
#!/bin/bash
##
# created by bastelfreak
# based on a script by Bluewind
##
# this allows us to set different configs via env vars:
# CONFIG_BUILD=config_build_rackmonkey.sh CONFIG_LIVE=config_live_rackmonkey.sh ./rebuild_and_copy.sh
config_build=${CONFIG_BUILD:-config_build.sh}
config_live=${CONFIG_LIVE:-config_live.sh}
for file in "$config_build" "$config_live"; do
if [ ! -e "$file" ]; then
echo "Error: ${file} file isn't available"
exit 1
fi
done
# shellcheck disable=SC1090
. "$config_build"
# we need to place the set under the exit
# it would ignore it because it's in an if/fi statement
set -e
umask 022
# copy the config because we need it later during build inside of the ISO
cp "$config_build" airootfs/root/config_build.sh
# copy the config, needed after booting the ISO
rsync -a ext_scripts/ scripts/ airootfs/usr/local/bin/
rsync -a "${config_live}" airootfs/usr/local/bin/config_live.sh
chmod +x airootfs/usr/local/bin/*
# clean builddir, build the ISO, clean it again
rm -rf work
./build.sh -v
rm -rf work
# determine the name of the latest ISO
unset -v latest
for file in out/archlinux-*.iso; do
[[ $file -nt $latest ]] && latest=$file
done
# copy and extract the ISO
rsync -tP "$latest" -e ssh "${DHCP_USER}@${DHCP_SERVER}:${DHCP_PATH}"
# shellcheck disable=SC2029
ssh "${DHCP_USER}@${DHCP_SERVER}" "${DHCP_EXTRACT} ${DHCP_PATH}${latest##*/}"