postinst is in linux-container 1-4.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | #!/bin/sh
set -e
. /usr/share/debconf/confmodule
_CONFFILE="/etc/default/linux-container"
case "${1}" in
configure)
db_get linux-container/enable
LINUX_CONTAINER_ENABLE="${RET}" # boolean
case "${LINUX_CONTAINER_ENABLE}" in
false)
exit 0
;;
esac
db_get linux-container/consoles
LINUX_CONTAINER_CONSOLES="${RET:-6}" # string (w/o empty)
db_get linux-container/hostname
LINUX_CONTAINER_HOSTNAME="${RET}" # string (w/o empty)
if [ -z "${LINUX_CONTAINER_HOSTNAME}" ]
then
if [ -n "$(cat /etc/hostname 2> /dev/null)" ]
then
LINUX_CONTAINER_HOSTNAME="$(cat /etc/hostname)"
elif [ -x /usr/bin/lsb_release ]
then
LINUX_CONTAINER_HOSTNAME="$(lsb_release -is | tr [A-Z] [a-z])"
else
LINUX_CONTAINER_HOSTNAME="debian"
fi
fi
_NUMBER="0"
while db_get linux-container/eth${_NUMBER}/dhcp && [ "${RET}" ]
do
if db_get linux-container/eth${_NUMBER}/comment
then
eval LINUX_CONTAINER_ETH${_NUMBER}_COMMENT="\"${RET}\"" # string (w/ empty)
fi
if db_get linux-container/eth${_NUMBER}/dhcp
then
eval LINUX_CONTAINER_ETH${_NUMBER}_DHCP="\"${RET}\"" # boolean
fi
if db_get linux-container/eth${_NUMBER}/address
then
eval LINUX_CONTAINER_ETH${_NUMBER}_ADDRESS="\"${RET:-192.168.0.$((${_NUMBER}+1))}\"" # string (w/o empty)
fi
if db_get linux-container/eth${_NUMBER}/broadcast
then
eval LINUX_CONTAINER_ETH${_NUMBER}_BROADCAST="\"${RET}\"" # string (w/ empty)
fi
if db_get linux-container/eth${_NUMBER}/gateway
then
eval LINUX_CONTAINER_ETH${_NUMBER}_GATEWAY="\"${RET}\"" # string (w/ empty)
fi
if db_get linux-container/eth${_NUMBER}/mtu
then
eval LINUX_CONTAINER_ETH${_NUMBER}_MTU="\"${RET}\"" # string (w/ empty)
fi
if db_get linux-container/eth${_NUMBER}/netmask
then
eval LINUX_CONTAINER_ETH${_NUMBER}_NETMASK="\"${RET:-255.255.255.0}\"" # string (w/ empty)
fi
if db_get linux-container/eth${_NUMBER}/network
then
eval LINUX_CONTAINER_ETH${_NUMBER}_NETWORK="\"${RET}\"" # string (w/ empty)
fi
if db_get linux-container/eth${_NUMBER}/post-up
then
eval LINUX_CONTAINER_ETH${_NUMBER}_POST_UP="\"${RET}\"" # string (w/ empty)
fi
_NUMBER="$((${_NUMBER} + 1))"
done
LINUX_CONTAINER_ETH_NUMBER="${_NUMBER}"
db_get linux-container/nameservers
LINUX_CONTAINER_NAMESERVERS="${RET}" # string (w/ empty)
db_stop
if [ ! -e "${_CONFFILE}" ]
then
echo -n "P: Creating file ${_CONFFILE}..."
cat > "${_CONFFILE}" << EOF
# /etc/default/linux-container
LINUX_CONTAINER_ENABLE="${LINUX_CONTAINER_ENABLE}"
EOF
echo " done."
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.
echo -n "P: Updating file ${_CONFFILE}..."
test -z "${LINUX_CONTAINER_ENABLE}" || \
grep -Eq '^ *LINUX_CONTAINER_ENABLE=' "${_CONFFILE}" || \
echo "LINUX_CONTAINER_ENABLE=" >> "${_CONFFILE}"
sed -e "s|^ *LINUX_CONTAINER_ENABLE=.*|LINUX_CONTAINER_ENABLE=\"${LINUX_CONTAINER_ENABLE}\"|" \
< "${_CONFFILE}" > "${_CONFFILE}.tmp"
mv -f "${_CONFFILE}.tmp" "${_CONFFILE}"
echo " done."
# Applying bug fixes
if [ -x /usr/bin/lsb_release ]
then
_DISTRIBUTOR="$(lsb_release -is | tr [A-Z] [a-z])"
_CODENAME="$(lsb_release -cs | tr [A-Z] [a-z])"
else
if [ -e /etc/progress_version ]
then
_DISTRIBUTOR="progress"
_VERSION="$(cat /etc/progress_version)"
case "${_VERSION}" in
1.0*)
_CODENAME="artax"
;;
1.9*)
_CODENAME="artax-backports"
;;
2.0*)
_CODENAME="baureo"
;;
esac
elif [ -e /etc/debian_version ]
then
_DISTRIBUTOR="debian"
if grep -qs sid /etc/debian_version
then
_CODENAME="sid"
else
_VERSION="$(cat /etc/debian_version)"
fi
case "${_VERSION}" in
6.0*)
_CODENAME="squeeze"
;;
7.0*)
_CODENAME="wheezy"
;;
esac
fi
fi
if ls /usr/share/linux-container/scripts/${_DISTRIBUTOR}-${_CODENAME}/* > /dev/null 2>&1
then
for _SCRIPT in /usr/share/linux-container/scripts/${_DISTRIBUTOR}-${_CODENAME}/*
do
${_SCRIPT}
done
fi
# squeeze only has /dev/tty and /dev/tty0 by default,
# therefore creating missing device nodes for tty1-4.
for _CONSOLE in $(seq 1 ${LINUX_CONTAINER_CONSOLES})
do
if [ ! -e "/dev/tty${_CONSOLE}" ]
then
echo -n "P: Creating file /dev/tty${_CONSOLE}..."
mknod "/dev/tty${_CONSOLE}" c 4 "${_CONSOLE}"
echo " done."
fi
done
echo -n "P: Updating file /etc/inittab..."
# Disable sulogin
# ~~:S:wait:/sbin/sulogin
sed -i -e 's|\(^[^#].*S:wait:.*$\)|#\1|' /etc/inittab
# Disable ctrlaltdel
# ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
sed -i -e 's|\(^[^#].*:ctrlaltdel:.*$\)|#\1|' /etc/inittab
# Disable power
# pf::powerwait:/etc/init.d/powerfail start
# pn::powerfailnow:/etc/init.d/powerfail now
# po::powerokwait:/etc/init.d/powerfail stop
sed -i -e 's|\(^[^#].*:power.*:.*$\)|#\1|' /etc/inittab
# Disable normal getty
# 1:2345:respawn:/sbin/getty 38400 tty1
# 2:23:respawn:/sbin/getty 38400 tty2
# 3:23:respawn:/sbin/getty 38400 tty3
# ...
# Keep container getty
# 1:2345:respawn:/sbin/getty 38400 console
# c1:23:respawn:/sbin/getty 38400 tty1
# c2:23:respawn:/sbin/getty 38400 tty2
# ...
sed -i -e 's|\(^[^#,^c].*:respawn:/sbin/getty.*[^console,linux]$\)|#\1|' /etc/inittab
# Enable container getty
# 1:2345:respawn:/sbin/getty 38400 console
# c1:23:respawn:/sbin/getty 38400 tty1
# c2:23:respawn:/sbin/getty 38400 tty2
# Assemble new entries
_CONSOLES="\n#-- linux-container begin\n1:2345:respawn:/sbin/getty 38400 console"
for _CONSOLE in $(seq 1 ${LINUX_CONTAINER_CONSOLES})
do
_CONSOLES="${_CONSOLES}\nc${_CONSOLE}:12345:respawn:/sbin/getty 38400 tty${_CONSOLE} linux"
done
_CONSOLES="${_CONSOLES}\n#-- linux-container end"
# Remove old entries
sed -e '/#-- linux-container begin/,/#-- linux-container end/d' /etc/inittab > /etc/inittab.tmp
mv -f /etc/inittab.tmp /etc/inittab
echo " done."
# Add new entries
_CONSOLE="$(grep '#[0-9].*:respawn:/sbin/getty' /etc/inittab | tail -1)"
sed -e "s|\(${_CONSOLE}\)|\1${_CONSOLES}|" /etc/inittab > /etc/inittab.tmp
mv -f /etc/inittab.tmp /etc/inittab
# disable selinux
echo -n "P: Disabling feature selinux..."
mkdir -p /selinux
echo 0 > /selinux/enforce
echo " done."
# configure the network
case "${LINUX_CONTAINER_DHCP}" in
false)
echo -n "P: Creating file /etc/hosts..."
cat > /etc/hosts << EOF
127.0.0.1 localhost
${LINUX_CONTAINER_ADDRESS} ${LINUX_CONTAINER_HOSTNAME}
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
echo " done."
;;
esac
echo -n "P: Creating file /etc/network/interfaces..."
cat > /etc/network/interfaces << EOF
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
# The loopback network interface
auto lo
iface lo inet loopback
EOF
for _NUMBER in $(seq 0 ${LINUX_CONTAINER_ETH_NUMBER})
do
eval _COMMENT="$`echo LINUX_CONTAINER_ETH${_NUMBER}_COMMENT`"
eval _DHCP="$`echo LINUX_CONTAINER_ETH${_NUMBER}_DHCP`"
eval _ADDRESS="$`echo LINUX_CONTAINER_ETH${_NUMBER}_ADDRESS`"
eval _BROADCAST="$`echo LINUX_CONTAINER_ETH${_NUMBER}_BROADCAST`"
eval _GATEWAY="$`echo LINUX_CONTAINER_ETH${_NUMBER}_GATEWAY`"
eval _MTU="$`echo LINUX_CONTAINER_ETH${_NUMBER}_MTU`"
eval _NETMASK="$`echo LINUX_CONTAINER_ETH${_NUMBER}_NETMASK`"
eval _NETWORK="$`echo LINUX_CONTAINER_ETH${_NUMBER}_NETWORK`"
eval _POST_UP="$`echo LINUX_CONTAINER_ETH${_NUMBER}_POST_UP`"
if [ -z "${_DHCP}" ]
then
continue
fi
echo >> /etc/network/interfaces
if [ -n "${_COMMENT}" ]
then
echo "# ${_COMMENT}" >> /etc/network/interfaces
fi
case "${_DHCP}" in
true)
cat >> /etc/network/interfaces << EOF
auto eth${_NUMBER}
iface eth${_NUMBER} inet dhcp
EOF
;;
false)
cat >> /etc/network/interfaces << EOF
auto eth${_NUMBER}
iface eth${_NUMBER} inet static
address ${_ADDRESS}
EOF
if [ -n "${_BROADCAST}" ]
then
echo " broadcast ${_BROADCAST}" >> /etc/network/interfaces
fi
if [ -n "${_GATEWAY}" ]
then
echo " gateway ${_GATEWAY}" >> /etc/network/interfaces
fi
echo " netmask ${_NETMASK}" >> /etc/network/interfaces
if [ -n "${_MTU}" ]
then
echo " mtu ${_MTU}" >> /etc/network/interfaces
fi
if [ -n "${_NETWORK}" ]
then
echo " network ${_NETWORK}" >> /etc/network/interfaces
fi
if [ -n "${_POST_UP}" ]
then
echo " post-up ${_POST_UP}" >> /etc/network/interfaces
fi
;;
esac
_NUMBER="$((${_NUMBER} + 1))"
done
echo " done."
if [ -n "${LINUX_CONTAINER_NAMESERVERS}" ]
then
echo -n "P: Creating file /etc/resolv.conf..."
rm -f /etc/resolv.conf
for _NAMESERVER in $(echo ${LINUX_CONTAINER_NAMESERVERS} | sed -e 's|,| |g')
do
echo "nameserver ${_NAMESERVER}" >> /etc/resolv.conf
done
echo " done."
fi
# set the hostname
echo -n "P: Creating file /etc/hostname..."
echo "${LINUX_CONTAINER_HOSTNAME}" > /etc/hostname
echo " done."
# remove pointless services in a container
for _SERVICE in checkroot.sh hwclockfirst.sh hwclock.sh module-init-tools umountfs umountroot
do
if [ -e "/etc/init.d/${_SERVICE}" ]
then
echo -n "P: Disabling service ${_SERVICE}..."
update-rc.d -f ${_SERVICE} disable | \
grep -v "update-rc.d: using dependency based boot sequencing" || true
echo " done."
fi
done
# Recreating openssh-server host keys
if [ ! -e /etc/ssh/ssh_host_rsa_key ] && [ -x /usr/bin/ssh-keygen ]
then
echo -n "P: Creating files /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key.pub..."
ssh-keygen -q -f /etc/ssh/ssh_host_rsa_key -N "" -t rsa
echo " done."
fi
if [ ! -e /etc/ssh/ssh_host_dsa_key ] && [ -x /usr/bin/ssh-keygen ]
then
echo -n "P: Creating files /etc/ssh/ssh_host_dsa_key /etc/ssh/ssh_host_dsa_key.pub..."
ssh-keygen -q -f /etc/ssh/ssh_host_dsa_key -N "" -t dsa
echo " done."
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`${1}'" >&2
exit 1
;;
esac
exit 0
|