# Vagrantfile to install OpenGnsys 1.1 virtual environment using VirtualBox provider. VAGRANTFILE_API_VERSION = "2" # VM provider: Oracle VM VirtualBox. ENV['VAGRANT_DEFAULT_PROVIDER'] = "virtualbox" # Language (accepted values: es_ES, ca_ES, en_GB). LANGUAGE = "es_ES" ENV['LC_ALL'] = LANGUAGE + ".UTF-8" # Number of OpenGnsys clients (accepted values: from 2 to 9). NCLIENTS = 4 # Repository virtual disk: file and size (GB). REPODISK = "ogRepo.vdi" REPOSIZE = 50 # Amount of memory for server and clients (MB) SERVERMEM = 1024 # Minimum: 512 CLIENTMEM = 512 # Minimum: 256 # Clients MAC address prefix. MACPREFIX = "08:00:27:0E:65:" NETPREFIX = "192.168.2." # Local port to access OpenGnsys Server. LOCALWEBPORT = 8443 # OpenGnsys Server provisioning script: prepare repo disk, install OpenGnsys, change default interface, configure DHCP server. OGSERVERSCRIPT = <> /etc/fstab mount -a fi # Install OpenGnsys and change server address. wget -q http://opengnsys.es/svn/branches/version1.1/installer/opengnsys_installer.sh -O - | bash || exit $? mv /opt/opengnsys/log/bash.log /opt/opengnsys/log/opengnsys_installer.log echo y | /opt/opengnsys/bin/setserveraddr enp0s8 # Insert DHCP data. for ((i=#{NCLIENTS}; i>0; i--)); do sed -i "/^}$/ i host ogClient0${i} { hardware ethernet #{MACPREFIX}0${i}; fixed-address #{NETPREFIX}1${i}; }" /etc/dhcp/dhcpd.conf done service isc-dhcp-server restart # Set language. export LANG="#{LANGUAGE}.UTF-8" echo "LANG=\"$LANG\"" > /etc/default/locale echo "LANG=\"$LANG\"" >> /etc/environment locale-gen --lang #{LANGUAGE} sed -i "s/XKBLAYOUT=.*/XKBLAYOUT=\"${LANG%_*}\"/" /etc/default/keyboard dpkg-reconfigure -fnoninteractive console-setup # Comment out next lines for automatic data insertion. #SQL="INSERT INTO aulas (nombreaula, idcentro, urlfoto, grupoid, ubicacion, puestos, modomul, ipmul, pormul, velmul, router, netmask, ntp, dns, proxy, modp2p, timep2p) VALUES ('Aula virtual', 1, 'aula.jpg', 0, 'Despliegue virtual con Vagrant.', 5, 2, '239.194.2.11', 9000, 70, '#{NETPREFIX}1', '255.255.255.0', '', '', '', 'peer', 30); INSERT INTO ordenadores (nombreordenador, ip, mac, idaula, idrepositorio, idperfilhard, idmenu, idproautoexec, grupoid, router, mascara, arranque, netiface, netdriver, fotoord) VALUES" #for ((i=1; i<=#{NCLIENTS}; i++)); do # SQL="$SQL ('ogClient0$i', '#{NETPREFIX}1$i', REPLACE('#{MACPREFIX}0$i',':',''), 1, 1, 0, 0, 0, 0, '#{NETPREFIX}1', '255.255.255.0', '00unknown', 'eth0', 'generic', 'fotoordenador.gif')," #done #mysql -u usuog -ppassusuog -D ogAdmBD -e "${SQL%,}" #/opt/opengnsys/bin/setclientmode ogLiveAdmin ogClient01 PERM #for ((i=2; i<=#{NCLIENTS}; i++)); do # /opt/opengnsys/bin/setclientmode ogLive ogClient0$i PERM #done # Comment out next lines to install new Angular-based web application (on early development). #apt-get install -y git nodejs npm #ln -fs nodejs /usr/bin/node #npm install bower -g #svn export http://opengnsys.es/svn/branches/version1.1-tickets/ogWebAdmin-ticket761/admin/WebConsole/angular /opt/opengnsys/www/angular #cd /opt/opengnsys/www/angular #chown -R vagrant.vagrant . #su vagrant -c "bower install -F" #sed -i 's!BASE_URL = .*$!BASE_URL = "https://localhost:#{LOCALWEBPORT}/opengnsys";!' ogWebAdmin/assets/js/config.constants.js #### TEMPORAL PATCHES #su vagrant -c "bower install angular-sanitize -F" #su vagrant -c "bower install angular-translate-loader-static-files -F" #su vagrant -c "bower install angular-ui-select -F" #su vagrant -c "bower install bootstrap -F" #su vagrant -c "bower install isteven-angular-multiselect -F" #ln -s globunet-util.min.css ogWebAdmin/lib/globunet/dist/css/globunet-util.css #cp -a ogWebAdmin/assets/i18n/es.json ogWebAdmin/assets/i18n/en.json #sed -i 's/jm.bardallo/usuog/' ogWebAdmin/assets/js/controllers/login.controller.js #sed -i "s/DirectoryIndex index.php/DirectoryIndex index.php index.html/" /etc/apache2/sites-enabled/opengnsys.conf #service apache2 reload echo "Notes:" echo "- OpenGnsys Server URL: https://localhost:#{LOCALWEBPORT}/opengnsys/" [ -d /opt/opengnsys/www/angular ] && echo "- Angular-based web URL: https://localhost:#{LOCALWEBPORT}/opengnsys/angular/ogWebAdmin/" exit 0 EOT # Client 1 OS provisioning script. MODELSCRIPT = <