ubuntu1c-autoinstall/config/gen_files_yml.sh

40 lines
797 B
Bash
Raw Normal View History

2023-05-08 18:12:40 +00:00
#!/bin/bash
tab() {
2023-05-16 20:43:02 +00:00
sed -e "s/^/$(printf %$1s)/"
2023-05-08 18:12:40 +00:00
}
not_empty() {
2023-05-16 20:43:02 +00:00
sed -e "/^$/d"
2023-05-08 18:12:40 +00:00
}
2023-05-16 20:43:02 +00:00
define() { IFS='\n' read -r -d '' ${1} || true; }
2023-05-08 18:12:40 +00:00
#ls -l | tab 10
define FILE_OPTS_COMMON <<'EOF'
encoding: gzip+base64
owner: root:root
permissions: '0644'
EOF
print_file() {
2023-05-16 20:43:02 +00:00
CONTENT=$(cat $1 | gzip | base64)
echo "- path: $2"
cat <<<"$FILE_OPTS_COMMON" | not_empty | tab 2
echo " content: |"
cat <<<"$CONTENT" | tab 4
echo " "
2023-05-08 18:12:40 +00:00
}
gen__write_files() {
2023-05-16 20:43:02 +00:00
echo "write_files:"
print_file src/srv1cv83@.service /etc/systemd/system/srv1cv83@.service | tab 2
print_file src/srv1cv83-ras@.service /etc/systemd/system/srv1cv83-ras@.service | tab 2
print_file src/apache-proxy /etc/nginx/sites-available/apache-proxy | tab 2
2023-05-08 18:12:40 +00:00
}
2023-05-16 20:43:02 +00:00
pushd config >/dev/null 2>&1
2023-05-08 18:12:40 +00:00
gen__write_files | tab 4
2023-05-16 20:43:02 +00:00
popd >/dev/null 2>&1