This file is indexed.

preinst is in lxc 1.0.10-0ubuntu1.1.

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
#!/bin/sh

set -e

write_lxc_net()
{
    local i=$1
    cat >> /etc/default/lxc-net << EOF
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
# containers.  Set to "false" if you'll use virbr0 or another existing
# bridge, or mavlan to your host's NIC.
USE_LXC_BRIDGE="true"

# If you change the LXC_BRIDGE to something other than lxcbr0, then
# you will also need to update your /etc/lxc/default.conf as well as the
# configuration (/var/lib/lxc/<container>/config) for any containers
# already created using the default config to reflect the new bridge
# name.
# If you have the dnsmasq daemon installed, you'll also have to update
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.$i.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.$i.0/24"
LXC_DHCP_RANGE="10.0.$i.2,10.0.$i.254"
LXC_DHCP_MAX="253"
# Uncomment the next line if you'd like to use a conf-file for the lxcbr0
# dnsmasq.  For instance, you can use 'dhcp-host=mail1,10.0.3.100' to have
# container 'mail1' always get ip address 10.0.3.100.
#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf

# Uncomment the next line if you want lxcbr0's dnsmasq to resolve the .lxc
# domain.  You can then add "server=/lxc/10.0.3.1' (or your actual $LXC_ADDR)
# to /etc/dnsmasq.conf, after which 'container1.lxc' will resolve on your
# host.
#LXC_DOMAIN="lxc"
EOF
}

configure_lxcbr0()
{
    local i=3
    cat > /etc/default/lxc-net << EOF
# This file is auto-generated by lxc.postinst if it does not
# exist.  Customizations will not be overridden.
EOF
    # if lxcbr0 exists, keep using the same network
    if  ip addr show lxcbr0 > /dev/null 2>&1 ; then
        i=`ip addr show lxcbr0 | grep "inet\>" | awk '{ print $2 }' | awk -F. '{ print $3 }'`
        write_lxc_net $i
        return
    fi
    # if no lxcbr0, find an open 10.0.a.0 network
    for l in `ip addr show | grep "inet\>" |awk '{ print $2 }' | grep '^10\.0\.' | sort -n`; do
            j=`echo $l | awk -F. '{ print $3 }'`
            if [ $j -gt $i ]; then
                write_lxc_net $i
                return
            fi
            i=$((j+1))
    done
    if [ $i -ne 254 ]; then
        write_lxc_net $i
    fi
}

migrate_auto()
{
    echo "Migrating /etc/lxc/auto to lxc.auto.start config flag"
    for container in /etc/lxc/auto/*; do
        [ "$container" = "/etc/lxc/auto/*" ] && continue

        if [ ! -L "$container" ]; then
            echo "$container isn't a symlink, skipping."
        fi

        if [ -d "$container" ] && [ -e "$container/config" ]; then
            echo " - Marking $container/config as auto-started"
            echo "" >> $container/config
            echo "# Added by lxc postinst, migration of autostart flag" >> $container/config
            echo "lxc.start.auto = 1" >> $container/config
        fi

        if [ -f "$container" ]; then
            echo " - Marking $container as auto-started"
            echo "" >> $container
            echo "# Added by lxc postinst, migration of autostart flag" >> $container
            echo "lxc.start.auto = 1" >> $container
        fi

        rm $container
    done

    # Try to remove /etc/lxc/auto (but ignore failure if non-empty)
    rmdir /etc/lxc/auto/ >/dev/null 2>&1 || true
}

case "${1}" in
    install|upgrade)
        if [ ! -f /etc/default/lxc-net ]; then
            configure_lxcbr0
        fi

        if [ -d /etc/lxc/auto ]; then
            migrate_auto
        fi

        if [ ! -f /etc/lxc/lxc-usernet ]; then
            mkdir -p /etc/lxc/
            echo "# USERNAME TYPE BRIDGE COUNT" > /etc/lxc/lxc-usernet
        fi
        ;;
    abort-upgrade)
        ;;
    *)
        echo "preinst called with unknown argument (${1})"
        exit 1
        ;;
esac

# Automatically added by dh_installinit
if [ "$1" = install ] || [ "$1" = upgrade ]; then
	if [ -e "/etc/init.d/lxc" ] && [ -L "/etc/init.d/lxc" ] \
	   && [ $(readlink -f "/etc/init.d/lxc") = /lib/init/upstart-job ]
	then
		rm -f "/etc/init.d/lxc"
	fi
fi
# End automatically added section
# Automatically added by dh_installinit
if [ "$1" = install ] || [ "$1" = upgrade ]; then
	if [ -e "/etc/init.d/lxc-net" ] && [ -L "/etc/init.d/lxc-net" ] \
	   && [ $(readlink -f "/etc/init.d/lxc-net") = /lib/init/upstart-job ]
	then
		rm -f "/etc/init.d/lxc-net"
	fi
fi
# End automatically added section
# Automatically added by dh_installinit
if [ "$1" = install ] || [ "$1" = upgrade ]; then
	if [ -e "/etc/init.d/lxc-instance" ] && [ -L "/etc/init.d/lxc-instance" ] \
	   && [ $(readlink -f "/etc/init.d/lxc-instance") = /lib/init/upstart-job ]
	then
		rm -f "/etc/init.d/lxc-instance"
	fi
fi
# End automatically added section
# Automatically added by dh_installdeb
dpkg-maintscript-helper mv_conffile /etc/apparmor.d/abstractions/lxc-container-default /etc/apparmor.d/abstractions/lxc/container-base 0.8.0~rc1-4ubuntu18 lxc -- "$@"
# End automatically added section
# Automatically added by dh_installdeb
dpkg-maintscript-helper mv_conffile /etc/apparmor.d/abstractions/lxc-start-container /etc/apparmor.d/abstractions/lxc/start-container 0.8.0~rc1-4ubuntu18 lxc -- "$@"
# End automatically added section
# Automatically added by dh_installdeb
dpkg-maintscript-helper mv_conffile /etc/dnsmasq.d/lxc /etc/dnsmasq.d-available/lxc 0.8.0~rc1-4ubuntu48 lxc -- "$@"
# End automatically added section
# Automatically added by dh_installdeb
dpkg-maintscript-helper mv_conffile /etc/lxc/lxc.conf /etc/lxc/default.conf 0.9.0~alpha2-0ubuntu1+b1~bzr1108-28~ lxc -- "$@"
# End automatically added section


exit 0