add update_files.sh
This commit is contained in:
parent
ef2dd30fac
commit
d92d4e4400
@ -1,14 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
tab() {
|
||||
sed -e "s/^/$(printf %$1s)/"
|
||||
sed -e "s/^/$(printf %$1s)/"
|
||||
}
|
||||
|
||||
not_empty() {
|
||||
sed -e "/^$/d"
|
||||
sed -e "/^$/d"
|
||||
}
|
||||
|
||||
define(){ IFS='\n' read -r -d '' ${1} || true; }
|
||||
define() { IFS='\n' read -r -d '' ${1} || true; }
|
||||
|
||||
#ls -l | tab 10
|
||||
|
||||
@ -19,22 +19,21 @@ permissions: '0644'
|
||||
EOF
|
||||
|
||||
print_file() {
|
||||
CONTENT=$(cat $1 | gzip | base64)
|
||||
echo "- path: $2"
|
||||
cat <<< $FILE_OPTS_COMMON | not_empty | tab 2
|
||||
echo " content: |"
|
||||
cat <<< $CONTENT | tab 4
|
||||
echo " "
|
||||
CONTENT=$(cat $1 | gzip | base64)
|
||||
echo "- path: $2"
|
||||
cat <<<"$FILE_OPTS_COMMON" | not_empty | tab 2
|
||||
echo " content: |"
|
||||
cat <<<"$CONTENT" | tab 4
|
||||
echo " "
|
||||
}
|
||||
|
||||
gen__write_files() {
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
pushd config
|
||||
pushd config >/dev/null 2>&1
|
||||
gen__write_files | tab 4
|
||||
popd
|
||||
|
||||
popd >/dev/null 2>&1
|
||||
|
22
config/update_files.sh
Executable file
22
config/update_files.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
temp_yml() {
|
||||
mktemp --suffix=.yml
|
||||
}
|
||||
|
||||
gen_files() {
|
||||
./gen_files_yml.sh >"$1"
|
||||
}
|
||||
|
||||
update_files_from() {
|
||||
SRC=$1 yq -i '.autoinstall.user-data.write_files |= load(strenv(SRC)).write_files' nocloud/user-data
|
||||
}
|
||||
|
||||
pushd config >/dev/null 2>&1
|
||||
|
||||
TMP_YML=$(temp_yml)
|
||||
gen_files "$TMP_YML"
|
||||
update_files_from "$TMP_YML"
|
||||
rm -f "$TMP_YML"
|
||||
|
||||
popd >/dev/null 2>&1
|
Loading…
Reference in New Issue
Block a user