Compare commits
No commits in common. "master" and "nilmbuntu-5" have entirely different histories.
master
...
nilmbuntu-
|
@ -1,44 +1,49 @@
|
||||||
Nilmbuntu
|
|
||||||
=========
|
|
||||||
|
|
||||||
Tools to customize an Ubuntu Live CD. Many parts of this will end up
|
Tools to customize an Ubuntu Live CD. Many parts of this will end up
|
||||||
being version-specific. The host machine must be running systemd,
|
being version-specific. The host machine must be running systemd,
|
||||||
since the image is executed inside a systemd-nspawn container.
|
since the image is executed inside a systemd-nspawn container.
|
||||||
|
|
||||||
Set up host machine:
|
Set up host machine, which must be running a recent systemd:
|
||||||
|
|
||||||
sudo apt install squashfs-tools xorriso isolinux systemd-container iptables
|
sudo apt install squashfs-tools xorriso isolinux systemd-container iptables
|
||||||
sudo systemctl start systemd-networkd
|
sudo systemctl start systemd-networkd
|
||||||
|
|
||||||
Choose a config:
|
Choose a config:
|
||||||
|
|
||||||
export BUILD_CONFIG=20.04.1
|
export BUILD_CONFIG=16.04
|
||||||
|
|
||||||
Download and extract the original ISO:
|
Download and extract the original ISO:
|
||||||
|
|
||||||
./extractiso.sh
|
./extractiso.sh
|
||||||
|
|
||||||
Apply customizations, both to the outer ISO and the inner image.
|
Apply customizations, both to the outer ISO and the inner image.
|
||||||
This will also run customizer-inner.sh inside a container:
|
This will also run customizer-inner.sh inside a container:
|
||||||
|
|
||||||
./customize.sh
|
./customize.sh
|
||||||
|
|
||||||
(Optional) Run and enter a shell in the container, for manual customization:
|
(Optional) Run and enter a shell in the container, for manual customization:
|
||||||
|
|
||||||
./enter.sh
|
./enter.sh
|
||||||
|
|
||||||
Build the new ISO:
|
Build the new ISO:
|
||||||
|
|
||||||
./buildiso.sh
|
./buildiso.sh
|
||||||
|
|
||||||
Boot the ISO in QEMU with a blank HDD, to test and install:
|
Boot the ISO in QEMU with a blank HDD, to test and install:
|
||||||
|
|
||||||
./run.sh -c
|
./run.sh -c
|
||||||
|
|
||||||
Boot QEMU with the same HDD image as above, to test an "installed" system:
|
Boot QEMU with the same HDD image as above, to test an "installed" system:
|
||||||
|
|
||||||
./run.sh -d
|
./run.sh -d
|
||||||
|
|
||||||
Remove everything but the ISOs:
|
Remove everything but the ISOs:
|
||||||
|
|
||||||
./cleanup.sh
|
./cleanup.sh
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
- A more proper way to build a distro from scratch would be something
|
||||||
|
like one of these, except that they're out of date:
|
||||||
|
|
||||||
|
http://www.mythbuntu.org/development/developer-cheatsheet (2010)
|
||||||
|
https://github.com/squibbylinux/squibby-build (2012)
|
18
buildiso.sh
18
buildiso.sh
|
@ -15,21 +15,27 @@ fi
|
||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
INITRD=${FS}/boot/initrd.img
|
INITRD=${FS}/initrd.img
|
||||||
VMLINUZ=${FS}/boot/vmlinuz
|
VMLINUZ=$(readlink -f ${FS}/vmlinuz)
|
||||||
|
VMLINUZ_EFI=${VMLINUZ}.efi.signed
|
||||||
|
|
||||||
if ! [ "$1" == "justiso" ] ; then
|
if ! [ "$1" == "justiso" ] ; then
|
||||||
|
|
||||||
if ! [ -r ${INITRD} -a -r ${VMLINUZ} ] ; then
|
|
||||||
|
if ! [ -r ${INITRD} -a -r ${VMLINUZ} -a -r ${VMLINUZ_EFI} ] ; then
|
||||||
set +x
|
set +x
|
||||||
echo "== Missing kernel and/or initrd. Either upgrade or reinstall"
|
echo "== Missing kernel and/or initrd. Either upgrade or reinstall"
|
||||||
echo "== the kernel inside the image to get the right files."
|
echo "== the kernel inside the image to get the right files."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy kernel and initrd
|
# Recompress initrd if changed
|
||||||
cp ${INITRD} ${ISO}/casper/initrd
|
if [ ${INITRD} -nt ${ISO}/casper/initrd.lz ] ; then
|
||||||
|
sh -c "zcat ${INITRD} | lzma > ${ISO}/casper/initrd.lz"
|
||||||
|
fi
|
||||||
|
# Get kernel and signed EFI kernel
|
||||||
cp ${VMLINUZ} ${ISO}/casper/vmlinuz
|
cp ${VMLINUZ} ${ISO}/casper/vmlinuz
|
||||||
|
cp ${VMLINUZ_EFI} ${ISO}/casper/vmlinuz.efi
|
||||||
|
|
||||||
# manifests
|
# manifests
|
||||||
chmod +w ${ISO}/casper/filesystem.manifest
|
chmod +w ${ISO}/casper/filesystem.manifest
|
||||||
|
@ -45,7 +51,7 @@ if ! [ "$1" == "justiso" ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# md5sums
|
# md5sums
|
||||||
rm -f ${ISO}/md5sum.txt
|
rm -f md5sum.txt
|
||||||
find ${ISO} -type f -print0 \
|
find ${ISO} -type f -print0 \
|
||||||
| xargs -0 md5sum \
|
| xargs -0 md5sum \
|
||||||
| sed -e "s, ${ISO}, .," \
|
| sed -e "s, ${ISO}, .," \
|
||||||
|
|
2
config
2
config
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -z "$BUILD_CONFIG" ] ; then
|
if [ -z "$BUILD_CONFIG" ] ; then
|
||||||
export BUILD_CONFIG=20.04.1
|
export BUILD_CONFIG=16.04.1
|
||||||
echo "No BUILD_CONFIG set -- assuming $BUILD_CONFIG"
|
echo "No BUILD_CONFIG set -- assuming $BUILD_CONFIG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- sh -*-
|
# -*- sh -*-
|
||||||
|
|
||||||
# output image
|
# output image
|
||||||
VERSION="20.04.1"
|
VERSION="16.04.1"
|
||||||
OUTPUT="nilmbuntu-${VERSION}.iso"
|
OUTPUT="nilmbuntu-${VERSION}.iso"
|
||||||
|
|
||||||
# original ISO
|
# original ISO
|
221
customize-inner.sh
Normal file
221
customize-inner.sh
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$IN_CHROOT" != "1" ] ; then
|
||||||
|
echo This is supposed to run inside the chroot, oops
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# Set up live username and hostname
|
||||||
|
cat >/etc/casper.conf <<"EOF"
|
||||||
|
export USERNAME="nilm"
|
||||||
|
export USERFULLNAME="NILM User"
|
||||||
|
export HOST="nilmbuntu"
|
||||||
|
export BUILD_SYSTEM="Ubuntu"
|
||||||
|
export FLAVOUR="NILMbuntu"
|
||||||
|
|
||||||
|
# Do the inital user setup even though UID 1000 already exists.
|
||||||
|
# This also needs to be set in /etc/environment, for ubiquity,
|
||||||
|
# but we do that in preseed/early_command so that it only shows
|
||||||
|
# up in the LiveCD image.
|
||||||
|
export OVERRIDE_SYSTEM_USER=true
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Set up NILM-specific stuff to get added to /etc/hosts after installation
|
||||||
|
cat >/etc/hosts.nilm <<"EOF"
|
||||||
|
127.0.2.1 nilm.primary
|
||||||
|
127.0.2.2 nilm.secondary
|
||||||
|
EOF
|
||||||
|
# And copy it for now (although it will get overwritten at boot)
|
||||||
|
cat /etc/hosts.nilm >> /etc/hosts
|
||||||
|
|
||||||
|
# Upgrade packages
|
||||||
|
apt update
|
||||||
|
apt -y dist-upgrade
|
||||||
|
apt -y --purge autoremove
|
||||||
|
|
||||||
|
# Remove old kernels, and reinstall the latest one (to make sure
|
||||||
|
# it's present in /boot)
|
||||||
|
LATEST_KERNEL=$(ls --sort=version /lib/modules/ | tail -n 1)
|
||||||
|
for VER in $(ls --sort=version /lib/modules/) ; do
|
||||||
|
if [ $VER != $LATEST_KERNEL ] ; then
|
||||||
|
apt -y --purge remove "linux-.*$VER"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
apt -y --reinstall install linux-{,signed-}image-${LATEST_KERNEL}
|
||||||
|
|
||||||
|
# Disable upgrade popups
|
||||||
|
sed -i -s -e 's/Prompt=.*/Prompt=never/g' \
|
||||||
|
/etc/update-manager/release-upgrades || true
|
||||||
|
|
||||||
|
# Set up & install postfix for local mail delivery
|
||||||
|
debconf-set-selections <<"EOF"
|
||||||
|
postfix postfix/mailname string localdomain
|
||||||
|
postfix postfix/main_mailer_type select Local only
|
||||||
|
EOF
|
||||||
|
apt -y install postfix
|
||||||
|
|
||||||
|
# Required packages
|
||||||
|
apt -y install \
|
||||||
|
python3 \
|
||||||
|
python2.7 \
|
||||||
|
python2.7-dev \
|
||||||
|
python-setuptools \
|
||||||
|
python-pip \
|
||||||
|
cython \
|
||||||
|
git \
|
||||||
|
build-essential \
|
||||||
|
python-cherrypy3 \
|
||||||
|
python-decorator \
|
||||||
|
python-simplejson \
|
||||||
|
python-requests \
|
||||||
|
python-dateutil \
|
||||||
|
python-tz \
|
||||||
|
python-progressbar \
|
||||||
|
python-psutil \
|
||||||
|
python-numpy \
|
||||||
|
python-nose \
|
||||||
|
python-coverage \
|
||||||
|
apache2 \
|
||||||
|
libapache2-mod-wsgi \
|
||||||
|
python-scipy \
|
||||||
|
python-daemon
|
||||||
|
|
||||||
|
# Install other useful stuff
|
||||||
|
apt -y install \
|
||||||
|
adb \
|
||||||
|
avrdude \
|
||||||
|
chromium-browser \
|
||||||
|
curl \
|
||||||
|
debconf-utils \
|
||||||
|
devscripts \
|
||||||
|
dfu-programmer \
|
||||||
|
dlocate \
|
||||||
|
emacs \
|
||||||
|
emacs-goodies-el \
|
||||||
|
esptool \
|
||||||
|
flashrom \
|
||||||
|
gcc-arm-none-eabi \
|
||||||
|
gcc-avr \
|
||||||
|
gdb-arm-none-eabi \
|
||||||
|
gddrescue \
|
||||||
|
gnuplot \
|
||||||
|
help2man \
|
||||||
|
ipython \
|
||||||
|
libnewlib-arm-none-eabi \
|
||||||
|
libreoffice \
|
||||||
|
libstdc++-arm-none-eabi-newlib \
|
||||||
|
texlive \
|
||||||
|
mailutils \
|
||||||
|
moreutils \
|
||||||
|
mutt \
|
||||||
|
network-manager-openvpn-gnome \
|
||||||
|
octave \
|
||||||
|
octave-missing-functions \
|
||||||
|
octave-signal \
|
||||||
|
openocd \
|
||||||
|
openssh-server \
|
||||||
|
openssl \
|
||||||
|
openvpn \
|
||||||
|
python-matplotlib \
|
||||||
|
screen \
|
||||||
|
sigrok \
|
||||||
|
silversearcher-ag \
|
||||||
|
subversion \
|
||||||
|
tcpdump \
|
||||||
|
zip
|
||||||
|
|
||||||
|
# Install the packages required for en_US language support
|
||||||
|
# This avoids a prompt and package download at first install
|
||||||
|
apt -y install $(/usr/bin/check-language-support -l en_US)
|
||||||
|
|
||||||
|
# Set up timezone to America/New_York for the live CD
|
||||||
|
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
|
||||||
|
dpkg-reconfigure -f noninteractive tzdata
|
||||||
|
|
||||||
|
# Put some default desktop shortcuts in place
|
||||||
|
DESKTOP=/etc/skel/Desktop
|
||||||
|
mkdir -p $DESKTOP
|
||||||
|
cp /usr/share/applications/exo-terminal-emulator.desktop $DESKTOP || true
|
||||||
|
cp /usr/share/applications/exo-web-browser.desktop $DESKTOP || true
|
||||||
|
chmod +x $DESKTOP/*
|
||||||
|
|
||||||
|
# Custom background image (which was already copied in by customize.sh)
|
||||||
|
XML=/etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
|
||||||
|
BG=/usr/share/xfce4/backdrops/nilmbuntu.png
|
||||||
|
apt -y install xmlstarlet
|
||||||
|
xmlstarlet ed -L -u "//property[@name='image-path']/@value" -v "$BG" $XML
|
||||||
|
xmlstarlet ed -L -u "//property[@name='image-style']/@value" -v "3" $XML
|
||||||
|
|
||||||
|
# Configure Firefox with our default homepage (now irrelevant since
|
||||||
|
# it won't be the default browser)
|
||||||
|
HOMEPAGE="http://www.wattsworth.net/"
|
||||||
|
cat >/etc/firefox/syspref.js <<EOF
|
||||||
|
pref("browser.startup.homepage", "${HOMEPAGE}");
|
||||||
|
pref("extensions.ubufox@ubuntu.com.custom_homepage", "${HOMEPAGE}");
|
||||||
|
pref("browser.startup.homepage_override.mstone", "ignore");
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Set up Chromium as default browser
|
||||||
|
update-alternatives --set x-www-browser /usr/bin/chromium-browser
|
||||||
|
update-alternatives --set gnome-www-browser /usr/bin/chromium-browser
|
||||||
|
mkdir -p /etc/skel/.config/xfce4
|
||||||
|
cat >/etc/skel/.config/xfce4/helpers.rc <<"EOF"
|
||||||
|
WebBrowser=chromium-browser
|
||||||
|
EOF
|
||||||
|
mkdir -p /etc/skel/.local/share/xfce4/helpers
|
||||||
|
cat >/etc/skel/.local/share/xfce4/helpers/chromium-browser.desktop <<"EOF"
|
||||||
|
[Desktop Entry]
|
||||||
|
Version=1.0
|
||||||
|
Name=Chromium Web Browser
|
||||||
|
X-XFCE-Category=WebBrowser
|
||||||
|
X-XFCE-Commands=chromium-browser
|
||||||
|
X-XFCE-CommandsWithParameter=chromium-browser "%s"
|
||||||
|
Exec=chromium-browser %U
|
||||||
|
Type=X-XFCE-Helper
|
||||||
|
Icon=chromium-browser
|
||||||
|
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;
|
||||||
|
StartupNotify=true
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Make Chromium a little nicer:
|
||||||
|
# - No first run
|
||||||
|
mkdir -p /etc/skel/.config/chromium/Default
|
||||||
|
touch '/etc/skel/.config/chromium/First Run'
|
||||||
|
# - Set up some default bookmarks on the bookmark bar
|
||||||
|
cat >/etc/skel/.config/chromium/Default/Bookmarks <<"EOF"
|
||||||
|
{ "version": 1, "roots": {
|
||||||
|
"other": { "id": "2", "name": "Other bookmarks", "type": "folder",
|
||||||
|
"children": [ ] },
|
||||||
|
"synced": { "id": "3", "name": "Mobile bookmarks", "type": "folder",
|
||||||
|
"children": [ ] },
|
||||||
|
"bookmark_bar": { "id": "1", "name": "Bookmarks bar", "type": "folder",
|
||||||
|
"children": [ {
|
||||||
|
"id": "6", "type": "url",
|
||||||
|
"name": "Wattsworth",
|
||||||
|
"url": "http://www.wattsworth.net/"
|
||||||
|
}, {
|
||||||
|
"id": "7", "type": "url",
|
||||||
|
"name": "Standalone NILM",
|
||||||
|
"type": "url",
|
||||||
|
"url": "http://nilm.primary/"
|
||||||
|
} ] }
|
||||||
|
} }
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
# Create NILM user. This should happen after anything that we put in
|
||||||
|
# /etc/skel, since files get copied from there. Note that this user
|
||||||
|
# is the same as what we have in the preseed file and casper.conf
|
||||||
|
if ! getent passwd nilm ; then
|
||||||
|
adduser --gecos "NILM User" --disabled-password nilm
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure locate databases are up-to-date
|
||||||
|
/etc/cron.daily/mlocate
|
||||||
|
/etc/cron.daily/dlocate
|
||||||
|
|
||||||
|
# Make sure initramfs was regenerated with casper changes
|
||||||
|
update-initramfs -u
|
19
customize.sh
19
customize.sh
|
@ -15,19 +15,18 @@ echo "NILMbuntu $VERSION" > ${ISO}/.disk/info
|
||||||
|
|
||||||
# Set up preseed file by appending preseed.cfg to the Xubuntu
|
# Set up preseed file by appending preseed.cfg to the Xubuntu
|
||||||
# default one
|
# default one
|
||||||
cat ${ISO}/preseed/xubuntu.seed files/preseed.cfg > ${ISO}/preseed/nilmbuntu.seed
|
cat ${ISO}/preseed/xubuntu.seed preseed.cfg > ${ISO}/preseed/nilmbuntu.seed
|
||||||
|
|
||||||
# Set up isolinux how we want by editing its config
|
# Set up isolinux how we want by editing its config
|
||||||
TRY="Boot ^NILMbuntu ${VERSION}"
|
TRY="Boot ^NILMbuntu ${VERSION}"
|
||||||
cp files/splash.png ${ISO}/isolinux/splash.png
|
cp splash.png ${ISO}/isolinux/splash.png
|
||||||
perl -n -i \
|
perl -n -i \
|
||||||
-e '$n=1 if /^label/; $n=2 if /^label live-install/; next if $n==2;' \
|
-e '$n=1 if /^label/; $n=2 if /^label live-install/; next if $n==2;' \
|
||||||
-e "s/menu label.*Try Xubuntu without installing/menu label $TRY/g;" \
|
-e "s/menu label.*(Try|NILM).*/menu label $TRY/g;" \
|
||||||
-e "s,preseed/.*[.]seed,preseed/nilmbuntu.seed,g;" \
|
-e "s,preseed/.*[.]seed,preseed/nilmbuntu.seed,g;" \
|
||||||
-e "s/ quiet splash//g;" \
|
-e "s/ quiet splash//g;" \
|
||||||
-e "print;" \
|
-e "print;" \
|
||||||
${ISO}/isolinux/txt.cfg
|
${ISO}/isolinux/txt.cfg
|
||||||
sed -i -s -e "s/^menu margin .*/menu margin 2/g;" ${ISO}/isolinux/menu.cfg
|
|
||||||
sed -i -s -e "s/^ui gfxboot/# ui gfxboot/g;" ${ISO}/isolinux/isolinux.cfg
|
sed -i -s -e "s/^ui gfxboot/# ui gfxboot/g;" ${ISO}/isolinux/isolinux.cfg
|
||||||
|
|
||||||
# Set up grub similarly
|
# Set up grub similarly
|
||||||
|
@ -35,20 +34,18 @@ TRY="Boot NILMbuntu ${VERSION}"
|
||||||
perl -n -i \
|
perl -n -i \
|
||||||
-e "next if /menuentry \"Install/../^}$/;" \
|
-e "next if /menuentry \"Install/../^}$/;" \
|
||||||
-e "next if /menuentry \"OEM install/../^}$/;" \
|
-e "next if /menuentry \"OEM install/../^}$/;" \
|
||||||
-e "s/Try Xubuntu without installing/${TRY}/g;" \
|
-e "s/menuentry \"(Try|NILM).*\" \{/menuentry \"${TRY}\" {/g;" \
|
||||||
-e "s,preseed/.*[.]seed,preseed/nilmbuntu.seed,g;" \
|
-e "s,preseed/.*[.]seed,preseed/nilmbuntu.seed,g;" \
|
||||||
-e "s/ quiet splash//g;" \
|
-e "s/ quiet splash//g;" \
|
||||||
-e "print;" \
|
-e "print;" \
|
||||||
${ISO}/boot/grub/{grub,loopback}.cfg
|
${ISO}/boot/grub/{grub,loopback}.cfg
|
||||||
|
|
||||||
# Prevent some packages from being removed after install
|
|
||||||
perl -n -i -e 'print unless /gparted/' ${ISO}/casper/filesystem.manifest-remove
|
|
||||||
|
|
||||||
sudo install -D -m 0644 files/fallback_dns.conf ${FS}/etc/systemd/resolved.conf.d/fallback_dns.conf
|
|
||||||
|
|
||||||
if ! [ "$1" == "skip" ] ; then
|
if ! [ "$1" == "skip" ] ; then
|
||||||
|
|
||||||
# Run the customize-inner.sh script inside the chroot
|
# Run the customize-inner.sh script inside the chroot
|
||||||
./enter.sh "cd /root ; files/customize-inner.sh"
|
sudo cp nilmbuntu.png ${FS}/usr/share/xfce4/backdrops/nilmbuntu.png
|
||||||
|
sudo cp customize-inner.sh ${FS}/root/customize-inner.sh
|
||||||
|
sudo chmod +x ${FS}/root/customize-inner.sh
|
||||||
|
./enter.sh "cd /root ; ./customize-inner.sh"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
34
enter.sh
34
enter.sh
|
@ -13,8 +13,8 @@ fi
|
||||||
# both). Instead let's execute systemd-nspawn in a transient systemd
|
# both). Instead let's execute systemd-nspawn in a transient systemd
|
||||||
# unit, then enter it using machinectl.
|
# unit, then enter it using machinectl.
|
||||||
|
|
||||||
UNIT=nilmbuntu-run-$NONPRIV_UID-$VERSION
|
UNIT=nilmbuntu-run-$VERSION
|
||||||
MACH=nilmbuntu-$NONPRIV_UID-$VERSION
|
MACH=nilmbuntu-$VERSION
|
||||||
|
|
||||||
setup_networking() {
|
setup_networking() {
|
||||||
# We use a virtual ethernet adapter -- this requires that
|
# We use a virtual ethernet adapter -- this requires that
|
||||||
|
@ -26,10 +26,10 @@ setup_networking() {
|
||||||
|
|
||||||
# However, the current systemd-networkd from Debian is broken and
|
# However, the current systemd-networkd from Debian is broken and
|
||||||
# won't enable masquerading -- so do it manually
|
# won't enable masquerading -- so do it manually
|
||||||
# IFACE=$(ip -4 route list default | head -1 | awk '{print $5}')
|
IFACE=$(ip -4 route list default | head -1 | awk '{print $5}')
|
||||||
# echo 1 > /proc/sys/net/ipv4/ip_forward
|
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||||
# iptables -t nat -D POSTROUTING -o $IFACE -j MASQUERADE >/dev/null || true
|
iptables -t nat -D POSTROUTING -o $IFACE -j MASQUERADE >/dev/null || true
|
||||||
# iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE
|
iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE
|
||||||
}
|
}
|
||||||
|
|
||||||
kill_container() {
|
kill_container() {
|
||||||
|
@ -99,14 +99,21 @@ run() {
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
rsync -avP --delete files/ ${FS}/root/files/
|
|
||||||
|
|
||||||
setup_networking
|
setup_networking
|
||||||
start_container
|
start_container
|
||||||
|
|
||||||
|
run "resolvconf --disable-updates"
|
||||||
|
run "echo 'nameserver 8.8.8.8' > /run/resolvconf/resolv.conf"
|
||||||
|
run "echo '127.0.0.1 localhost' > /etc/hosts"
|
||||||
run "cat /etc/hosts.nilm >>/etc/hosts 2>/dev/null || true"
|
run "cat /etc/hosts.nilm >>/etc/hosts 2>/dev/null || true"
|
||||||
run "hostnamectl --transient set-hostname nilmbuntu"
|
run "hostnamectl --transient set-hostname nilmbuntu"
|
||||||
|
|
||||||
|
#run "dbus-uuidgen > /var/lib/dbus/machine-id"
|
||||||
|
#run "dpkg-divert --local --rename --add /sbin/initctl"
|
||||||
|
#run "ln -sf /bin/true /sbin/initctl"
|
||||||
|
#run "dpkg-divert --local --rename --add /usr/sbin/update-grub"
|
||||||
|
#run "ln -sf /bin/true /usr/sbin/update-grub"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
if [ -z "$1" ] ; then
|
if [ -z "$1" ] ; then
|
||||||
run "exec bash"
|
run "exec bash"
|
||||||
|
@ -119,15 +126,20 @@ echo "Cleaning up..."
|
||||||
# Manually clean up some things that show up after booting an image
|
# Manually clean up some things that show up after booting an image
|
||||||
# and installing packages. This doesn't get everything, but what's
|
# and installing packages. This doesn't get everything, but what's
|
||||||
# left should be fine.
|
# left should be fine.
|
||||||
run "apt clean"
|
run "apt-get clean"
|
||||||
run "dpkg --clear-avail"
|
|
||||||
run "> /etc/machine-id"
|
run "> /etc/machine-id"
|
||||||
run "rm -f /core /boot/grub/grubenv"
|
run "rm -f /core /boot/grub/grubenv"
|
||||||
run "rm -f /var/lib/systemd/random-seed"
|
run "rm -f /var/lib/systemd/random-seed"
|
||||||
run "rm -f /var/lib/ubuntu-drivers-common/last_gfx_boot"
|
run "rm -f /var/lib/ubuntu-drivers-common/last_gfx_boot"
|
||||||
run "rm -f /var/lib/NetworkManager/*"
|
run "rm -f /var/lib/NetworkManager/*"
|
||||||
run "rm -f /root/.bash_history"
|
run "rm -f /root/.bash_history"
|
||||||
run "rm -rf /root/files"
|
|
||||||
|
#run "rm /sbin/initctl"
|
||||||
|
#run "dpkg-divert --rename --remove /sbin/initctl"
|
||||||
|
#run "rm /usr/sbin/update-grub"
|
||||||
|
#run "dpkg-divert --rename --remove /usr/sbin/update-grub"
|
||||||
|
#run "rm /var/lib/dbus/machine-id"
|
||||||
|
#run "> /etc/resolv.conf"
|
||||||
|
|
||||||
kill_container
|
kill_container
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
export USERNAME="nilm"
|
|
||||||
export USERFULLNAME="NILM User"
|
|
||||||
export HOST="nilmbuntu-live"
|
|
||||||
export BUILD_SYSTEM="Ubuntu"
|
|
||||||
export FLAVOUR="NILMbuntu"
|
|
||||||
|
|
||||||
# Do the inital user setup even though UID 1000 already exists.
|
|
||||||
# This also needs to be set in /etc/environment, for ubiquity,
|
|
||||||
# but we do that in preseed/early_command so that it only shows
|
|
||||||
# up in the LiveCD image.
|
|
||||||
export OVERRIDE_SYSTEM_USER=true
|
|
||||||
|
|
||||||
# The ISO has a UUID stored in /.disk/casper-uuid-generic, which
|
|
||||||
# won't match the new UUID that update-initramfs put in /conf/uuid.conf,
|
|
||||||
# so it won't find the live media at casper boot.
|
|
||||||
# Easiest way to avoid this is to set a blank UUID, so that the
|
|
||||||
# UUID checks are skipped.
|
|
||||||
export UUID=""
|
|
|
@ -1,140 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ "$IN_CHROOT" != "1" ] ; then
|
|
||||||
echo This is supposed to run inside the chroot, oops
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# Move stuff to the right places
|
|
||||||
install -D -m 0644 files/nilmbuntu.png /usr/share/xfce4/backdrops/nilmbuntu.png
|
|
||||||
install -D -m 0644 files/casper.conf /etc/casper.conf
|
|
||||||
install -D -m 0644 files/hosts.nilm /etc/hosts.nilm
|
|
||||||
|
|
||||||
# Disable apport crash reporting
|
|
||||||
sed -i -s -e 's/enabled=1/enabled=0/g' /etc/default/apport
|
|
||||||
|
|
||||||
# Copy hosts for now (although it will get overwritten at boot)
|
|
||||||
cat /etc/hosts.nilm >> /etc/hosts
|
|
||||||
|
|
||||||
# Upgrade packages
|
|
||||||
apt update
|
|
||||||
apt -y dist-upgrade
|
|
||||||
apt -y --purge autoremove
|
|
||||||
|
|
||||||
# Remove old kernels, and reinstall the latest one (to make sure
|
|
||||||
# it's present in /boot)
|
|
||||||
LATEST_KERNEL=$(ls --sort=version /lib/modules/ | tail -n 1)
|
|
||||||
for VER in $(ls --sort=version /lib/modules/) ; do
|
|
||||||
if [ $VER != $LATEST_KERNEL ] ; then
|
|
||||||
apt -y --purge remove "linux-.*$VER"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
apt -y --reinstall install linux-image-${LATEST_KERNEL}
|
|
||||||
|
|
||||||
# Disable upgrade popups
|
|
||||||
sed -i -s -e 's/Prompt=.*/Prompt=never/g' \
|
|
||||||
/etc/update-manager/release-upgrades || true
|
|
||||||
|
|
||||||
# Set up & install postfix for local mail delivery
|
|
||||||
debconf-set-selections <<"EOF"
|
|
||||||
postfix postfix/mailname string localdomain
|
|
||||||
postfix postfix/main_mailer_type select Local only
|
|
||||||
EOF
|
|
||||||
apt -y install postfix
|
|
||||||
|
|
||||||
# Required packages
|
|
||||||
apt -y install \
|
|
||||||
python3 \
|
|
||||||
python3-venv \
|
|
||||||
python3-pip \
|
|
||||||
git \
|
|
||||||
build-essential \
|
|
||||||
apache2 \
|
|
||||||
libapache2-mod-wsgi
|
|
||||||
|
|
||||||
# Install other useful stuff
|
|
||||||
apt -y install \
|
|
||||||
adb \
|
|
||||||
avrdude \
|
|
||||||
curl \
|
|
||||||
debconf-utils \
|
|
||||||
devscripts \
|
|
||||||
dfu-programmer \
|
|
||||||
dlocate \
|
|
||||||
emacs \
|
|
||||||
emacs-goodies-el \
|
|
||||||
esptool \
|
|
||||||
firefox \
|
|
||||||
flashrom \
|
|
||||||
gddrescue \
|
|
||||||
git \
|
|
||||||
gnuplot \
|
|
||||||
gparted \
|
|
||||||
help2man \
|
|
||||||
ipython3 \
|
|
||||||
libnewlib-arm-none-eabi \
|
|
||||||
libreoffice \
|
|
||||||
libstdc++-arm-none-eabi-newlib \
|
|
||||||
texlive \
|
|
||||||
mailutils \
|
|
||||||
moreutils \
|
|
||||||
mutt \
|
|
||||||
octave \
|
|
||||||
octave-missing-functions \
|
|
||||||
octave-signal \
|
|
||||||
openocd \
|
|
||||||
openssh-server \
|
|
||||||
openssl \
|
|
||||||
openvpn \
|
|
||||||
screen \
|
|
||||||
silversearcher-ag \
|
|
||||||
tcpdump \
|
|
||||||
zip
|
|
||||||
|
|
||||||
# Install the packages required for en_US language support
|
|
||||||
# This avoids a prompt and package download at first install
|
|
||||||
apt -y install $(/usr/bin/check-language-support -l en_US)
|
|
||||||
|
|
||||||
# Set up timezone to America/New_York for the live CD
|
|
||||||
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
|
|
||||||
dpkg-reconfigure -f noninteractive tzdata
|
|
||||||
|
|
||||||
# Put some default desktop shortcuts in place
|
|
||||||
DESKTOP=/etc/skel/Desktop
|
|
||||||
mkdir -p $DESKTOP
|
|
||||||
cp /usr/share/applications/exo-terminal-emulator.desktop $DESKTOP || true
|
|
||||||
cp /usr/share/applications/exo-web-browser.desktop $DESKTOP || true
|
|
||||||
chmod +x $DESKTOP/*
|
|
||||||
|
|
||||||
# Custom background image
|
|
||||||
XML=/etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
|
|
||||||
BG=/usr/share/xfce4/backdrops/nilmbuntu.png
|
|
||||||
apt -y install xmlstarlet
|
|
||||||
xmlstarlet ed -L -u "//property[@name='image-path']/@value" -v "$BG" $XML
|
|
||||||
xmlstarlet ed -L -u "//property[@name='image-style']/@value" -v "3" $XML
|
|
||||||
|
|
||||||
# Make Firefox nicer
|
|
||||||
install -D -m 0644 files/syspref.js /etc/firefox/syspref.js
|
|
||||||
|
|
||||||
# Create NILM user. This should happen after anything that we put in
|
|
||||||
# /etc/skel, since files get copied from there. Note that this user
|
|
||||||
# is the same as what we have in the preseed file and casper.conf
|
|
||||||
if ! getent passwd nilm ; then
|
|
||||||
adduser --gecos "NILM User" --disabled-password nilm
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure locate databases are up-to-date
|
|
||||||
/etc/cron.daily/mlocate
|
|
||||||
/etc/cron.daily/dlocate
|
|
||||||
|
|
||||||
# Make sure initramfs was regenerated with casper changes.
|
|
||||||
# Manipulate some config files to avoid host stuff leaking through.
|
|
||||||
echo 'RESUME=none' > /etc/initramfs-tools/conf.d/resume
|
|
||||||
mv /etc/crypttab /etc/crypttab-old
|
|
||||||
CASPER_GENERATE_UUID=1 update-initramfs -u
|
|
||||||
rm /etc/initramfs-tools/conf.d/resume
|
|
||||||
mv /etc/crypttab-old /etc/crypttab
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[Resolve]
|
|
||||||
FallbackDNS=1.1.1.1 9.9.9.10 8.8.8.8 2606:4700:4700::1111 2620:fe::10 2001:4860:4860::8888
|
|
|
@ -1,2 +0,0 @@
|
||||||
127.0.2.1 nilm.primary
|
|
||||||
127.0.2.2 nilm.secondary
|
|
|
@ -1,16 +0,0 @@
|
||||||
pref("browser.aboutwelcome.enabled", false);
|
|
||||||
pref("datareporting.policy.firstRunURL", "");
|
|
||||||
pref("network.trr.mode", 5);
|
|
||||||
pref("toolkit.telemetry.reportingpolicy.firstRun", false);
|
|
||||||
pref("browser.startup.homepage_override.mstone", "ignore");
|
|
||||||
pref("trailhead.firstrun.didSeeAboutWelcome", true);
|
|
||||||
|
|
||||||
pref("browser.newtabpage.activity-stream.default.sites","https://www.google.com/");
|
|
||||||
pref("browser.newtabpage.activity-stream.feeds.asrouterfeed", false);
|
|
||||||
pref("browser.newtabpage.activity-stream.feeds.discoverystreamfeed", false);
|
|
||||||
pref("browser.newtabpage.activity-stream.feeds.section.highlights", false);
|
|
||||||
pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);
|
|
||||||
pref("browser.newtabpage.activity-stream.feeds.snippets", false);
|
|
||||||
pref("browser.newtabpage.activity-stream.section.highlights.includePocket", false);
|
|
||||||
pref("browser.newtabpage.pinned", "[{\"url\":\"https://www.wattsworth.net\",\"label\":\"Wattsworth\"},{\"url\":\"http://nilm.primary\",\"label\":\"Local NILM\"}]");
|
|
||||||
pref("browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts", false);
|
|
Before Width: | Height: | Size: 589 KiB After Width: | Height: | Size: 589 KiB |
|
@ -53,6 +53,3 @@ d-i user-setup/allow-password-weak boolean true
|
||||||
d-i user-setup/force-encrypt-home boolean false
|
d-i user-setup/force-encrypt-home boolean false
|
||||||
d-i user-setup/encrypt-home boolean false
|
d-i user-setup/encrypt-home boolean false
|
||||||
d-i passwd/auto-login boolean true
|
d-i passwd/auto-login boolean true
|
||||||
|
|
||||||
d-i netcfg/get_hostname seen true
|
|
||||||
d-i netcfg/get_hostname string nilmbuntu
|
|
11
run.sh
11
run.sh
|
@ -47,22 +47,19 @@ set -x
|
||||||
|
|
||||||
cfg=""
|
cfg=""
|
||||||
|
|
||||||
cfg+=" -nodefaults"
|
|
||||||
cfg+=" -drive file=${DISK},media=disk,format=raw,if=virtio"
|
cfg+=" -drive file=${DISK},media=disk,format=raw,if=virtio"
|
||||||
cfg+=" -enable-kvm"
|
cfg+=" -enable-kvm"
|
||||||
cfg+=" -m 2048"
|
cfg+=" -m 2048"
|
||||||
cfg+=" -usb"
|
cfg+=" -usbdevice tablet"
|
||||||
cfg+=" -device usb-tablet"
|
|
||||||
cfg+=" -nic user"
|
cfg+=" -vga vmware"
|
||||||
cfg+=" -vga virtio"
|
|
||||||
cfg+=" -k en-us"
|
|
||||||
#cfg+=" -vnc :0"
|
#cfg+=" -vnc :0"
|
||||||
|
|
||||||
case $boot in
|
case $boot in
|
||||||
c)
|
c)
|
||||||
echo "booting CD with empty disk"
|
echo "booting CD with empty disk"
|
||||||
rm -f ${DISK}
|
rm -f ${DISK}
|
||||||
dd if=/dev/zero "of=${DISK}" bs=1M count=0 seek=24576
|
dd if=/dev/zero "of=${DISK}" bs=1M count=0 seek=30720
|
||||||
cfg+=" -drive file=${iso},media=cdrom,if=none,id=cd"
|
cfg+=" -drive file=${iso},media=cdrom,if=none,id=cd"
|
||||||
cfg+=" -device virtio-scsi-pci -device scsi-cd,drive=cd"
|
cfg+=" -device virtio-scsi-pci -device scsi-cd,drive=cd"
|
||||||
cfg+=" -boot d"
|
cfg+=" -boot d"
|
||||||
|
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user