Compare commits
20 Commits
wattsworth
...
nilmbuntu-
Author | SHA1 | Date | |
---|---|---|---|
5b2ac4ba8b | |||
3a0b0e8114 | |||
b3bcec51f8 | |||
6d16d6dc0e | |||
0c439a1643 | |||
00ef92be05 | |||
1f5afcc566 | |||
f4f36e3c16 | |||
5626b1723a | |||
06169b9894 | |||
4845ce82bf | |||
7d88ead0c5 | |||
8b4fe416fe | |||
eaa16f87b1 | |||
5988e64b8e | |||
26215d6ac8 | |||
7402ca0073 | |||
f8c1018925 | |||
2fd0460dc1 | |||
b693071019 |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,9 +1,2 @@
|
||||
fs
|
||||
fs-*
|
||||
iso
|
||||
iso-*
|
||||
mnt
|
||||
mnt-*
|
||||
tmp-*
|
||||
*.iso
|
||||
disk.img
|
||||
disk.img-*
|
||||
|
10
README
10
README
@@ -4,7 +4,7 @@ since the image is executed inside a systemd-nspawn container.
|
||||
|
||||
Set up host machine, which must be running a recent systemd:
|
||||
|
||||
sudo apt-get install squashfs-tools xorriso isolinux systemd-container iptables
|
||||
sudo apt install squashfs-tools xorriso isolinux systemd-container iptables
|
||||
sudo systemctl start systemd-networkd
|
||||
|
||||
Choose a config:
|
||||
@@ -39,3 +39,11 @@ Boot QEMU with the same HDD image as above, to test an "installed" system:
|
||||
Remove everything but the ISOs:
|
||||
|
||||
./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)
|
||||
|
7
backup.sh
Executable file
7
backup.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
. config || exit 0
|
||||
set -e
|
||||
|
||||
echo Backing up filesystem...
|
||||
sudo rsync -a --delete ${FS} ${FS}.backup
|
2
config
2
config
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$BUILD_CONFIG" ] ; then
|
||||
export BUILD_CONFIG=16.04
|
||||
export BUILD_CONFIG=16.04.1
|
||||
echo "No BUILD_CONFIG set -- assuming $BUILD_CONFIG"
|
||||
fi
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# -*- sh -*-
|
||||
|
||||
# output image
|
||||
VERSION="16.04"
|
||||
VERSION="16.04.1"
|
||||
OUTPUT="nilmbuntu-${VERSION}.iso"
|
||||
|
||||
# original ISO
|
@@ -8,31 +8,43 @@ fi
|
||||
set -e
|
||||
set -x
|
||||
|
||||
try_install() {
|
||||
# try to install packages, but ignore failure
|
||||
for pkg in "$@"; do
|
||||
if ! apt-get -y install "$pkg" ; then
|
||||
echo ---- WARNING: Failed to install package: $pkg
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Set up live username and hostname
|
||||
cat >/etc/casper.conf <<"EOF"
|
||||
export USERNAME="ubuntu"
|
||||
export USERFULLNAME="Live session user"
|
||||
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
|
||||
|
||||
# Upgrade packages and remove old kernels
|
||||
apt-get update
|
||||
apt-get -y dist-upgrade
|
||||
apt-get -y --purge autoremove
|
||||
for VER in $(ls --sort=version /lib/modules/ | head -n -1) ; do
|
||||
apt-get -y --purge remove "linux-.*$VER"
|
||||
# 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' \
|
||||
@@ -43,10 +55,10 @@ debconf-set-selections <<"EOF"
|
||||
postfix postfix/mailname string localdomain
|
||||
postfix postfix/main_mailer_type select Local only
|
||||
EOF
|
||||
apt-get -y install postfix
|
||||
apt -y install postfix
|
||||
|
||||
# Required packages
|
||||
apt-get -y install \
|
||||
apt -y install \
|
||||
python3 \
|
||||
python2.7 \
|
||||
python2.7-dev \
|
||||
@@ -71,20 +83,29 @@ apt-get -y install \
|
||||
python-scipy \
|
||||
python-daemon
|
||||
|
||||
# Install other useful but optional stuff
|
||||
try_install \
|
||||
# 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 \
|
||||
@@ -95,15 +116,21 @@ try_install \
|
||||
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
|
||||
@@ -116,10 +143,14 @@ 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
|
||||
sed -i -s -e 's/xubuntu-wallpaper.png/nilmbuntu.png/g' $XML/xfce4-desktop.xml
|
||||
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
|
||||
# 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}");
|
||||
@@ -127,181 +158,64 @@ pref("extensions.ubufox@ubuntu.com.custom_homepage", "${HOMEPAGE}");
|
||||
pref("browser.startup.homepage_override.mstone", "ignore");
|
||||
EOF
|
||||
|
||||
# NilmDB setup below...
|
||||
# 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
|
||||
|
||||
# # Create nilmdb user to run the database
|
||||
# adduser --system --group --shell /bin/bash --disabled-password nilmdb
|
||||
# cp -rv /etc/skel/.??* /home/nilmdb
|
||||
# chown -R nilmdb:nilmdb /home/nilmdb
|
||||
# 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 WSGI scripts
|
||||
# cat > /home/nilmdb/nilmdb.wsgi <<"EOF"
|
||||
# import nilmdb.server
|
||||
# application = nilmdb.server.wsgi_application("/home/nilmdb/db","/nilmdb")
|
||||
# EOF
|
||||
# cat > /home/nilmdb/nilmrun.wsgi <<"EOF"
|
||||
# import nilmrun.server
|
||||
# application = nilmrun.server.wsgi_application("/nilmrun")
|
||||
# EOF
|
||||
|
||||
# #### Edit apache config
|
||||
# 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
|
||||
|
||||
# # Create apache config by hacking up the default one. Might be a better way
|
||||
# # to do this, and it'll probably break on new versions, but...
|
||||
# Make sure locate databases are up-to-date
|
||||
/etc/cron.daily/mlocate
|
||||
/etc/cron.daily/dlocate
|
||||
|
||||
# APACHE_VER=$(dpkg -s apache2 | grep ^Version | cut -d ' ' -f 2)
|
||||
# if dpkg --compare-versions $APACHE_VER ge 2.4 ; then
|
||||
# DEF=/etc/apache2/sites-available/000-default.conf
|
||||
# NEED_PERMISSIONS=1
|
||||
# else
|
||||
# DEF=/etc/apache2/sites-available/default
|
||||
# NEED_PERMISSIONS=0
|
||||
# fi
|
||||
|
||||
# # Cut out any existing NilmDB stuff
|
||||
# perl -ne 'print unless /## NilmDB start/../## NilmDB end/' $DEF > $DEF.orig
|
||||
|
||||
# # Copy everything up to the first </VirtualHost> line
|
||||
# perl -ne 'print unless m-^[^#]*</VirtualHost>-..1' $DEF.orig > $DEF
|
||||
|
||||
# # Add the NilmDB config
|
||||
# cat >>$DEF <<"EOF"
|
||||
# ## NilmDB start
|
||||
# WSGIScriptAlias /nilmdb /home/nilmdb/nilmdb.wsgi
|
||||
# WSGIDaemonProcess nilmdb-procgroup threads=32 user=nilmdb group=nilmdb
|
||||
# <Location /nilmdb>
|
||||
# WSGIProcessGroup nilmdb-procgroup
|
||||
# WSGIApplicationGroup nilmdb-appgroup
|
||||
# </Location>
|
||||
|
||||
# WSGIScriptAlias /nilmrun /home/nilmdb/nilmrun.wsgi
|
||||
# WSGIDaemonProcess nilmrun-procgroup threads=32 user=nilmdb group=nilmdb
|
||||
# <Location /nilmrun>
|
||||
# WSGIProcessGroup nilmrun-procgroup
|
||||
# WSGIApplicationGroup nilmrun-appgroup
|
||||
# </Location>
|
||||
# EOF
|
||||
# if [ $NEED_PERMISSIONS == 1 ] ; then
|
||||
# cat >>$DEF <<"EOF"
|
||||
|
||||
# <Directory /home/nilmdb>
|
||||
# Options All
|
||||
# AllowOverride All
|
||||
# Require all granted
|
||||
# </Directory>
|
||||
# EOF
|
||||
# fi
|
||||
# cat >>$DEF <<"EOF"
|
||||
# ## NilmDB end
|
||||
# EOF
|
||||
|
||||
# # Copy everything including and after the first </VirtualHost> line
|
||||
# perl -ne 'print if m-^[^#]*</VirtualHost>-..1' $DEF.orig >> $DEF
|
||||
|
||||
# #### Done editing apache config
|
||||
|
||||
# # Create nilmdb capture, processing, and cleanup files
|
||||
# cat > /home/nilmdb/capture.sh <<"EOF"
|
||||
# #!/bin/bash -e
|
||||
|
||||
# # Don't run capture if we're running off a live CD
|
||||
# if grep -q boot=casper /proc/cmdline ; then
|
||||
# echo "Skipping capture, because this is a live CD."
|
||||
# exit 0
|
||||
# fi
|
||||
|
||||
# echo "Starting capture in background..."
|
||||
# nilm-pipewatch --daemon --lock "/tmp/nilmdb-capture.lock" --timeout 30 \
|
||||
# "ethstream -a 192.168.1.209 -n 6 -r 8000" \
|
||||
# "nilm-insert -m 10 -r 8000 --live /data/raw"
|
||||
# EOF
|
||||
# cat > /home/nilmdb/process.sh <<"EOF"
|
||||
# #!/bin/bash -e
|
||||
|
||||
# # Ensure only one copy of this code runs at a time:
|
||||
# LOCKFILE="/tmp/nilmdb-process.lock"
|
||||
# exec 99>"$LOCKFILE"
|
||||
# flock -n -x 99 || exit 0
|
||||
# trap 'rm -f "$LOCKFILE"' 0
|
||||
|
||||
# nilm-sinefit -c 4 /data/raw /data/sinefit
|
||||
# nilm-prep -c 1 -r 0 /data/raw /data/sinefit /data/prep-a
|
||||
# nilm-prep -c 2 -r 120 /data/raw /data/sinefit /data/prep-b
|
||||
# nilm-prep -c 3 -r 240 /data/raw /data/sinefit /data/prep-c
|
||||
# nilm-decimate-auto /data/raw "/data/prep*"
|
||||
# nilm-cleanup --yes /home/nilmdb/cleanup.cfg
|
||||
# EOF
|
||||
# cat > /home/nilmdb/cleanup.cfg <<"EOF"
|
||||
# [/data/prep-*]
|
||||
# keep = 1y
|
||||
|
||||
# [/data/raw]
|
||||
# keep = 2w
|
||||
|
||||
# [/data/sinefit]
|
||||
# keep = 1y
|
||||
# decimated = false
|
||||
# EOF
|
||||
|
||||
# # Set up crontab
|
||||
# cat > /home/nilmdb/crontab <<"EOF"
|
||||
# SHELL=/bin/bash
|
||||
# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# # Run capture and processing scripts every 5 minutes
|
||||
# */5 * * * * chronic /home/nilmdb/capture.sh
|
||||
# */5 * * * * chronic /home/nilmdb/process.sh
|
||||
|
||||
# # Try to run nilmdb-fsck on boot. It should hopefully run before
|
||||
# # apache opens the database, and apache will return errors to clients
|
||||
# # until nilmdb-fsck is done.
|
||||
# @reboot chronic nilmdb-fsck --fix --no-data /home/nilmdb/db
|
||||
# EOF
|
||||
# crontab -u nilmdb /home/nilmdb/crontab
|
||||
|
||||
# # Fix permissions
|
||||
# chown -R nilmdb:nilmdb /home/nilmdb
|
||||
# chmod +x /home/nilmdb/{capture,process}.sh
|
||||
|
||||
# # Fetch and build everything. Put it in the nilmdb dir
|
||||
# echo "machine git.jim.sh login nilm password nilm" > /home/nilmdb/.netrc
|
||||
# GIT=https://git.jim.sh/jim/lees
|
||||
# rm -rf /home/nilmdb/git
|
||||
# mkdir /home/nilmdb/git
|
||||
# chown nilmdb:nilmdb /home/nilmdb/.netrc /home/nilmdb/git
|
||||
# REPOS="nilmdb nilmtools nilmrun ethstream"
|
||||
|
||||
# # check it out as nilmdb, so the .netrc gets used
|
||||
# for repo in $REPOS; do
|
||||
# sudo -i -u nilmdb git clone $GIT/$repo.git git/$repo
|
||||
# done
|
||||
|
||||
# # build as root, because we need to do that for the install
|
||||
# for repo in $REPOS; do
|
||||
# make -C /home/nilmdb/git/$repo install
|
||||
# done
|
||||
|
||||
# # fix up all permissions in git dir, so nilmdb user can play with it later
|
||||
# chown -R nilmdb:nilmdb /home/nilmdb/git
|
||||
|
||||
# # Create the initial database and streams by running the standalone
|
||||
# # server as nilmdb, making the right nilmtool calls, and killing it.
|
||||
# sudo -i -u nilmdb nilmdb-server -a 127.0.0.1 -p 18646 -d /home/nilmdb/db &
|
||||
# SERVERPID=$!
|
||||
# trap "kill -9 $SERVERPID" 0
|
||||
# for i in $(seq 1 120) ; do
|
||||
# sleep 1
|
||||
# echo waiting for nilmdb to start $i
|
||||
# if nilmtool -u http://127.0.0.1:18646/ info ; then
|
||||
# break
|
||||
# fi
|
||||
# done
|
||||
# nilmtool -u http://127.0.0.1:18646/ destroy -R "/data/*" || true
|
||||
# nilmtool -u http://127.0.0.1:18646/ create /data/raw uint16_6
|
||||
# nilmtool -u http://127.0.0.1:18646/ create /data/sinefit float32_3
|
||||
# nilmtool -u http://127.0.0.1:18646/ create /data/prep-a float32_8
|
||||
# nilmtool -u http://127.0.0.1:18646/ create /data/prep-b float32_8
|
||||
# nilmtool -u http://127.0.0.1:18646/ create /data/prep-c float32_8
|
||||
# kill $SERVERPID
|
||||
# wait
|
||||
# trap "" 0
|
||||
# Make sure initramfs was regenerated with casper changes
|
||||
update-initramfs -u
|
||||
|
34
customize.sh
34
customize.sh
@@ -13,37 +13,9 @@ sed -i -s -e \
|
||||
# out the distro name in dialogs, and I think casper might use it too
|
||||
echo "NILMbuntu $VERSION" > ${ISO}/.disk/info
|
||||
|
||||
# Set up preseed file
|
||||
cp ${ISO}/preseed/xubuntu.seed ${ISO}/preseed/nilmbuntu.seed
|
||||
cat >> ${ISO}/preseed/nilmbuntu.seed <<"EOF"
|
||||
# Commands to run on successful install:
|
||||
# - Regenerate SSH host keys
|
||||
# - Remove "quiet splash" from grub command line
|
||||
# Ubiquity doesn't actually use preseed/late_command, so we do it
|
||||
# in ubiquity/success_command (which needs things mounted)
|
||||
ubiquity ubiquity/success_command string \
|
||||
echo "success_command running" >/target/var/log/installer/postinst.log; \
|
||||
for i in /dev /dev/pts /dev/shm /sys /sys/kernel/security /proc /cdrom; do \
|
||||
mount --bind $i /target/$i; done; \
|
||||
sed -i -e 's/quiet splash//g' /target/etc/default/grub; \
|
||||
chroot /target update-grub \
|
||||
>>/target/var/log/installer/postinst.log 2>&1; \
|
||||
rm -f /target/etc/ssh/ssh_host_*; \
|
||||
chroot /target dpkg-reconfigure openssh-server \
|
||||
>>/target/var/log/installer/postinst.log 2>&1; \
|
||||
for i in /dev/pts /dev/shm /dev /sys/kernel/security /sys /proc /cdrom; do \
|
||||
umount /target/$i; done; \
|
||||
echo "success_command done" >>/target/var/log/installer/postinst.log
|
||||
|
||||
# Default user. Ubiquity should let them change this.
|
||||
# (To skip the dialog completely, maybe set a password?)
|
||||
d-i passwd/user-fullname string NILM User
|
||||
d-i passwd/username string nilm
|
||||
#d-i passwd/user-password password nilm
|
||||
#d-i passwd/user-password-again password nilm
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i passwd/auto-login boolean true
|
||||
EOF
|
||||
# Set up preseed file by appending preseed.cfg to the Xubuntu
|
||||
# default one
|
||||
cat ${ISO}/preseed/xubuntu.seed preseed.cfg > ${ISO}/preseed/nilmbuntu.seed
|
||||
|
||||
# Set up isolinux how we want by editing its config
|
||||
TRY="Boot ^NILMbuntu ${VERSION}"
|
||||
|
2
enter.sh
2
enter.sh
@@ -104,6 +104,8 @@ 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 "hostnamectl --transient set-hostname nilmbuntu"
|
||||
|
||||
#run "dbus-uuidgen > /var/lib/dbus/machine-id"
|
||||
|
@@ -17,7 +17,13 @@ set -e
|
||||
# download it if it doesn't exist
|
||||
if ! [ -e ${ORIG} ] ; then
|
||||
mkdir -p $(dirname ${ORIG})
|
||||
wget -O "${ORIG}" "${ORIGURL}"
|
||||
if [ -e $(dirname ${ORIG})/../$(basename ${ORIG}) ] ; then
|
||||
# grab from parent directory
|
||||
cp $(dirname ${ORIG})/../$(basename ${ORIG}) ${ORIG}
|
||||
else
|
||||
# grab from web
|
||||
wget -O "${ORIG}" "${ORIGURL}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# mount it
|
||||
|
55
preseed.cfg
Normal file
55
preseed.cfg
Normal file
@@ -0,0 +1,55 @@
|
||||
# Commands to run at casper boot:
|
||||
# - Regenerate SSH keys
|
||||
# - Append /etc/hosts.nilm to /etc/hosts
|
||||
#
|
||||
# And the following hacks, which could also run in customize-inner.sh,
|
||||
# but doing them here ensures that they'll only be present during the
|
||||
# LiveCD session
|
||||
# - Append some stuff to /etc/enviroment that's needed for Ubiquity to
|
||||
# create the initial user properly, when we've already created it.
|
||||
# - Hack Ubiquity to prevent changing the username, and to set
|
||||
# a default password
|
||||
d-i preseed/early_command string \
|
||||
echo "early_command running" ; \
|
||||
chroot /root sh -c "rm -f /etc/ssh/ssh_host_*" ; \
|
||||
chroot /root sh -c "dpkg-reconfigure openssh-server" ; \
|
||||
cat /root/etc/hosts.nilm >> /root/etc/hosts ; \
|
||||
echo OVERRIDE_SYSTEM_USER=1 >> /root/etc/environment ; \
|
||||
sed -i \
|
||||
-e 's@id="login_encrypt">@id="login_encrypt"><property name="sensitive">False</property>@g' \
|
||||
-e 's@id="fullname">@id="fullname"><property name="sensitive">False</property>@g' \
|
||||
-e 's@id="username">@id="username"><property name="sensitive">False</property>@g' \
|
||||
-e 's@"visibility">False@"visibility">True@g' \
|
||||
-e 's@id="password">@id="password"><property name="text">nilm</property>@g' \
|
||||
-e 's@id="verified_password">@id="verified_password"><property name="text">nilm</property>@g' \
|
||||
/root/usr/share/ubiquity/gtk/stepUserInfo.ui ; \
|
||||
echo "early_command done"
|
||||
# chroot /root sh -c "echo UBIQUITY_AUTOMATIC=1 >> /etc/environment"
|
||||
|
||||
# Commands to run on successful install:
|
||||
# (Ubiquity doesn't actually use preseed/late_command, so we do it
|
||||
# in ubiquity/success_command (which needs things mounted))
|
||||
# - Remove "quiet splash" from grub command line
|
||||
# - Append /etc/hosts.nilm to /etc/hosts
|
||||
ubiquity ubiquity/success_command string \
|
||||
echo "success_command running" >/target/var/log/installer/postinst.log; \
|
||||
mount --bind /dev /target/dev ; \
|
||||
in-target sh -c "sed -i -e 's/quiet splash//g' /etc/default/grub" ; \
|
||||
in-target sh -c "update-grub >>/var/log/installer/postinst.log 2>&1" ; \
|
||||
in-target sh -c "cat /etc/hosts.nilm >> /etc/hosts " ; \
|
||||
umount /target/dev ; \
|
||||
echo "success_command done" >>/target/var/log/installer/postinst.log
|
||||
|
||||
ubiquity ubiquity/use_nonfree boolean true
|
||||
|
||||
# Default user. Ubiquity should let them change this.
|
||||
# (To skip the dialog completely, set the first 4, and put
|
||||
# UBIQUITY_AUTOMATIC in /etc/environment in early_command above)
|
||||
d-i passwd/user-fullname string NILM User
|
||||
d-i passwd/username string nilm
|
||||
#d-i passwd/user-password password nilm
|
||||
#d-i passwd/user-password-again password nilm
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i user-setup/force-encrypt-home boolean false
|
||||
d-i user-setup/encrypt-home boolean false
|
||||
d-i passwd/auto-login boolean true
|
7
restore.sh
Executable file
7
restore.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
. config || exit 0
|
||||
set -e
|
||||
|
||||
echo Restoring filesystem...
|
||||
sudo rsync -a --delete ${FS}.backup ${FS}
|
18
run.sh
18
run.sh
@@ -46,20 +46,28 @@ set -e
|
||||
set -x
|
||||
|
||||
cfg=""
|
||||
|
||||
cfg+=" -drive file=${DISK},media=disk,format=raw,if=virtio"
|
||||
cfg+=" -enable-kvm"
|
||||
cfg+=" -m 2048"
|
||||
cfg+=" -usbdevice tablet"
|
||||
|
||||
cfg+=" -vga vmware"
|
||||
#cfg+=" -vnc :0"
|
||||
|
||||
case $boot in
|
||||
c)
|
||||
echo "booting CD with empty disk"
|
||||
rm -f ${DISK}
|
||||
dd if=/dev/zero "of=${DISK}" bs=1M count=0 seek=10240
|
||||
cfg+=" -drive file=${iso},index=1,media=cdrom"
|
||||
cfg+=" -drive file=${DISK},index=0,media=disk,format=raw"
|
||||
dd if=/dev/zero "of=${DISK}" bs=1M count=0 seek=30720
|
||||
cfg+=" -drive file=${iso},media=cdrom,if=none,id=cd"
|
||||
cfg+=" -device virtio-scsi-pci -device scsi-cd,drive=cd"
|
||||
cfg+=" -boot d"
|
||||
;;
|
||||
d)
|
||||
echo "booting disk with no CD"
|
||||
cfg+=" -drive file=${DISK},index=0,media=disk,format=raw"
|
||||
cfg+=" -boot c"
|
||||
;;
|
||||
esac
|
||||
|
||||
qemu-system-x86_64 -enable-kvm -m 2048 -vga vmware $cfg
|
||||
qemu-system-x86_64 $cfg
|
||||
|
Reference in New Issue
Block a user