Pierre-Luc

A simple PW bash install script!

Recommended Posts

Pierre-Luc    403

Just wanted to share a simple bash script I've been using lately to make installing ProcessWire a little faster. Feel free to modify it to your taste! :)
 
Just copy everything into a simple text file, I call mine "preparepw". Optionally, set this file to executable (chmod -x preparepw) and put it somewhere into your path to be able to load it as a regular command without the need to call it from sh ~/preparepw for example.
 
To run, first cd to where you want to install PW's root, e.g. /sites/mysite/ then call the script. It will create a /sites/mysite/wwwroot/ directory containing all of PW's files from current master, set the required permissions and rename htaccess.
 
It has an option to set the directory that, when unset, will default back to ./wwwroot. (e.g. preparepw public would install PW in ./public/). 

#!/bin/bash
# Version 2.0
INPUT=$1

if [[ -z $INPUT ]]; then
  INPUT="wwwroot"
  printf "Directory option not set, installing into ./$INPUT/...\n"
else
  printf "Installing in to ./$INPUT/...\n"
fi

# Select a version
printf "\nWhich ProcessWire branch do you want to install?\n"
options=("master" "dev" "devns")
select BRANCH in "${options[@]}"; do test -n "$BRANCH" && break; echo ">>> Invalid selection, please try again"; done

printf "\nDownloading ProcessWire $BRANCH branch, please hold on...\n"

# Get ProcessWire master and prepare files
if [ "$BRANCH" == "master" ]; then
  curl -o processwire.zip https://github.com/ryancramerdesign/ProcessWire/archive/master.zip -# -L
fi

if [ "$BRANCH" == "dev" ]; then
  curl -o processwire.zip https://github.com/ryancramerdesign/ProcessWire/archive/dev.zip -# -L
fi

if [ "$BRANCH" == "devns" ]; then
  curl -o processwire.zip https://github.com/ryancramerdesign/ProcessWire/archive/devns.zip -# -L
fi

unzip -q processwire.zip
rm processwire.zip

if [ "$BRANCH" == "master" ]; then
  mv ProcessWire-master $INPUT
fi

if [ "$BRANCH" == "dev" ]; then
  mv ProcessWire-dev $INPUT
fi

if [ "$BRANCH" == "devns" ]; then
  mv ProcessWire-devns $INPUT
fi

chmod -R u+rwX,go+rX,go-w $INPUT
mv $INPUT/htaccess.txt $INPUT/.htaccess

cd $INPUT

# Prompt for site profile
printf "\nWhich site profile will you be using?\n"
select d in site-*/; do test -n "$d" && break; echo ">>> Invalid selection, please try again"; done
mv $d site/
rm -rf site-*/

# Set permissions
chmod 777 site/assets
chmod 777 site/modules
chmod 666 site/config.php

printf "\n"
read -p "Press [Enter] once you've finished the installation process to remove the install files..."
rm install.php
rm -rf site/install
printf "\nInstallation files removed.\n"

printf "\nDirectory \"$INPUT\" all set for ProcessWire. Have fun! \n"

Edited by Pierre-Luc
  • Like 15

Share this post


Link to post
Share on other sites
kongondo    5,016

What's grab.pw?

http://processwire.com/download/

Grab.pw

Accessing the URL grab.pw will always download the latest stable version (ZIP), and www.grab.pw will load our GitHub page. 

Soma’s Online Installer[/size]

Yet another way to install ProcessWire is to use Soma's online installer. To use it, place this grabpw.php file to your web server, and then load it in your browser. It will download ProcessWire automatically and begin the installation process. Note that this technique may not work in all server environments.

  • Like 3

Share this post


Link to post
Share on other sites
WinnieB    22

Just wanted to share a simple bash script I've been using lately to make installing ProcessWire a little faster. Feel free to modify it to your taste! :)

Thanks, this is awesome! I've seen people mention scripting PW installations, it's very helpful to see an actual example.

  • Like 1

Share this post


Link to post
Share on other sites
bernhard    1,322

i did something similar here: https://github.com/BernhardBaumrock/vagrant-pw-lamp/blob/master/bin/grabpw

maybe it helps anyone who is as new to bash scripts as i am :D the part of creating the database is not needed in the new dev versions as this is already built in to core

it is part of my vagrant lamp that i use for quickly setting up dev-environments on my windows machine. i really like it! but there are other threads in the forum about this topic...

there's a lot more to find: https://processwire.com/talk/topic/9541-pw-cookie-cutter/

Share this post


Link to post
Share on other sites
Pierre-Luc    403

@BernhardB, yup, the PR I submit on database creation that Ryan accepted is directly linked to making the setup much, much faster. :)

I'm still looking into Vagrant and/or Docker automatic setups, but time being limited, it's still far from being there. :)

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.