blob: ee13b73541ae4c655d9b2db2fc94b03c1b31611c (
plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
#!/bin/sh
set -e
CONFFILE="/etc/compute-tools/container.conf"
Install ()
{
DEFAULT="${1}"
TARGET="${2}"
mkdir -p "${DEFAULT}" > /dev/null 2>&1 || true
mkdir -p "${TARGET}" > /dev/null 2>&1 || true
if [ "${TARGET}" != "${DEFAULT}" ]
then
if [ -h "${DEFAULT}" ]
then
rm -f "${DEFAULT}"
ln -s "${TARGET}" "${DEFAULT}"
else
if [ -e "${DEFAULT}" ] && [ -z "$(ls -A ${DEFAULT})" ]
then
rmdir "${DEFAULT}"
ln -s "${TARGET}" "${DEFAULT}"
fi
fi
fi
if ! dpkg-statoverride --list "${DEFAULT}" > /dev/null 2>&1 &&
! dpkg-statoverride --list "${TARGET}" > /dev/null 2>&1
then
chmod 0700 "${TARGET}"
chown root:root "${TARGET}"
chmod 0700 "${DEFAULT}"
chown root:root "${DEFAULT}"
fi
}
case "${1}" in
configure)
# build-scripts
update-alternatives --quiet --install /usr/share/compute-tools/build-scripts/default container_build-script /usr/share/compute-tools/build-scripts/mmdebstrap 1000
update-alternatives --quiet --install /usr/share/compute-tools/build-scripts/default container_build-script /usr/share/compute-tools/build-scripts/debootstrap 2000
update-alternatives --quiet --install /usr/share/compute-tools/build-scripts/default container_build-script /usr/share/compute-tools/build-scripts/progress-linux 3000
update-alternatives --quiet --install /usr/share/compute-tools/build-scripts/default container_build-script /usr/share/compute-tools/build-scripts/debian 4000
# get-scripts
update-alternatives --quiet --install /usr/share/compute-tools/get-scripts/default container_get-script /usr/share/compute-tools/get-scripts/curl 1000
. /usr/share/debconf/confmodule
db_get open-infrastructure-container-tools/machines
MACHINES="${RET:-/var/lib/machines}" # string (w/o empty)
db_get open-infrastructure-container-tools/config
CONFIG="${RET:-/etc/compute-tools/config}" # string (w/o empty)
db_get open-infrastructure-container-tools/debconf
DEBCONF="${RET:-/etc/compute-tools/debconf}" # string (w/o empty)
db_get open-infrastructure-container-tools/hooks
HOOKS="${RET:-/etc/compute-tools/hooks}" # string (w/o empty)
db_get open-infrastructure-container-tools/keys
KEYS="${RET:-/etc/compute-tools/keys}" # string (w/o empty)
db_get open-infrastructure-container-tools/cache
CACHE="${RET:-/var/cache/container}" # string (w/o empty)
db_get open-infrastructure-container-tools/build-script
SCRIPT="${RET:-debian}" # string (w/o empty)
db_get open-infrastructure-container-tools/irc
IRK_TARGETS="${RET}" # string (w/ empty)
db_stop
Install "/var/lib/machines" "${MACHINES}"
Install "/etc/compute-tools/config" "${CONFIG}"
Install "/etc/compute-tools/debconf" "${DEBCONF}"
Install "/etc/compute-tools/hooks" "${HOOKS}"
Install "/etc/compute-tools/keys" "${KEYS}"
Install "/var/cache/container" "${CACHE}"
update-alternatives --quiet --set container_build-script "/usr/share/compute-tools/build-scripts/${SCRIPT}"
# upgrade from buster: conffile
if [ -e /etc/open-infrastructure/container.conf ] && [ ! -e "${CONFFILE}" ]
then
mv /etc/open-infrastructure/container.conf "${CONFFILE}"
rmdir /etc/open-infrastructure > /dev/null 2>&1 || true
fi
# upgrade from buster: keys
if [ -e /etc/open-infrastructure/container/keys ]
then
mv /etc/open-infrastructure/container/keys/* "${KEYS}" > /dev/null 2>&1 || true
rmdir /etc/open-infrastructure/container/keys > /dev/null 2>&1 || true
rm -f /etc/open-infrastructure/container/keys > /dev/null 2>&1 || true
rmdir -p /etc/open-infrastructure/container > /dev/null 2>&1 || true
fi
# upgrade from buster: logfiles
if ls /var/log/open-infrastructure/container.log* > /dev/null 2>&1
then
if [ -e /var/log/compute-tools ]
then
mv /var/log/open-infrastructure/* /var/log/compute-tools 2>&1 || true
rmdir /var/log/open-infrastructure > /dev/null 2>&1 || true
else
mv /var/log/open-infrastructure /var/log/compute-tools
fi
fi
if [ ! -e "${CONFFILE}" ]
then
cat > "${CONFFILE}" << EOF
# ${CONFFILE}
IRK_TARGETS="${IRK_TARGETS}"
EOF
fi
cp -a -f "${CONFFILE}" "${CONFFILE}.tmp"
# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the config file.
test -z "${IRK_TARGETS}" || \
grep -Eq '^ *IRK_TARGETS=' "${CONFFILE}" || \
echo "IRK_TARGETS=" >> "${CONFFILE}"
sed -e "s|^ *IRK_TARGETS=.*|IRK_TARGETS=\"${IRK_TARGETS}\"|" \
< "${CONFFILE}" > "${CONFFILE}.tmp"
mv -f "${CONFFILE}.tmp" "${CONFFILE}"
if command -v sysctl > /dev/null 2>&1
then
sysctl -q -p /etc/sysctl.d/zz-container.conf
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`${1}'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|