File: freezer-api.postrm.in

package info (click to toggle)
freezer-api 9.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,884 kB
  • sloc: python: 15,677; sh: 388; makefile: 56
file content (48 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
#!/bin/sh

set -e

#PKGOS-INCLUDE#

remove_dir(){
	DIR_PATH=$1

        # Try to delete only when freezer-scheduler is not installed
        if ! dpkg-query -W --showformat '${Status} ${Package} ${Version}\n' 'freezer-scheduler' 2>/dev/null | grep -q ^install; then
                # Freezer-scheduler is not installed, we can try to remove
                rmdir --ignore-fail-on-non-empty ${DIR_PATH} || true
        else
                echo "Freezer-scheduler is installed, not removing common ${DIR_PATH} directory."
        fi
}

if [ "${1}" = "purge" ] ; then
        pkgos_dbc_postrm freezer-api freezer-api $@

	# Freezer is using same directory structure
	# as freezer-scheduler
	#
	# We have to make sure that we will delete
	# only freezer-api stuff.

	# All freezer-api stuff in /etc/freezer
	rm -f /etc/freezer/freezer-api-uwsgi.ini
	rm -f /etc/freezer/freezer-api.conf
	rm -f /etc/freezer/freezer-paste.ini
	rm -f /etc/freezer/policy.json

	# All freezer-api stuff including logrotated files
	rm -f /var/log/freezer/freezer-api*

	# Remove directories if they are empty
	# and freezer-scheduler is not installed
	for i in /var/lib/freezer /var/log/freezer \
		 /var/lock/freezer /var/cache/freezer \
		 /etc/freezer; do 
		remove_dir ${i}
	done
fi

#DEBHELPER#

exit 0