Browse Source

Set up Chromium

tags/nilmbuntu-5
Jim Paris 4 years ago
parent
commit
5626b1723a
1 changed files with 47 additions and 147 deletions
  1. +47
    -147
      customize-inner.sh

+ 47
- 147
customize-inner.sh View File

@@ -142,7 +142,8 @@ 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}");
@@ -150,154 +151,53 @@ pref("extensions.ubufox@ubuntu.com.custom_homepage", "${HOMEPAGE}");
pref("browser.startup.homepage_override.mstone", "ignore");
EOF

# NilmDB setup below...

# # 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

# # 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 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...

# 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
# 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

# # 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"
# 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

# # 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

# Create NILM user. This should happen after anything that we put in
# /etc/skel, since files get copied from there. Note that this user


Loading…
Cancel
Save