File: fix_conf_file.sh

package info (click to toggle)
ceph 18.2.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,186,140 kB
  • sloc: cpp: 6,278,388; ansic: 3,507,431; python: 372,964; asm: 216,381; java: 133,450; sh: 125,043; xml: 39,398; ruby: 32,026; makefile: 29,004; javascript: 23,994; cs: 18,980; perl: 9,708; sql: 7,833; lisp: 5,920; pascal: 3,109; ada: 1,681; yacc: 478; awk: 188; f90: 55; php: 1
file content (28 lines) | stat: -rwxr-xr-x 999 bytes parent folder | download | duplicates (4)
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
source ./copy_func.sh
#
# Take a templated file, modify a local copy, and write it to the
# remote site.
#
# Usage: fix_conf_file <remote-site> <file-name> <remote-location> [<rbd-secret>]
#      <remote-site> -- site where we want this modified file stored.
#      <file-name> -- name of the remote file.
#      <remote-location> -- directory where the file will be stored
#      <rbd-secret> -- (optional) rbd_secret used by libvirt
#
function fix_conf_file() {
    if [[ $# < 3 ]]; then
        echo 'fix_conf_file: Too few parameters' 
        exit 1
    fi
    openstack_node_local=${1}
    cp files/${2}.template.conf ${2}.conf
    hostname=`ssh $openstack_node_local hostname`
    inet4addr=`ssh $openstack_node_local hostname -i`
    sed -i s/VARHOSTNAME/$hostname/g ${2}.conf
    sed -i s/VARINET4ADDR/$inet4addr/g ${2}.conf
    if [[ $# == 4 ]]; then
        sed -i s/RBDSECRET/${4}/g ${2}.conf
    fi
    copy_file ${2}.conf $openstack_node_local ${3} 0644 "root:root"
    rm ${2}.conf
}