#!/bin/bash # ensure that this script is run as root if [ $(id -u) -ne 0 ]; then sudo $0 exit fi # set language to english LANG=en_US.UTF-8 # update APT rootfs (Debian and Ubuntu) for DIST in $(find /var/cache/lxc/*/* -maxdepth 0 -type d); do echo "Updating ${DIST} ..." /usr/sbin/chroot "${DIST}" apt-get update -qq /usr/sbin/chroot "${DIST}" apt-get dist-upgrade -qq -y /usr/sbin/chroot "${DIST}" apt-get autoremove -qq -y /usr/sbin/chroot "${DIST}" apt-get clean done >
# fix dns
echo "nameserver 8.8.8.8" > /var/cache/lxc/debian/rootfs-wheezy-amd64/etc/resolv.conf
Cronjob
echo "0 13 * * * root /usr/bin/wget -q --no-check-certificate https://raw.githubusercontent.com/panticz/lxc/master/scripts/lxc-update-templates.sh -O - | bash -" > /etc/cron.d/lxc_update_template
service cron restart
# fix squeeze repository
sed -i 's|cdn.debian.net|ftp.debian.org|g' /var/cache/lxc/debian/rootfs-squeeze-amd64/etc/apt/sources.list