-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-cfg
executable file
·44 lines (34 loc) · 963 Bytes
/
update-cfg
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
#!/bin/bash
if [ $(id -u) != "0" ]
then
echo "This script requires root"
sudo "$0" "$@"
exit $?
fi
currentDir=$(pwd)
cd $(dirname ${0})
# Working copy of files
cp -a fs_root staging
# Generate qemu config files
mkdir -p staging/etc/conf.d/qemu.d
for file in config/*; do
source $file
echo "args=\"$ARGS\"" > staging/etc/conf.d/qemu.d/$(basename $file)
echo "haltcmd=\"$HALTCMD\"" >> staging/etc/conf.d/qemu.d/$(basename $file)
done
# Apply passwords to config files
# password file has lines like "ABC=123"
# this will replace all occurances of ${ABC} with 123
for file in $(find staging/ -type f -print); do
while IFS="=" read placeholder pass; do
sed -i "s/{{$placeholder}}/$pass/g" $file
done < passwords
done
# Copy config in place
cp -rv staging/* /
rm -rf staging
# Make sure systemd has any changes to unit files
systemctl daemon-reload
# Rebuild grub menu
grub-mkconfig -o /boot/grub/grub.cfg
cd ${currentDir}