Skip to content

Instantly share code, notes, and snippets.

@red-stripe
Last active November 16, 2017 03:23
Show Gist options
  • Save red-stripe/9818acb58ee94a32a83bd82b777db3f7 to your computer and use it in GitHub Desktop.
Save red-stripe/9818acb58ee94a32a83bd82b777db3f7 to your computer and use it in GitHub Desktop.
Fab Lab Wgtn Ubuntu 16.04 install script V0.01
#!/bin/bash
## Fab Lab Wgtn Ubuntu 16.04 install script - Hacked togeather by Craig Hobern
#Baised on the hard work of these great people:
#Francisco Sanchez - https://gist.github.com/TheBeachLab/e87feda460f1b5f64145
#Nadya Peek - https://gist.github.com/pral2a/7804545fc55b14ad0bef
# Do you want to install fab modules?
fabmodules=true
### ToDo
# Error checking, catch missnamed interfaces or lack of internet connection
# Breakout hardcoded devices or mountpoints to variables
# Work out a nice way to setup rvm for guest accounts
# Add Logging
#
###
#Manually add a new user
# sudo adduser fab-admin
# sudo usermod -aG sudo fab-admin
#Remove temp admin account
# sudo deluser --remove-home olduser
#Perpare to fight proxys!
# /etc/environment
# http_proxy="http://user:password@myproxy.server.com:8080/"
# https_proxy="https://user:password@myproxy.server.com:8080/"
# ftp_proxy="http://user:password@myproxy.server.com:8080/"
# /etc/apt/apt.conf.d/95proxies
# Acquire::http::proxy "http://user:password@myproxy.server.com:8080/";
# Acquire::ftp::proxy "ftp://user:password@myproxy.server.com:8080/";
# Acquire::https::proxy "https://user:password@myproxy.server.com:8080/";
# /home/$USER/.npmrc
# "http://domain\username:password@servername:port/" npm
#Dont use nz ubuntu ppa mirrors, they go down.... all the time.
sudo apt-get update
#add sweet error catch here
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
#manually setup burg, if you're into that sort of thing
#sudo cp /boot/grub/locale /boot/burg/locale
#sudo add-apt-repository ppa:n-muench/burg -y && sudo add-apt-repository ppa:danielrichter2007/grub-customizer -y && sudo apt-get update && sudo apt-get install burg burg-themes grub-customizer
#sudo burg-emu
#http://howtoubuntu.org/how-to-make-your-dual-boot-better-with-burg
## the ying and yang of cli editors
sudo apt-get -y install vim nano
## Remove preinstalled apps
sudo apt-get -y purge gnome-mines gnome-mahjongg aisleriot gnome-sudoku thunderbird transmission-gtk
sudo rm -rf /usr/share/applications/ubuntu-amazon-default.desktop
## Note application versions in the ubuntu repository tend to lag behind, If the latest version is required install directly from there site.
sudo apt-get -y install g++ gcc make cmake
## 3D printing
sudo apt-get -y install slic3r meshlab
# Backup old source list before we start messing with it
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
## https://ultimaker.com/en/resources/21362-cura-2-1-linux-not-working
sudo add-apt-repository -y ppa:thopiekar/cura
sudo apt-get -y update
sudo apt-get -y install cura cura-plugins-all
## Documentation software
sudo apt-get -y install vlc pandoc
sudo add-apt-repository -y ppa:webupd8team/atom
sudo apt-get -y update
sudo apt-get -y install atom
sudo add-apt-repository -y ppa:webupd8team/brackets
sudo apt-get -y update
sudo apt-get install -y brackets
sudo add-apt-repository -y ppa:maarten-baert/simplescreenrecorder
sudo apt-get -y update
sudo apt-get -y install simplescreenrecorder
#tools for microcontroller programming
sudo apt-get -y install gcc-avr avr-libc avrdude
#CAD 2D 3D simulation software
sudo apt-get -y install openscad inkscape gimp blender
#circuit design
sudo add-apt-repository -y ppa:jorik-kippendief/eagle
sudo apt-get update
sudo apt-get -y install eagle
#http://kicad-pcb.org/download/ubuntu/
sudo add-apt-repository -y ppa:js-reynaud/kicad-4
sudo apt-get update
sudo apt-get -y install kicad
#Git for version control
sudo apt-get -y install git
#arduino
wget https://downloads.arduino.cc/arduino-1.8.5-linux64.tar.xz
tar -xvf arduino-1.8*.tar.xz
sudo mv arduino-1.8.5 /opt
chmod +x /opt/arduino-1.8.5/install.sh
cd /opt/arduino-1.8.5/
sudo ./install.sh
cd ~/
#fab modules
# http://fabacademy.fablabcascina.org/tutorials/fabmodules-html5
# http://fabacademy.org/archives/2015/doc/fabmodules-html5.html
# https://github.com/FabModules/fabmodules-html5
# http://wiki.fablab.is/wiki/Fab_modules
# http://fabmodules.org/
# notes from debugging http://pastebin.com/XnJB9TBc
if [ $fabmodules == 'true' ]
then
sudo apt-get -y install nodejs npm python-serial python-tk python-serial python-pip
sudo git clone https://github.com/FabModules/fabmodules-html5.git /opt/fabmodules
#add symlink to node
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo groupadd fabmodules
sudo adduser $USER fabmodules
sudo adduser $USER dialout
#add local user to printer group
#sudo adduser $USER lpr
#put the python scripts into the local/user/bin so they can be run from any location.
#cd /usr/local/bin
sudo cp /opt/fabmodules/mod_server/mod_serial.py /usr/local/bin/mod_serial.py
sudo cp /opt/fabmodules/mod_server/mod_lp.py /usr/local/bin/mod_lp.py
# copy from the git we just cloned
#sudo wget -nc http://fabmodules.org/mod_server/mod_serial.py
#sudo wget -nc http://fabmodules.org/mod_server/mod_lp.py
sudo chmod +x /usr/local/bin/mod_lp.py
sudo chmod +x /usr/local/bin/mod_serial.py
#install ws in the mod_server directory so mod_server can find it
cd /opt/fabmodules/mod_server/
sudo npm install -g npm
sudo npm install node-static
sudo npm install serve-static
sudo npm install ws
sudo chown -R $USER ~/.npm/
sudo chown -R :fabmodules /opt/fabmodules/
sudo mkdir -p /var/log/fabmodules
sudo touch /var/log/fabmodules/mod_server.log
sudo chown -R :fabmodules /var/log/fabmodules/
sudo chmod g+w /var/log/fabmodules/mod_server.log
#/opt/fabmodules/mod_server$ sudo npm start
#mod_serial.py /dev/ttyUSB0 9600 dsrdtr
fi
#Blogging
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source /home/$USER/.rvm/scripts/rvm
rvm requirements
rvm install ruby
rvm use ruby --default
sudo apt-get -y install ruby-dev
rvm rubygems current
gem install jekyll
gem install github-pages
jekyll -v
# sudo cp -R /home/$USER/.rvm/ /etc/guest-session/skel/.rvm/
# Work out a nice way to set this up for guest accounts
### Setting up guest account ###
sudo mkdir -p /etc/guest-session/skel/
cd /etc/guest-session/
# Open captive portal page on login
sudo mkdir -p skel/.config/upstart/
sudo touch skel/.config/upstart/firefox-with-url.conf
sudo echo -e "start on desktop-start\nstop on desktop-end\nexec firefox https://wel-clearp1.massey.ac.nz/guest/aruba_guest_wireless.php" | sudo tee -a skel/.config/upstart/firefox-with-url.conf
#Create desktop shortcuts for guest user
sudo mkdir -p /etc/guest-session/skel/Desktop
printf "[Desktop Entry]\nVersion=1\nType=Application\nComment=This launches the locally installed FabModules Website\nIcon=application-x-executable\nName=FabModules (local)\nExec=firefox /opt/fabmodules/index.html\n" | sudo tee /etc/guest-session/skel/Desktop/localFabModules.desktop
printf "[Desktop Entry]\nName=Brackets\nType=Application\nCategories=Development\nExec=/opt/brackets/brackets %U\nIcon=brackets\nMimeType=text/html;\nKeywords=Text;Editor;Write;Web;Development;\nStartupWMClass=brackets\n" | sudo tee /etc/guest-session/skel/Desktop/brackets.desktop
printf "[Desktop Entry]\nName=Atom\nComment=A hackable text editor for the 21st century\nExec=/opt/atom/atom %F\nIcon=atom\nType=Application\nStartupNotify=true\nCategories=TextEditor;Development;Utility;\nMimeType=text/plain;\nX-Desktop-File-Install-Version=0.22\n" | sudo tee /etc/guest-session/skel/Desktop/atom.desktop
printf "[Desktop Entry]\nVersion=1\nName=Cura\nGenericName=3D Printing Software\nComment=Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great.\nExec=/usr/bin/cura %F\nTryExec=/usr/bin/cura\nIcon=/usr/share/cura/resources/images/cura-icon.png\nTerminal=false\nType=Application\nMimeType=application/sla;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;image/bmp;image/gif;image/jpeg;image/png\nCategories=Graphics;\nKeywords=3D;Printing;\n" | sudo tee /etc/guest-session/skel/Desktop/cura.desktop
printf "[Desktop Entry]\nCategories=Development;Engineering;Electronics;\nComment=Design a printed circuit board.\nExec=eagle %U\nGenericName=PCB Designer\nIcon=eagle\nMimeType=application/vnd.cadsoft.eagle.board;application/vnd.cadsoft.eagle.project;application/vnd.cadsoft.eagle.schematic\nName=Eagle\nType=Application\n" | sudo tee /etc/guest-session/skel/Desktop/eagle.desktop
sudo chmod u+x /etc/guest-session/skel/Desktop/*
# This is probably better done with an array... its on a trello card somewhere
# Test you can actually use the array is bash
#arraytest[0]='test' || (echo 'Failure: arrays not supported in this version of bash.' && exit 2)
#Mount share drive with write access for guests
sudo groupadd fabshare
sudo mkdir -m 0777 /var/guest-data
sudo cp /etc/fstab /etc/fstab.backup
#Check the name and file system of the shared drive before mounting
#sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
# echo "/dev/sdb2 /var/guest-data ntfs-3g defaults,windows_names,locale=en_NZ.UTF-8 0 0" | sudo tee -a /etc/fstab
sudo chown -R :fabshare /var/guest-data
sudo mkdir -p /etc/guest-session/skel/.config/gtk-3.0/
sudo touch /etc/guest-session/skel/.config/gtk-3.0/bookmarks
sudo echo -e "file:///var/guest-data" | sudo tee -a /etc/guest-session/skel/.config/gtk-3.0/bookmarks
#auto mount this as something more accessable
sudo touch /etc/guest-session/prefs.sh
GUESTCOMMS0=$(gettext 'sudo usermod -aG fabshare $USER')
GUESTCOMMS1=$(gettext 'sudo usermod -aG dialout $USER')
#dont do this if you didnt install fabmodules
GUESTCOMMS2=$(gettext 'sudo usermod -aG fabmodules $USER')
GUESTCOMMS3=$(gettext 'sudo ifconfig eno1 down')
GUESTCOMMS4=$(gettext 'sudo ifconfig wlp5s0 up')
#print list of networks with following command
#sudo iwlist wlp5s0 scan
GUESTCOMMS5=$(gettext 'sudo nmcli device wifi connect MUGuests iface wls6 --timeout 3')
GUESTCOMMS6=$(gettext '')
GUESTCOMMAND="$GUESTCOMMS0\n$GUESTCOMMS1\n$GUESTCOMMS2\n$GUESTCOMMS3\n$GUESTCOMMS4\n$GUESTCOMMS5\n$GUESTCOMMS6"
echo -e $GUESTCOMMAND | sudo tee -a /etc/guest-session/prefs.sh
#leave these two last
echo "chown -R $USER: $HOME" | sudo tee -a /etc/guest-session/prefs.sh
sudo chmod u+x /etc/guest-session/prefs.sh
#/usr/sbin/guest-account
#Disable default guest account warning message so we can display our own
sudo touch /etc/guest-session/skel/.skip-guest-warning-dialog
sudo touch /etc/guest-session/auto.sh
#things to go in | sudo tee -a /etc/guest-session/auto.sh
TITLE="\"Welcome to Fab Lab Wgtn\""
TEXT="\"Hi, Welcome to Ubuntu!\nFiles saved on this pc will be removed when you logout.\nPlease save anything you with to keep in the guest-data folder or online.\""
GUESTAUTO=$(gettext "{ sleep 4; zenity --info --no-wrap --title=$TITLE --text=$TEXT; }")
echo -e $GUESTAUTO | sudo tee -a /etc/guest-session/auto.sh
# this might not work? ^^^
### Secutiry lockdown to keep ITS happy
# Set wired lan interface to manual config
echo "iface eno1 inet manual" | sudo tee -a /etc/network/interfaces
sudo apt-get -y autoremove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment