You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

213 lines
6.0 KiB

  1. #!/bin/bash
  2. if [ "$IN_CHROOT" != "1" ] ; then
  3. echo This is supposed to run inside the chroot, oops
  4. exit 1
  5. fi
  6. set -e
  7. set -x
  8. # Set up live username and hostname
  9. cat >/etc/casper.conf <<"EOF"
  10. export USERNAME="nilm"
  11. export USERFULLNAME="NILM User"
  12. export HOST="nilmbuntu"
  13. export BUILD_SYSTEM="Ubuntu"
  14. export FLAVOUR="NILMbuntu"
  15. # Do the inital user setup even though UID 1000 already exists.
  16. # This also needs to be set in /etc/environment, for ubiquity,
  17. # but we do that in preseed/early_command so that it only shows
  18. # up in the LiveCD image.
  19. export OVERRIDE_SYSTEM_USER=true
  20. EOF
  21. # Set up NILM-specific stuff to get added to /etc/hosts after installation
  22. cat >/etc/hosts.nilm <<"EOF"
  23. 127.0.2.1 nilm.primary
  24. 127.0.2.2 nilm.secondary
  25. EOF
  26. # And copy it for now (although it will get overwritten at boot)
  27. cat /etc/hosts.nilm >> /etc/hosts
  28. # Upgrade packages and remove old kernels
  29. apt update
  30. apt -y dist-upgrade
  31. apt -y --purge autoremove
  32. for VER in $(ls --sort=version /lib/modules/ | head -n -1) ; do
  33. apt -y --purge remove "linux-.*$VER"
  34. done
  35. # Disable upgrade popups
  36. sed -i -s -e 's/Prompt=.*/Prompt=never/g' \
  37. /etc/update-manager/release-upgrades || true
  38. # Set up & install postfix for local mail delivery
  39. debconf-set-selections <<"EOF"
  40. postfix postfix/mailname string localdomain
  41. postfix postfix/main_mailer_type select Local only
  42. EOF
  43. apt -y install postfix
  44. # Required packages
  45. apt -y install \
  46. python3 \
  47. python2.7 \
  48. python2.7-dev \
  49. python-setuptools \
  50. python-pip \
  51. cython \
  52. git \
  53. build-essential \
  54. python-cherrypy3 \
  55. python-decorator \
  56. python-simplejson \
  57. python-requests \
  58. python-dateutil \
  59. python-tz \
  60. python-progressbar \
  61. python-psutil \
  62. python-numpy \
  63. python-nose \
  64. python-coverage \
  65. apache2 \
  66. libapache2-mod-wsgi \
  67. python-scipy \
  68. python-daemon
  69. # Install other useful stuff
  70. apt -y install \
  71. adb \
  72. avrdude \
  73. chromium-browser \
  74. curl \
  75. debconf-utils \
  76. devscripts \
  77. dfu-programmer \
  78. dlocate \
  79. emacs \
  80. emacs-goodies-el \
  81. esptool \
  82. flashrom \
  83. gcc-arm-none-eabi \
  84. gcc-avr \
  85. gdb-arm-none-eabi \
  86. gddrescue \
  87. gnuplot \
  88. help2man \
  89. ipython \
  90. libnewlib-arm-none-eabi \
  91. libreoffice \
  92. libstdc++-arm-none-eabi-newlib \
  93. texlive \
  94. mailutils \
  95. moreutils \
  96. mutt \
  97. network-manager-openvpn-gnome \
  98. octave \
  99. octave-missing-functions \
  100. octave-signal \
  101. openocd \
  102. openssh-server \
  103. openssl \
  104. openvpn \
  105. python-matplotlib \
  106. screen \
  107. sigrok \
  108. silversearcher-ag \
  109. subversion \
  110. tcpdump \
  111. zip
  112. # Install the packages required for en_US language support
  113. # This avoids a prompt and package download at first install
  114. apt -y install $(/usr/bin/check-language-support -l en_US)
  115. # Set up timezone to America/New_York for the live CD
  116. ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
  117. dpkg-reconfigure -f noninteractive tzdata
  118. # Put some default desktop shortcuts in place
  119. DESKTOP=/etc/skel/Desktop
  120. mkdir -p $DESKTOP
  121. cp /usr/share/applications/exo-terminal-emulator.desktop $DESKTOP || true
  122. cp /usr/share/applications/exo-web-browser.desktop $DESKTOP || true
  123. chmod +x $DESKTOP/*
  124. # Custom background image (which was already copied in by customize.sh)
  125. XML=/etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
  126. BG=/usr/share/xfce4/backdrops/nilmbuntu.png
  127. apt -y install xmlstarlet
  128. xmlstarlet ed -L -u "//property[@name='image-path']/@value" -v "$BG" $XML
  129. xmlstarlet ed -L -u "//property[@name='image-style']/@value" -v "3" $XML
  130. # Configure Firefox with our default homepage (now irrelevant since
  131. # it won't be the default browser)
  132. HOMEPAGE="http://www.wattsworth.net/"
  133. cat >/etc/firefox/syspref.js <<EOF
  134. pref("browser.startup.homepage", "${HOMEPAGE}");
  135. pref("extensions.ubufox@ubuntu.com.custom_homepage", "${HOMEPAGE}");
  136. pref("browser.startup.homepage_override.mstone", "ignore");
  137. EOF
  138. # Set up Chromium as default browser
  139. update-alternatives --set x-www-browser /usr/bin/chromium-browser
  140. update-alternatives --set gnome-www-browser /usr/bin/chromium-browser
  141. mkdir -p /etc/skel/.config/xfce4
  142. cat >/etc/skel/.config/xfce4/helpers.rc <<"EOF"
  143. WebBrowser=chromium-browser
  144. EOF
  145. mkdir -p /etc/skel/.local/share/xfce4/helpers
  146. cat >/etc/skel/.local/share/xfce4/helpers/chromium-browser.desktop <<"EOF"
  147. [Desktop Entry]
  148. Version=1.0
  149. Name=Chromium Web Browser
  150. X-XFCE-Category=WebBrowser
  151. X-XFCE-Commands=chromium-browser
  152. X-XFCE-CommandsWithParameter=chromium-browser "%s"
  153. Exec=chromium-browser %U
  154. Type=X-XFCE-Helper
  155. Icon=chromium-browser
  156. MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;
  157. StartupNotify=true
  158. EOF
  159. # Make Chromium a little nicer:
  160. # - No first run
  161. mkdir -p /etc/skel/.config/chromium/Default
  162. touch '/etc/skel/.config/chromium/First Run'
  163. # - Set up some default bookmarks on the bookmark bar
  164. cat >/etc/skel/.config/chromium/Default/Bookmarks <<"EOF"
  165. { "version": 1, "roots": {
  166. "other": { "id": "2", "name": "Other bookmarks", "type": "folder",
  167. "children": [ ] },
  168. "synced": { "id": "3", "name": "Mobile bookmarks", "type": "folder",
  169. "children": [ ] },
  170. "bookmark_bar": { "id": "1", "name": "Bookmarks bar", "type": "folder",
  171. "children": [ {
  172. "id": "6", "type": "url",
  173. "name": "Wattsworth",
  174. "url": "http://www.wattsworth.net/"
  175. }, {
  176. "id": "7", "type": "url",
  177. "name": "Standalone NILM",
  178. "type": "url",
  179. "url": "http://nilm.primary/"
  180. } ] }
  181. } }
  182. EOF
  183. # Create NILM user. This should happen after anything that we put in
  184. # /etc/skel, since files get copied from there. Note that this user
  185. # is the same as what we have in the preseed file and casper.conf
  186. adduser --gecos "NILM User" --disabled-password nilm
  187. # Make sure locate databases are up-to-date
  188. /etc/cron.daily/mlocate
  189. /etc/cron.daily/dlocate
  190. # Make sure initramfs was regenerated with casper changes
  191. update-initramfs -u