From d35fae6d1df6ec9daad8c3fd11cbaa1729edf788 Mon Sep 17 00:00:00 2001 From: Jim Paris Date: Sun, 18 Aug 2013 12:27:28 -0400 Subject: [PATCH] setup crontab, database; regen ssh keys and setup grub --- TODO | 2 -- customize-inner.sh | 34 +++++++++++++++++++++++++++++++++- customize.sh | 21 ++++++++++++++------- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index cb4bb9b..f72380b 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,7 @@ -- nilmdb crontab - terminal, browser on desktop - theme: style "Clearlooks", icons "elementary Xfce" - nilmdb wallpaper, was "xubuntu-quantal.png" - preseed username, password, login automatically? - disable 13.04 upgrade notification? - precreate database and streams -- maybe get rid of splash+quiet in installed image? - try xubuntu 13.04 diff --git a/customize-inner.sh b/customize-inner.sh index ca7ad6d..ae16170 100644 --- a/customize-inner.sh +++ b/customize-inner.sh @@ -73,7 +73,8 @@ apt-get -y install \ subversion \ dlocate \ ack-grep \ - mutt + mutt \ + openssh-server # Set up timezone to America/New_York for the live CD echo America/New_York > /etc/timezone @@ -164,6 +165,22 @@ 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 @@ -188,3 +205,18 @@ 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 & +SERVER=$! +sleep 1 +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 $! +sleep 1 +kill -9 $! || true diff --git a/customize.sh b/customize.sh index 72fbf33..3a717e6 100755 --- a/customize.sh +++ b/customize.sh @@ -5,7 +5,7 @@ set -e set -x # Customize the outer ISO image -perl -p -i -e \ +sed -i -e \ "s/DISKNAME.*/DISKNAME NilmDBuntu $VERSION by Jim Paris/" \ ${ISO}/README.diskdefines @@ -13,16 +13,23 @@ perl -p -i -e \ # out the distro name in dialogs, and I think casper might use it too echo "NilmDBuntu $VERSION by Jim Paris" > ${ISO}/.disk/info -# Include openssh server at install time. Can't include it in the -# image, because then we'd share keys on all machines, I think. +# Set up preseed file cp ${ISO}/preseed/xubuntu.seed ${ISO}/preseed/nilmdbuntu.seed -cat >> ${ISO}/preseed/nilmdbuntu.seed <> ${ISO}/preseed/nilmdbuntu.seed <<"EOF" +# Late commands: +# - Regenerate SSH host keys +# - Remove "quiet splash" from grub command line +d-i preseed/late_command string \ + in-target rm /etc/ssh/ssh_host_*; \ + in-target dpkg-reconfigure openssh-server; \ + in-target sed -i 's/quiet splash//g' /etc/default/grub; \ + in-target update-grub; \ + echo "done" EOF # Rename Xubuntu to NilmDBuntu in boot scripts; also changes # preseed file to the custom one -perl -p -i \ +sed -i \ -e "s/Xubuntu/NilmDBuntu/g;" \ -e "s/Kubuntu/NilmDBuntu/g;" \ -e "s/Ubuntu/NilmDBuntu/g;" \ @@ -33,7 +40,7 @@ perl -p -i \ # Remove quiet and splash from boot command lines. Easier than a # custom plymouth theme and it's helpful. -perl -p -i -e "s/ quiet splash//g;" \ +sed -i -e "s/ quiet splash//g;" \ ${ISO}/isolinux/txt.cfg ${ISO}/boot/grub/{grub,loopback}.cfg # Run the customize-inner.sh script inside the chroot