2013-08-17 22:28:49 -04:00
|
|
|
#!/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"
|
2016-07-03 00:18:59 -04:00
|
|
|
export USERNAME="nilm"
|
|
|
|
export USERFULLNAME="NILM User"
|
2016-06-27 16:52:45 -04:00
|
|
|
export HOST="nilmbuntu"
|
2013-08-17 22:28:49 -04:00
|
|
|
export BUILD_SYSTEM="Ubuntu"
|
2016-06-27 16:52:45 -04:00
|
|
|
export FLAVOUR="NILMbuntu"
|
2016-07-03 00:18:59 -04:00
|
|
|
|
|
|
|
# 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
|
2013-08-17 22:28:49 -04:00
|
|
|
EOF
|
|
|
|
|
2016-07-01 17:28:07 -04:00
|
|
|
# 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
|
2016-07-03 00:17:01 -04:00
|
|
|
# And copy it for now (although it will get overwritten at boot)
|
|
|
|
cat /etc/hosts.nilm >> /etc/hosts
|
2016-07-01 17:28:07 -04:00
|
|
|
|
2016-07-26 18:08:57 -04:00
|
|
|
# Upgrade packages
|
2016-07-03 00:17:01 -04:00
|
|
|
apt update
|
|
|
|
apt -y dist-upgrade
|
|
|
|
apt -y --purge autoremove
|
2016-07-26 18:08:57 -04:00
|
|
|
|
|
|
|
# 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
|
2013-08-17 22:28:49 -04:00
|
|
|
done
|
2016-07-26 18:08:57 -04:00
|
|
|
apt -y --reinstall install linux-{,signed-}image-${LATEST_KERNEL}
|
2013-08-17 22:28:49 -04:00
|
|
|
|
2013-08-18 12:42:11 -04:00
|
|
|
# Disable upgrade popups
|
2016-06-27 16:52:45 -04:00
|
|
|
sed -i -s -e 's/Prompt=.*/Prompt=never/g' \
|
2013-08-18 19:26:07 -04:00
|
|
|
/etc/update-manager/release-upgrades || true
|
2013-08-18 12:42:11 -04:00
|
|
|
|
2013-08-18 17:54:56 -04:00
|
|
|
# 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
|
2016-07-03 00:17:01 -04:00
|
|
|
apt -y install postfix
|
2013-08-18 17:54:56 -04:00
|
|
|
|
2016-06-27 16:52:45 -04:00
|
|
|
# Required packages
|
2016-07-03 00:17:01 -04:00
|
|
|
apt -y install \
|
2016-06-27 16:52:45 -04:00
|
|
|
python3 \
|
2013-08-17 22:28:49 -04:00
|
|
|
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
|
|
|
|
|
2016-07-03 00:17:01 -04:00
|
|
|
# Install other useful stuff
|
|
|
|
apt -y install \
|
|
|
|
adb \
|
|
|
|
avrdude \
|
|
|
|
chromium-browser \
|
2013-08-17 22:28:49 -04:00
|
|
|
curl \
|
2016-07-03 00:17:01 -04:00
|
|
|
debconf-utils \
|
2016-06-27 16:52:45 -04:00
|
|
|
devscripts \
|
2016-07-03 00:17:01 -04:00
|
|
|
dfu-programmer \
|
2016-06-27 16:52:45 -04:00
|
|
|
dlocate \
|
|
|
|
emacs \
|
|
|
|
emacs-goodies-el \
|
2016-07-03 00:17:01 -04:00
|
|
|
esptool \
|
|
|
|
flashrom \
|
2016-06-27 16:52:45 -04:00
|
|
|
gcc-arm-none-eabi \
|
2016-07-03 00:17:01 -04:00
|
|
|
gcc-avr \
|
2016-06-27 16:52:45 -04:00
|
|
|
gdb-arm-none-eabi \
|
2013-08-17 22:28:49 -04:00
|
|
|
gddrescue \
|
2016-06-27 16:52:45 -04:00
|
|
|
gnuplot \
|
2013-08-17 22:28:49 -04:00
|
|
|
help2man \
|
2016-06-27 16:52:45 -04:00
|
|
|
ipython \
|
|
|
|
libnewlib-arm-none-eabi \
|
2016-07-03 00:17:01 -04:00
|
|
|
libreoffice \
|
2016-06-27 16:52:45 -04:00
|
|
|
libstdc++-arm-none-eabi-newlib \
|
|
|
|
texlive \
|
|
|
|
mailutils \
|
2013-08-17 22:28:49 -04:00
|
|
|
moreutils \
|
2013-08-20 13:38:44 -04:00
|
|
|
mutt \
|
2013-08-28 10:28:54 -04:00
|
|
|
network-manager-openvpn-gnome \
|
2016-06-27 16:52:45 -04:00
|
|
|
octave \
|
|
|
|
octave-missing-functions \
|
|
|
|
octave-signal \
|
|
|
|
openocd \
|
2016-07-01 16:22:20 -04:00
|
|
|
openssh-server \
|
2014-02-18 14:56:22 -05:00
|
|
|
openssl \
|
2016-06-27 16:52:45 -04:00
|
|
|
openvpn \
|
|
|
|
python-matplotlib \
|
2014-02-18 14:56:22 -05:00
|
|
|
screen \
|
2016-07-03 00:17:01 -04:00
|
|
|
sigrok \
|
2016-06-27 16:52:45 -04:00
|
|
|
silversearcher-ag \
|
|
|
|
subversion \
|
|
|
|
tcpdump \
|
|
|
|
zip
|
2013-08-17 22:28:49 -04:00
|
|
|
|
2016-06-28 16:14:21 -04:00
|
|
|
# Install the packages required for en_US language support
|
|
|
|
# This avoids a prompt and package download at first install
|
2016-07-03 00:17:01 -04:00
|
|
|
apt -y install $(/usr/bin/check-language-support -l en_US)
|
2016-06-28 16:14:21 -04:00
|
|
|
|
2013-08-18 11:40:52 -04:00
|
|
|
# Set up timezone to America/New_York for the live CD
|
2016-06-27 16:52:45 -04:00
|
|
|
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
|
2013-08-18 11:40:52 -04:00
|
|
|
dpkg-reconfigure -f noninteractive tzdata
|
|
|
|
|
2016-06-28 13:18:31 -04:00
|
|
|
# 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)
|
2016-06-28 16:14:31 -04:00
|
|
|
XML=/etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
|
|
|
|
BG=/usr/share/xfce4/backdrops/nilmbuntu.png
|
2016-07-03 00:17:01 -04:00
|
|
|
apt -y install xmlstarlet
|
2016-06-28 16:14:31 -04:00
|
|
|
xmlstarlet ed -L -u "//property[@name='image-path']/@value" -v "$BG" $XML
|
|
|
|
xmlstarlet ed -L -u "//property[@name='image-style']/@value" -v "3" $XML
|
2016-06-28 13:18:31 -04:00
|
|
|
|
2016-07-03 00:20:39 -04:00
|
|
|
# Configure Firefox with our default homepage (now irrelevant since
|
|
|
|
# it won't be the default browser)
|
2016-06-28 13:18:31 -04:00
|
|
|
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
|
|
|
|
|
2016-07-03 00:20:39 -04:00
|
|
|
# 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
|
2016-06-27 16:52:45 -04:00
|
|
|
|
2016-07-03 00:20:39 -04:00
|
|
|
# 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
|
2016-06-27 16:52:45 -04:00
|
|
|
|
|
|
|
|
2016-07-03 00:18:59 -04:00
|
|
|
# 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
|
2016-07-03 02:05:12 -04:00
|
|
|
if ! getent passwd nilm ; then
|
|
|
|
adduser --gecos "NILM User" --disabled-password nilm
|
|
|
|
fi
|
2016-06-27 16:52:45 -04:00
|
|
|
|
2016-07-03 00:20:49 -04:00
|
|
|
# Make sure locate databases are up-to-date
|
|
|
|
/etc/cron.daily/mlocate
|
|
|
|
/etc/cron.daily/dlocate
|
2016-06-27 16:52:45 -04:00
|
|
|
|
2016-07-03 00:18:59 -04:00
|
|
|
# Make sure initramfs was regenerated with casper changes
|
2016-07-03 00:42:54 -04:00
|
|
|
update-initramfs -u
|