Last active
September 4, 2019 10:50
-
-
Save oblique63/5642c8214dd08f407326 to your computer and use it in GitHub Desktop.
Opencart Vagrantfile (with VQMod and VQGen)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
PORT = 9999 | |
# Ignore this, cli-installation is buggy | |
AUTO_INSTALL = false | |
ADMIN = "admin" | |
PASS = "password123" | |
EMAIL = "[email protected]" | |
# Opencart info | |
OPENCART_VERSION = "2.0.1.0" | |
# Extensions | |
# TODO: setup https://github.com/Beyond-IT/opencart-test-suite | |
# TODO: Set flags to decide whether to install these extensions | |
VQMOD_VERSION = "2.5.1" | |
VQGEN_VERSION = "3.3.0" | |
# Override Engine requires OpenCart 2.0.1.0 -- Currently not working | |
OVERRIDE_ENGINE_URL = "http://www.opencart.com/index.php?route=extension/extension/download&extension_download_id=737748" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network "forwarded_port", guest: 80, host: PORT #, auto_correct: true | |
config.vm.network "private_network", ip: "192.168.50.4" | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "2048"] | |
end | |
config.vm.synced_folder ".", "/vagrant" | |
config.vm.synced_folder "opencart/upload", "/var/www/opencart", \ | |
create: true, group: "www-data", :mount_options => ['dmode=775', 'fmode=775'] | |
vhost_conf = <<-VHOST | |
<VirtualHost *:80> | |
ServerAdmin webmaster@localhost | |
DocumentRoot /var/www/opencart | |
<Directory /var/www/opencart> | |
AllowOverride All | |
</Directory> | |
Alias /adminer.php /usr/share/adminer/adminer.php | |
Alias /adminer.css /usr/share/adminer/adminer.css | |
</VirtualHost> | |
VHOST | |
#config.vm.provision "shell", run: "always", inline: "PATH=/vagrant/bin:$PATH" | |
config.vm.provision "shell", inline: <<-SHELL | |
cd /vagrant | |
export DEBIAN_FRONTEND="noninteractive" | |
echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections | |
# Install Stuff | |
sudo apt-get update | |
sudo apt-get -q -y install git unzip apache2 | |
sudo apt-get -q -y install mysql-server-5.6 mysql-client-5.6 | |
sudo apt-get -q -y install php5 php5-mysql php5-gd php5-curl php5-mcrypt | |
# MySQL | |
mysqladmin create opencart -u root | |
# PHP | |
sudo php5enmod mcrypt | |
# Composer Install | |
if [ ! -x /usr/local/bin/composer ]; then | |
curl -sS https://getcomposer.org/installer | php | |
chmod +x composer.phar | |
mv composer.phar /usr/local/bin/composer | |
echo "Ignore that, just call 'composer' directly" | |
else | |
echo "Composer already installed" | |
fi | |
# Adminer Install | |
if [ ! -d /usr/share/adminer ]; then | |
echo "#====> Installing Adminer" | |
sudo mkdir /usr/share/adminer | |
sudo wget "http://www.adminer.org/latest-mysql.php" -O /usr/share/adminer/adminer.php | |
sudo wget "https://raw.github.com/vrana/adminer/master/designs/pappu687/adminer.css" -O /usr/share/adminer/adminer.css | |
else | |
echo "Adminer already installed" | |
fi | |
# OpenCart Setup | |
if [ ! -d opencart/upload/install ]; then | |
echo "#====> Installing OpenCart #{OPENCART_VERSION}" | |
wget -nv https://github.com/opencart/opencart/archive/#{OPENCART_VERSION}.tar.gz | |
tar -xvf #{OPENCART_VERSION}.tar.gz | |
cp -r opencart-#{OPENCART_VERSION}/* opencart | |
rm -rf #{OPENCART_VERSION}.tar.gz opencart-#{OPENCART_VERSION} | |
ln -s opencart/upload www | |
mv opencart/upload/config-dist.php opencart/upload/config.php | |
mv opencart/upload/admin/config-dist.php opencart/upload/admin/config.php | |
mv opencart/upload/.htaccess.txt opencart/upload/.htaccess | |
# Auto-install is buggy | |
#if [ "#{AUTO_INSTALL}" = "true" ]; then | |
# echo "# Auto Installing OpenCart..." | |
# cd opencart/upload/install | |
# php cli_install.php install --db_hostname localhost \ | |
# --db_username root \ | |
# --db_password ''\ | |
# --db_database opencart \ | |
# --db_driver mysqli \ | |
# --username #{ADMIN} \ | |
# --password #{PASS} \ | |
# --email #{EMAIL} \ | |
# --http_server http://localhost:#{PORT}/ | |
# cd .. | |
# rm -rf install | |
#fi | |
else | |
echo "OpenCart already set up" | |
fi | |
# Permissions | |
cd /vagrant/opencart/upload | |
sudo chmod -f 777 system/cache system/logs system/library system/download download image image/cache image/data image/catalog config.php admin/config.php | |
# Extension Installations | |
# Check for extensions in 'extensions' directory, otherwise download them | |
cd /vagrant | |
if [ ! -d extensions ]; then | |
mkdir extensions | |
fi | |
cd extensions | |
### Override Engine Install -- NOT WORKING | |
#echo "#====> Installing Override Engine" | |
#wget -nv #{OVERRIDE_ENGINE_URL} -O override_engine.zip | |
#unzip override_engine.zip -d override_engine | |
#rm override_engine.zip | |
#cp override_engine/upload/index.php ../opencart/upload/index.php | |
#cp override_engine/upload/admin/index.php ../opencart/upload/admin/index.php | |
#cp override_engine/upload/system/startup.php ../opencart/upload/system/startup.php | |
#cp override_engine/upload/system/engine/action.php ../opencart/upload/system/engine/action.php | |
#cp override_engine/upload/system/engine/controller.php ../opencart/upload/system/engine/controller.php | |
#cp override_engine/upload/system/engine/loader.php ../opencart/upload/system/engine/loader.php | |
#cp override_engine/upload/system/library/language.php ../opencart/upload/system/library/language.php | |
#mkdir opencart/upload/override | |
### vQmod Install | |
if [ ! -d /vagrant/opencart/upload/vqmod ]; then # Not installed in OpenCart? | |
echo "#====> Installing vQmod #{VQMOD_VERSION}" | |
if [ ! -d vqmod-#{VQMOD_VERSION} ]; then # Not cached in extensions directory? | |
echo "# Downloading vQmod..." | |
wget -nv https://github.com/vqmod/vqmod/releases/download/v#{VQMOD_VERSION}-opencart.zip/vqmod-#{VQMOD_VERSION}-opencart.zip -O vqmod.zip | |
unzip vqmod.zip | |
rm vqmod.zip | |
mv vqmod vqmod-#{VQMOD_VERSION} | |
else | |
echo "# Using cached version in 'extensions/vQmod-#{VQMOD_VERSION}'" | |
fi | |
cp -r vqmod-#{VQMOD_VERSION}/ /vagrant/opencart/upload/vqmod | |
sudo chmod -f 777 /vagrant/opencart/upload/vqmod /vagrant/opencart/upload/vqmod/vqcache | |
echo "(Visit 'http://localhost:#{PORT}/vqmod/install' to finish installation)" | |
else | |
echo "vQmod #{VQMOD_VERSION} already installed" | |
fi | |
### vQGen Install | |
if [ ! -d /vagrant/opencart/upload/vqgen ]; then # Not installed in OpenCart? | |
echo "#====> Installing vQgen #{VQGEN_VERSION}" | |
if [ ! -d vqgen-#{VQGEN_VERSION} ]; then # Not cached in extensions directory? | |
echo "# Downloading vQgen..." | |
wget -nv https://github.com/uksb/vqgen/archive/v#{VQGEN_VERSION}.zip -O vqgen.zip | |
unzip vqgen.zip | |
rm vqgen.zip | |
else | |
echo "# Using cached version in 'extensions/vqgen-#{VQGEN_VERSION}'" | |
fi | |
cp -r vqgen-#{VQGEN_VERSION}/vqgen /vagrant/opencart/upload/vqgen | |
echo "(Read /vagrant/modules/vqgen-#{VQGEN_VERSION}/README.md for more configuration information)" | |
else | |
echo "vQGen #{VQGEN_VERSION} already installed" | |
fi | |
# End Extension Installations | |
cd /vagrant | |
# Themes | |
if [ ! -d themes ]; then | |
mkdir themes | |
fi | |
cd themes | |
### Blank Theme | |
if [ ! -d opencart-blank-theme ]; then | |
echo "#====> Loading blank theme" | |
git clone https://github.com/justinmarsan/opencart-blank-theme.git | |
rm -rf opencart-blank-theme/.git | |
fi | |
if [ ! -d /vagrant/opencart/upload/catalog/view/theme/blank ]; then | |
mkdir /vagrant/opencart/upload/catalog/view/theme/blank | |
cp -r opencart-blank-theme/image /vagrant/opencart/upload/catalog/view/theme/blank/image | |
cp -r opencart-blank-theme/stylesheet /vagrant/opencart/upload/catalog/view/theme/blank/stylesheet | |
cp -r opencart-blank-theme/template /vagrant/opencart/upload/catalog/view/theme/blank/template | |
fi | |
cd /vagrant | |
# Apache | |
sudo echo "#{vhost_conf}" > /etc/apache2/sites-enabled/000-default.conf | |
sudo a2enmod rewrite | |
sudo apache2ctl restart | |
echo "#########################################" | |
echo "Remember to delete the 'opencart/upload/install' directory after going through the installation!" | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment