Monday, December 01, 2014

A Full Featured Shell Script for a MOXA V2616A Industrial Router

For anyone who gets their hands on a MOXA v2616A Computer,  this script will update the system with the MOXA repos as well an ip subnet etc.
Change the IP and Default Gateway to suit your needs.

Copy and Paste the below script
Save the File to .sh 
Give the file execution permissions
Execute the script as root or with sudo

#!/bin/bash
ifconfig eth0 192.168.16.164
route add default gw 192.168.16.240
echo "nameserver 192.168.16.240" > /etc/resolv.conf
cd /opt
apt-get install -y unzip
wget http://www.moxa.com/drivers/UC/V2616A/V2616A-LX_V1.0_Utility_MOXA_SYS_DEB_KEY.zip
unzip V2616A-LX_V1.0_Utility_MOXA_SYS_DEB_KEY.zip
rm -rf V2615A-LX_V1.0_Utility_MOXA_SYS_DEB_KEY.zip
cd V2616A-LX_V1.0_Utility_MOXA_SYS_DEB_KEY
mv NEW-MOXA-SYS-DEBIAN-KEY NEW-MOXA-SYS-DEBIAN-KEY.gpg
apt-key add NEW-MOXA-SYS-DEBIAN-KEY.gpg
echo "#Moxa Repos" >> /etc/apt/sources.list
echo "deb http://debian.moxa.com/debian wheezy main" >> /etc/apt/sources.list
echo "#Backported packages for Debian 7 'Wheezy'" >> /etc/apt/sources.list
echo "deb http://http.debian.net/debian/ wheezy-backports main contrib" >> /etc/apt/sources.list
apt-get update
apt-get install -y linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,')
echo "#Virtual Box Repos"
echo "deb http://download.virtualbox.org/virtualbox/debian wheezy contrib" >> /etc/apt/sources.list
cd /opt
wget "http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc" >> /etc/apt/sources.list
apt-key add oracle_vbox.asc
apt-get update
apt-get -t wheezy-backports install virtualbox-4.3 curl git zsh -y
apt-get upgrade -y
curl -L http://install.ohmyz.sh | sh
chsh -s /bin/zsh






Sunday, November 30, 2014

VirtualBox Tested Versions 4.0 4.1 4.2. 4.3

Confirmed working solution on Virtualbox 4.0 with Debian Wheezy
Confirmed working solution on Virtualbox 4.1 with Debian Wheezy
Confirmed working solution on Virtualbox 4.2 with Debian Wheezy
Confirmed working solution on Virtualbox 4.3.20-96996~Debian~wheezy

How To AutoStart Virtual Machines in Linux

How To AutoStart Virtual Machines with Virtual Box 4.3 in Linux

After much frustration with incomplete blog Posts, this guide works with full instructions on how to get one or multiple VM's running on boot just as root. This guide will start your VM's as the root user. Therefore this guide will automatically boot from the root user of which may be casue for concern based on your environment.
Hopefully this will help anyone looking for a fully working solution.
This guide was based on VirtualBox 4.3 installed on Debian 7.


Firstly, you need to create/edit the file /etc/default/virtualbox and add a few variables.


VBOXAUTOSTART_DB which contains an absolute path to the autostart database directory and
VBOXAUTOSTART_CONFIG which contains the location of the autostart config settings. The file should look similar to this:

root@home:~ nano /etc/default/virtualbox add to the end

# virtualbox defaults file
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg

Now we need to create the autostart  config file.
root@home:~ nano /etc/vbox/autostart.cfg  and add..

# Default policy is to deny starting a VM, the other option is "allow".
default_policy = allow
# Create an entry for each user allowed to run autostart
root ={
allow = true
startup_delay = 1
}

Set permissions on directory to the vboxuser group and make sure users can write to the directory as well as sticky bit.

root@home:~ sudo chgrp vboxusers /etc/vbox
root@home:~ sudo chmod 1775/etc/vbox



MAKE SURE YOU ARE LOGGED IN AS ROOT - SUDO IS NOT GOOD ENOUGH! or do sudo -s

root@home:~ VBoxManage setproperty autostartdbpath /etc/vbox
root@home:~ VBoxManage modifyvm windows7 --autostart-enabled on

root@home:~ touch /etc/vbox/root.start
root@home:~ chmod 777 /etc/vbox/root.start

root@home:~ nano /etc/rc.local and add the lines

/etc/init.d/vboxdrv start
/etc/init.d/vboxautostart-service start

place these BEFORE the "exit 0"

reboot and you should be set to go!
Good Luck!