-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathpreinstall
More file actions
executable file
·34 lines (26 loc) · 939 Bytes
/
preinstall
File metadata and controls
executable file
·34 lines (26 loc) · 939 Bytes
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
#!/bin/bash
# this script should be run when instructed to.
if [[ $(id -u) -ne 0 ]]; then
echo "This script must be executed as root or using sudo."
exit 99
fi
logfile="/root/omv_preinstall.log"
exec > >(stdbuf -oL tee -a "${logfile}") 2> >(stdbuf -oL tee -a "${logfile}" >&2)
trap 'rc=$?; echo "=== END $(date -Is) rc=$rc ==="; exit $rc' EXIT
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
export LANG=C.UTF-8
export LANGUAGE=C
export LC_ALL=C.UTF-8
apt-get --yes --no-install-recommends install jq
apt-get --yes purge --autoremove cloud-init
mac="$(ip -j a show dev eth0 | jq -r .[].address | head -n1)"
if [ -z "${mac}" ]; then
mac="$(ip -j a show dev end0 | jq -r .[].address | head -n1)"
fi
if [ -n "${mac}" ]; then
echo "mac - ${mac}"
echo -e "[Match]\nMACAddress=${mac}\n[Link]\nName=eth0" > /etc/systemd/network/10-persistent-eth0.link
echo "Please reboot the system now."
fi
exit 0