Debian Codegraph @

connectors/vmware/packaging/scripts/postinstall.sh

raw
1 #!/bin/bash
2
3 json_config_file_path='/etc/centreon/centreon_vmware.json'
4 perl_config_file_path='/etc/centreon/centreon_vmware.pm'
5
6 function migrateConfigFromPmToJson() {
7 # If the legacy config file exists, we migrate it into a JSON config file
8 if [[ -f "$perl_config_file_path" ]] ; then
9 /usr/bin/centreon_vmware_convert_config_file "$perl_config_file_path" > "$json_config_file_path"
10 mv "$perl_config_file_path" "${perl_config_file_path}.deprecated"
11 fi
12 chown centreon: "$json_config_file_path"
13 chmod 640 "$json_config_file_path"
14 }
15
16 function applyToSystemD() {
17 systemctl daemon-reload
18 systemctl restart centreon_vmware.service
19 }
20
21 action="$1"
22 version="$2"
23
24 if [[ "$1" == "configure" ]]; then # deb
25 if [[ -z "$version" ]]; then
26 # Alpine linux does not pass args, and deb passes $1=configure
27 action="install"
28 elif [[ -n "$version" ]]; then
29 # deb passes $1=configure $2=<current version>
30 action="upgrade"
31 fi
32 fi
33
34
35 case "$action" in
36 "1" | "install")
37 migrateConfigFromPmToJson
38 applyToSystemD
39 ;;
40 "2" | "upgrade")
41 migrateConfigFromPmToJson
42 applyToSystemD
43 ;;
44 *)
45 # $1 == version being installed
46 applyToSystemD
47 ;;
48 esac
49