Skip to content

Instantly share code, notes, and snippets.

@auriza
Last active May 23, 2018 01:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auriza/e45690fc728a3e98b7d936c12bd2906a to your computer and use it in GitHub Desktop.
Save auriza/e45690fc728a3e98b7d936c12bd2906a to your computer and use it in GitHub Desktop.
Xubuntu 2016 lab installation
#!/bin/bash
# Xubuntu 16.04 Lab Install
# <https://gist.github.com/auriza/e45690fc728a3e98b7d936c12bd2906a>
# INSTALL BASE SYSTEM (MANUAL ONE BY ONE) --------------------------------------
## Fresh install
# - Welcome : [Install Xubuntu]
# - Prepare : uncheck all options, [Continue]
# - Install : (*) Erase disk and install Xubuntu, [Install Now], [Continue]
# - Where? : Jakarta, [Continue]
# - Keyboard: [Continue]
# - Who? : [Continue]
# - Name : Admin Lab
# - Hostname: lab1-01
# - Username: adminlab
# - Password: ************
# - Confirm : ************
# - [Restart Now]
## Set static IP address
eth="$(ls /sys/class/net | grep en)"
host="$(hostname | tr -d a-z-)"
net="172.18.16"
cat << EOF | sudo tee -a /etc/network/interfaces
auto $eth
iface $eth inet static
address $net.$host
netmask 255.255.255.0
gateway $net.254
dns-nameservers 172.17.5.14 172.17.5.21
EOF
sudo service networking restart
## Set local repository
sudo tee /etc/apt/sources.list << EOF
deb http://172.18.12.13/ubuntu/ xenial main universe multiverse restricted
deb http://172.18.12.13/ubuntu/ xenial-security main universe multiverse restricted
deb http://172.18.12.13/ubuntu/ xenial-updates main universe multiverse restricted
EOF
## Install SSH for remote administration
sudo apt update
sudo apt install ssh
# APPLICATION ------------------------------------------------------------------
sudo adduser student
sudo apt update
sudo apt upgrade
## Download all additional app
wget "http://172.18.12.13/lab/list.txt"
wget -i list.txt
## Basic app
sudo ubuntu-drivers autoinstall
sudo apt install $(check-language-support)
sudo apt install virtualbox
sudo apt install p7zip unrar
sudo apt install libreoffice-impress libreoffice-base tesseract-ocr{,-ara,-ind}
sudo apt install dia gimp inkscape graphviz blender
sudo apt install mpv audacity vokoscreen
sudo apt install filezilla xul-ext-ublock-origin
sudo apt install htop tmux tree w3m ntpdate bmon curl
sudo apt install xubuntu-restricted-extras
curl "http://1.1.1.3/ac_portal/login.php" -d "opr=pwdLogin&userName=...&pwd=..."
sudo /usr/lib/update-notifier/package-data-downloader
sudo apt purge gigolo mousepad parole network-manager gnome-sudoku gnome-mines appstream
## Programming
sudo apt install geany build-essential git
sudo apt install yasm gdb ddd gcc-multilib
sudo apt install racket gprolog swi-prolog clips
## Java8
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo mkdir /var/cache/oracle-jdk8-installer
sudo cp jdk*.tar.gz /var/cache/oracle-jdk8-installer
sudo apt install oracle-java8-installer oracle-java8-set-default
## IDE
sudo apt install codeblocks netbeans
sudo apt install mono-complete mono-xsp4 monodevelop
## Machine Learning
sudo apt install r-recommended octave weka
## Library
sudo apt install freeglut3-dev libglew-dev libglfw3-dev
sudo apt install libopencv-dev opencv-doc python-opencv
sudo apt install mpi-default-* openmpi-doc
## Web and database
sudo apt install postgresql postgis pgadmin3 pgcli sqlite3
sudo apt install apache2 php libapache2-mod-php php-pgsql php-sqlite3
## Geospatial
sudo apt install qgis libjs-openlayers
## TeX
sudo apt install texlive pandoc pandoc-citeproc
## Radig
sudo apt install logisim iverilog gtkwave fritzing eagle
## Network
sudo apt install nmap traceroute whois wireshark
## Bioinformatics
sudo apt install ugene clustal* velvet* soapdenovo* bowtie* samtools plink
## Programming misc
sudo apt install golang rustc haskell-platform
# CUDA [if nvidia]
if [ $(lspci | grep VGA | grep -c NVIDIA) -eq 1 ]; then
sudo apt install nvidia-cuda-toolkit nvidia-nsight nvidia-visual-profiler
fi
# APPLICATION (NON-REPO) -------------------------------------------------------
## Ubuntu 16.04 Server VM
gunzip ubuntu-server.vdi.gz
sudo mkdir /opt/vm
sudo mv ubuntu-server.vdi /opt/vm
## PacketTracer --> 7.1.1
mkdir pt
tar -xvf PacketTracer*.tar.gz -C pt
cd pt
rm eula.txt set*.sh
sudo ./install
echo -e "PT7HOME=/opt/pt\nexport PT7HOME\nQT_DEVICE_PIXEL_RATIO=auto\nexport QT_DEVICE_PIXEL_RATIO\n" | sudo tee /etc/profile.d/pt7.sh
sudo tee /usr/share/applications/pt7.desktop << EOF
[Desktop Entry]
Exec=packettracer
Icon=/opt/pt/art/app.png
Type=Application
Categories=Education;
Terminal=false
Name=Packet Tracer
MimeType=application/x-pkt;application/x-pka;application/x-pkz;
EOF
cd
sudo rm -r pt
sudo apt install libqt5webkit5 libqt5script5 libqt5scripttools5
sudo dpkg -i libicu52*.deb
## RStudio --> 1.1.414
sudo dpkg -i rstudio*.deb
sudo apt install -f
## GeoServer --> 2.12.1
sudo unzip geoserver*.zip -d /opt
sudo mv /opt/geoserver* /opt/geoserver
echo -e "GEOSERVER_HOME=/opt/geoserver\nexport GEOSERVER_HOME\n" | sudo tee /etc/profile.d/geoserver.sh
sudo addgroup --system geoserver
sudo chown -R :geoserver /opt/geoserver
sudo chmod -R g=u /opt/geoserver
## PyCharmEdu --> 2017.3
sudo tar -xvf pycharm*.gz -C /opt
sudo mv /opt/pycharm* /opt/pycharm
sudo tee /usr/share/applications/jetbrains-pycharm.desktop << EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm Edu
Icon=/opt/pycharm/bin/pycharm.png
Exec="/opt/pycharm/bin/pycharm.sh" %f
Comment=The Drive to Develop
Categories=Development;
Terminal=false
StartupWMClass=jetbrains-pycharm
EOF
## MEGAN --> 6.10.6
chmod +x MEGAN*.sh
sudo ./MEGAN*.sh
## MetaSim --> 0.9.5
chmod +x MetaSim_unix*.sh
sudo ./MetaSim_unix*.sh -c
## TASSEL --> 5.2.41
chmod +x TASSEL*.sh
sudo ./TASSEL*.sh
## I-TASSER --> 5.1
sudo tar -xvf I-TASSER5.1.tar.bz2 -C /opt
sudo mv /opt/I-TASSER* /opt/i-tasser
## Android Studio --> 3.0.1
sudo unzip android*.zip -d /opt
sudo apt install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
sudo tee /usr/share/applications/jetbrains-studio.desktop << EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Icon=/opt/android-studio/bin/studio.png
Exec="/opt/android-studio/bin/studio.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-studio
EOF
## UnityEditor --> 2017.2.1f1
### https://forum.unity.com/threads/unity-on-linux-release-notes-and-known-issues.350256/page-2
sudo dpkg -i unity-editor*.deb
sudo apt install -f
## GravitDesigner --> 3.2.6
sudo unzip GravitDesigner.zip -d /opt
sudo rm /opt/Installation-Guide.html
sudo tee /usr/share/applications/gravit-designer.desktop << EOF
[Desktop Entry]
Name=Gravit Designer
Comment=Gravit Designer is a full featured free vector design app right at your fingertip.
Exec="/opt/GravitDesigner.AppImage" %U
Terminal=false
Type=Application
Icon=appimagekit-gravit-designer
Categories=Graphics;
TryExec=/opt/GravitDesigner.AppImage
EOF
## Pencil --> 3.0.4
sudo dpkg -i Pencil*.deb
## Postman --> 5.5.0
sudo tar -xvf Postman*.gz -C /opt
sudo tee /usr/share/applications/postman.desktop << EOF
[Desktop Entry]
Version=1.0
Type=Application
Name=Postman
Icon=/opt/Postman/resources/app/assets/icon.png
Exec=/opt/Postman/Postman
Categories=Development;
Terminal=false
EOF
## PyCrypto
tar -xvf pycrypto*.tar.gz
cd pycrypto*
sudo apt install python-dev python3-dev
python setup.py build
python3 setup.py build
sudo python setup.py install
sudo python3 setup.py install
cd ..
rm -r pycrypto
## SublimeText
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt update
sudo apt install sublime-text
## GoogleChrome
sudo dpkg -i google-chrome*.deb
sudo apt install -f
# SETTINGS ---------------------------------------------------------------------
## Autostart -> off
echo "Hidden=true" | sudo tee -a /etc/xdg/autostart/update-notifier.desktop
echo "Hidden=true" | sudo tee -a /etc/xdg/autostart/blueman.desktop
echo "Hidden=true" | sudo tee -a /etc/xdg/autostart/nm-applet.desktop
## Wallpaper
sudo mv ipb.jpg /usr/share/xfce4/backdrops
cd /usr/share/xfce4/backdrops
sudo rm xubuntu-wallpaper.png
sudo ln -s ipb.jpg xubuntu-wallpaper.png
cd
## Geany: colorscheme
unzip geany-themes-master.zip
sudo cp geany-themes-master/colorschemes/* /usr/share/geany/colorschemes/
rm -r geany-themes-master
## Geany: ASM x86, Markdown, Verilog, Python
sudo cp filetypes.{asm,markdown,verilog} /usr/share/geany/
sudo sed -i 's/CM=python /CM=python3 /' /usr/share/geany/filetypes.python
sudo sed -i '$ a set disassembly-flavor intel' /etc/gdb/gdbinit
# Disassociate qgis-mime from jpeg and tiff
sudo sed -i 's|image/tiff;image/jpeg;image/jp2;||' /usr/share/applications/qgis.desktop
sudo sed -i '66,117 d' /usr/share/mime/packages/qgis.xml
sudo update-mime-database /usr/share/mime
# Remove some app from desktop menu
sudo rm /usr/share/applications/{bmon,monodoc,unity-monodevelop}.desktop
# Fix Fritzing missing icon
sudo sed -i 's/\(Icon=fritzing\)/\1_icon.png/' /usr/share/applications/fritzing.desktop
## Apache module
sudo sed -i '21,25 s/^/#/' /etc/apache2/mods-available/php7.0.conf
sudo a2enmod userdir rewrite
sudo service apache2 restart
## Kill WiFi and BT
sudo sed -i '$ i rfkill block all' /etc/rc.local
# USER STUDENT -----------------------------------------------------------------
## Add user student to groups
sudo adduser student med
sudo adduser student geoserver
sudo adduser student wireshark
sudo adduser student vboxusers
su student -c /opt/geoserver/bin/startup.sh
su student -c /opt/geoserver/bin/shutdown.sh
## Postgres
sudo su - postgres
psql << EOF
CREATE USER student WITH PASSWORD 'student' CREATEDB;
CREATE DATABASE student OWNER student;
\c student;
CREATE EXTENSION adminpack;
CREATE EXTENSION postgis;
EOF
logout
## Store student default home directory
sudo 7zr a /opt/student.7z /home/student
# SECURITY ---------------------------------------------------------------------
## Add timestamp to bash_history
sudo sed -i '$ a HISTTIMEFORMAT="%F %T "' /etc/bash.bashrc
## Disable student password change
sudo passwd student -n 2000
## Disable student SSH
sudo sed -i '$ a DenyUsers student' /etc/ssh/sshd_config
# WINDOWS VM -------------------------------------------------------------------
## Download and extract VDI (076ff3bc23466fce97f0853bed6e2c17)
unrar e win7_lab_201609.vdi.rar
sudo mv win7_lab.vdi /opt/vm
sudo chown root:vboxusers /opt/vm/win7_lab.vdi
sudo chmod 755 /opt/vm/win7_lab.vdi
## Create VM Win7 (run as student)
su - student
vboxmanage setproperty machinefolder ~/.vm
vboxmanage modifyhd /opt/vm/win7_lab.vdi --type immutable
vboxmanage createvm --name "win7_lab" --ostype "Windows7" --register
vboxmanage modifyvm "win7_lab" --memory 1536 --vram 32 --clipboard bidirectional
vboxmanage storagectl "win7_lab" --name "SATA Controller" --add sata
vboxmanage storageattach "win7_lab" --storagectl "SATA Controller" --device 0 --port 0 --type hdd --mtype immutable --medium /opt/vm/win7_lab.vdi
vboxmanage sharedfolder add "win7_lab" --name "Public" --hostpath ~/Public/ --automount
vboxmanage setextradata global "GUI/SuppressMessages" "all"
vboxmanage setextradata "win7_lab" "GUI/Fullscreen" "on"
logout
# MAINTENANCE ------------------------------------------------------------------
sudo apt update
sudo apt upgrade
sudo apt autoremove --purge
## Clean and restore student's home
su - student
rm -rf * .*
7zr x /opt/student.7z
mv -f student/.* .
rm -r student
vboxmanage setproperty machinefolder ~/.vm
vboxmanage modifyhd /opt/vm/win7_lab.vdi --type immutable
vboxmanage createvm --name "win7_lab" --ostype "Windows7" --register
vboxmanage modifyvm "win7_lab" --memory 1536 --vram 32 --clipboard bidirectional
vboxmanage storagectl "win7_lab" --name "SATA Controller" --add sata
vboxmanage storageattach "win7_lab" --storagectl "SATA Controller" --device 0 --port 0 --type hdd --mtype immutable --medium /opt/vm/win7_lab.vdi
vboxmanage sharedfolder add "win7_lab" --name "Public" --hostpath ~/Public/ --automount
vboxmanage setextradata global "GUI/SuppressMessages" "all"
vboxmanage setextradata "win7_lab" "GUI/Fullscreen" "on"
logout
## Recreate student's database
sudo su - postgres
psql -tc "SELECT 'DROP DATABASE ' || datname || ';' FROM pg_database, pg_user WHERE datdba = usesysid AND usename = 'student';" | psql
psql << EOF
DROP OWNED BY student CASCADE;
CREATE DATABASE student OWNER student;
\c student;
CREATE EXTENSION adminpack;
CREATE EXTENSION postgis;
EOF
logout
## Reinstall Geoserver
sudo rm -r /opt/geoserver
sudo unzip geoserver*.zip -d /opt
sudo mv /opt/geoserver* /opt/geoserver
sudo chown -R :geoserver /opt/geoserver
sudo chmod -R g=u /opt/geoserver
su student -c /opt/geoserver/bin/startup.sh
su student -c /opt/geoserver/bin/shutdown.sh
# AFTERCLONE: SET HOSTNAME AND IP ADDRESS --------------------------------------
sudo editor /etc/hostname
sudo editor /etc/hosts
sudo editor /etc/network/interfaces
# WAKE ON LAN (WOL) ------------------------------------------------------------
## BIOS Enable WOL
#~ - Lenovo: Boot -> F1
#~ - F9 (defaults)
#~ - Power: Automatic: Wake on LAN: Enabled
#~ - Security: Admin password: ******
#~ - F10 (save)
#~ - HP: Boot -> F10
#~ - F5 (defaults)
#~ - Power: WOL in S5: Enabled
#~ - Advanced: Supervisor password: ******
#~ - F10 (save)
# ------------------------------------------------------------------------------
#TODO: cron @reboot clear-restore-student.sh
#TODO: monitor IP traffic
#TODO: Monitor -> Reset -> Text -> Lock
# ------------------------------------------------------------------------------
## MONITORING
# server: sudo apt install epoptes
sudo apt install epoptes-client
sudo sed -i '$ a 172.18.12.13\tserver' /etc/hosts
sudo epoptes-client -c
# ------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment