Skip to content
Snippets Groups Projects
Commit f98a1bde authored by Keegan Mullaney's avatar Keegan Mullaney
Browse files

add wordpress dev code, del vars.sh

move vars into run so users don't have to modify vars.sh manually
remove $USER_NAME and use $HOME instead for simplicity in paths
comment out creation of new users

 Changes to be committed:
	modified:   README.md
	modified:   includes/base.lib
	modified:   includes/git.lib
	modified:   includes/software.lib
	modified:   run.sh
	modified:   scripts/aliases.sh
	modified:   scripts/linux_update.sh
	modified:   scripts/ssh_key.sh
	modified:   scripts/terminal_config.sh
	new file:   scripts/wordpress_dev.sh
	deleted:    vars.sh
parent 1381a4cd
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -10,7 +10,6 @@ Quickly configures a fresh install of [Ubuntu 14.04 x64][tt].
- [What it can do](#what-it-can-do)
- [Usage](#usage)
- [Clone or download this project](#clone-or-download-this-project)
- [Set variables for run.sh script](#set-variables-for-runsh-script)
- [Run it](#run-it)
- [SSH Keys](#ssh-keys)
- [License](#license)
Loading
Loading
@@ -32,10 +31,6 @@ Quickly configures a fresh install of [Ubuntu 14.04 x64][tt].
- HTTPS: `git clone https://github.com/keegoid/ubuntu-quick-config.git`
- SSH: `git clone git@github.com:keegoid/ubuntu-quick-config.git`
 
### Set variables for run.sh script
Open **vars.sh** with your favorite text editor and **edit the input variables** at the top to reflect your information.
### Run it
 
Run the main program with `./run.sh`
Loading
Loading
Loading
Loading
@@ -166,7 +166,7 @@ function run_script()
cd "$project_dir/scripts"
# echo "changing directory to $_"
# make sure dos2unix is installed
dpkg-query -W dos2unix >/dev/null 2>&1 || { echo >&2 "dos2unix will be installed."; sudo apt-get -y install dos2unix; }
[ -n "$(apt-cache policy dos2unix | grep 'Installed: (none)')" ] && { echo >&2 "dos2unix will be installed."; sudo apt-get -y install dos2unix; }
dos2unix -k -q ${script}
chmod +x ${script}
# sudo chown $(logname):$(logname) ${script} && echo "owner set to $(logname)"
Loading
Loading
@@ -211,7 +211,7 @@ function locate_repos()
# $1 -> SSH directory
# $2 -> SSH key comment
# $3 -> use SSH?
# $4 -> non-root Linux username (optional)
# $4 -> non-root Linux username
function gen_ssh_keys()
{
local ssh_dir="$1"
Loading
Loading
Loading
Loading
@@ -21,11 +21,9 @@ function configure_git()
local editor="$3"
local ignore="$HOME/.gitignore_global"
 
if git config --list | grep -q "${name}"; then
if [ -e "${ignore}" ]; then
echo "git is already configured."
else
echo
read -p "Press enter to configure git..."
# specify a user
git config --global user.name "${name}"
git config --global user.email "${email}"
Loading
Loading
@@ -74,7 +72,11 @@ function configure_git()
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db" > "${ignore}"
Thumbs.db
# txt editor backups #
######################
*.*~" > "${ignore}"
git config --global core.excludesfile "${ignore}"
echo "git was configured"
echo
Loading
Loading
Loading
Loading
@@ -83,6 +83,16 @@ function get_software()
done
}
 
# purpose: to check if program is NOT installed
# arguments:
# $1 -> program name
# returns: true if not installed, false if installed or unrecognized program name
function not_installed()
{
local app="$1"
[ -n "$(apt-cache policy ${app} | grep 'Installed: (none)')" ] && echo true || echo false
}
# purpose: to install programs from a list
# arguments:
# $1 -> program list (space-separated)
Loading
Loading
@@ -93,7 +103,7 @@ function install_apt()
local repo="$2"
# install applications in the list
for apt in $names; do
if ! dpkg-query -W "$apt" >/dev/null 2>&1; then
if [ "$(not_installed $apt)" = true ]; then
echo
read -p "Press enter to install $apt..."
[ -z "${repo}" ] && sudo apt-get -y install "$apt" || { sudo apt-add-repository "${repo}"; sudo apt-get update; sudo apt-get -y install "$apt"; }
Loading
Loading
@@ -114,8 +124,10 @@ function install_npm()
# make sure npm is installed
install_apt "npm"
# symlink nodejs to path
sudo ln -s "$(which nodejs)" /usr/bin/node
# symlink nodejs to path
if [ ! -L /usr/bin/node ]; then
sudo ln -s "$(which nodejs)" /usr/bin/node
fi
# install npm packages in the list
for app in $names; do
if ! npm ls -gs | grep -qw "$app"; then
Loading
Loading
@@ -192,9 +204,67 @@ function source_rvm()
# purpose: to install keybase
function install_keybase()
{
# change to Downloads directory to download file and then back to original directory
cd /tmp
curl -O https://dist.keybase.io/linux/deb/keybase-latest-amd64.deb && sudo dpkg -i keybase-latest-amd64.deb
cd -
if [ "$(not_installed keybase)" = true ]; then
# change to tmp directory to download file and then back to original directory
cd /tmp
curl -O https://dist.keybase.io/linux/deb/keybase-latest-amd64.deb && sudo dpkg -i keybase-latest-amd64.deb
cd - >/dev/null
fi
}
# purpose: to install newer version of virtualbox per VVV requirements
function install_virtualbox()
{
if [ "$(not_installed virtualbox-5.0)" = true ]; then
# add virtualbox to sources list if not already there
if ! grep -q "virtualbox" /etc/apt/sources.list; then
echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" | sudo tee --append /etc/apt/sources.list
fi
# add signing key
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
# update sources and install the latest virtualbox
sudo apt-get update
install_apt "virtualbox-5.0 dkms"
fi
}
# purpose: to install newer version of vagrant per VVV requirements
function install_vagrant()
{
if [ "$(not_installed vagrant)" = true ]; then
# change to tmp directory to download file and then back to original directory
cd /tmp
curl -O https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb && sudo dpkg -i vagrant_1.8.1_x86_64.deb
cd - >/dev/null
fi
# install vagrant-hostsupdater
[ -z "$(vagrant plugin list | grep hostsupdater)" ] && vagrant plugin install vagrant-hostsupdater
# install vagrant-triggers
[ -z "$(vagrant plugin list | grep triggers)" ] && vagrant plugin install vagrant-triggers
}
# purpose: to clone vvv
function clone_vvv()
{
if ! [ -d ../../vagrants/vvv ]; then
# clone VVV to vagrants directory one level up
git clone https://github.com/Varying-Vagrant-Vagrants/VVV.git ../../vagrants/vvv
echo "use \'vagrant up\' to start VVV from within ../../vagrants/vvv"
fi
}
# purpose: to clone vv
function clone_vv()
{
local clonePath="$HOME/bin/vv"
if ! [ -d "${clonePath}" ]; then
# clone VV to bin/vv directory
git clone https://github.com/bradp/vv.git "${clonePath}"
# add bin/vv directory to PATH
if ! grep -q "${clonePath}" $HOME/.profile; then
echo "PATH=${clonePath}:$PATH" >> $HOME/.profile
echo "vv directory added to PATH so vv commands will work in terminal"
fi
fi
}
 
Loading
Loading
@@ -10,15 +10,34 @@ echo "# "
echo "# http://keegoid.mit-license.org "
echo "# --------------------------------------------"
 
source vars.sh
# library files
LIBS='base.lib software.lib git.lib'
LIBS_DIR='includes'
# for screen error messages
RED='\033[0;41;30m'
STD='\033[0;0;39m'
 
# source function libraries
for lib in $LIBS; do
[ -d "$LIBS_DIR" ] && { source "$LIBS_DIR/$lib" > /dev/null 2>&1 && echo "sourced: $LIBS_DIR/$lib" || echo "can't find: $LIBS_DIR/$lib"; }
done
 
# make sure curl is installed
install_apt "curl"
# config for server
IS_SERVER=$(confirm "Is this a server?")
# user inputs
read -ep "enter your name for git: " -i 'Keegan Mullaney' REAL_NAME
read -ep "enter your email for git: " -i 'keeganmullaney@gmail.com' EMAIL_ADDRESS
read -ep "enter your prefered text editor for git: " -i 'vi' GIT_EDITOR
read -ep "enter a comment for your ssh key: " -i 'coding key' SSH_KEY_COMMENT
read -ep "enter apps to install with apt-get: " -i 'deluge gist gnupg2 gufw lynx nautilus-open-terminal xclip vim vlc' APT_PROGRAMS
read -ep "enter apps to install with pip: " -i 'jrnl[encrypted]' PIP_PROGRAMS
read -ep "enter apps to install with npm: " -i 'doctoc' NPM_PROGRAMS
# make sure curl and git are installed
install_apt "curl git"
#install_apt "curl git openssh-server"
 
# local repository location
# use Dropbox for Repos directory?
Loading
Loading
@@ -27,9 +46,6 @@ install_apt "curl"
#REPOS=$(locate_repos $USER_NAME $DROPBOX)
#echo "repository location: $REPOS"
 
# config for server
IS_SERVER=$(confirm "Is this a server?")
# install software and update system
function updates_go()
{
Loading
Loading
@@ -90,11 +106,23 @@ function terminal_go()
pause
}
 
# wordpress
function wordpress_go()
{
echo "# -------------------------------"
echo "# SECTION 6: WORDPRESS DEV "
echo "# -------------------------------"
# install requirements for WordPress development
run_script wordpress_dev.sh
pause
}
# code to run before exit
function finish_up()
{
# set ownership
sudo chown -cR $USER_NAME:$USER_NAME "$WORKING_DIR"
sudo chown -cR $(logname):$(logname) "$HOME"
echo
echo "# --------------------------------------------------------------------"
echo "# Lastly: execute sudo ./sudoers.sh to increase the sudo timeout. "
Loading
Loading
@@ -122,22 +150,24 @@ display_menu()
echo "3. SSH KEY"
echo "4. ALIASES"
echo "5. TERMINAL CONFIG"
echo "6. EXIT"
echo "6. WORDPRESS DEVELOPMENT"
echo "7. EXIT"
}
 
# user selection
select_options()
{
local choice
read -r -p "Enter choice [1 - 6]: " choice
read -rp "Enter choice [1 - 7]: " choice
case $choice in
1) updates_go;;
2) git_go;;
3) ssh_go;;
4) aliases_go;;
5) terminal_go;;
6) finish_up && exit 0;;
*) echo -e "${RED}Error...${STD}" && sleep 2
6) wordpress_go;;
7) finish_up && exit 0;;
*) echo -e "${RED}Error...${STD}" && sleep 1
esac
}
Loading
Loading
Loading
Loading
@@ -10,18 +10,18 @@ echo "# http://keegoid.mit-license.org "
echo "# --------------------------------------------"
 
# if user doesn't exist, add new user
if [ "$(user_exists $USER_NAME)" = false ]; then
echo
sudo /usr/sbin/adduser $USER_NAME
fi
#if [ "$(user_exists $USER_NAME)" = false ]; then
# echo
# sudo /usr/sbin/adduser $USER_NAME
#fi
 
# append aliases to .bashrc if not done already
pause "Press enter to add useful aliases for $USER_NAME..."
if grep -q "alias wget" /home/$USER_NAME/.bashrc; then
echo "already added aliases for $USER_NAME..."
if grep -q "alias wget" $HOME/.bashrc; then
echo "already added aliases..."
else
# alias useful shell commands
cat << EOF >> /home/$USER_NAME/.bashrc
pause "Press enter to add useful aliases..."
# alias useful shell commands, EOF must not be indented
cat << EOF >> $HOME/.bashrc
 
# make directories and parents
alias mkdir='mkdir -pv'
Loading
Loading
@@ -69,8 +69,8 @@ alias osversion='cat /etc/*release*'
alias wget='wget -c'
 
# print aliases
alias aliases="cat /home/$USER_NAME/.bashrc"
alias aliases="cat $HOME/.bashrc"
EOF
echo "/home/$USER_NAME/.bashrc was updated"
echo "$HOME/.bashrc was updated"
fi
 
Loading
Loading
@@ -16,12 +16,7 @@ pause "Press enter to upgrade programs..."
sudo apt-get -y upgrade
 
# install programs with apt-get
install_apt "$WORKSTATION_PROGRAMS"
# install programs with apt-get
if [ "$IS_SERVER" = true ]; then
install_apt "$SERVER_PROGRAMS"
fi
install_apt "$APT_PROGRAMS"
 
# install gems
#install_gem "$GEM_PROGRAMS"
Loading
Loading
@@ -33,9 +28,7 @@ install_pip "$PIP_PROGRAMS"
install_npm "$NPM_PROGRAMS" true
 
# install keybase
pause "Press enter to install keybase..."
install_keybase
keybase version
 
#if [ "$DROPBOX" = true ]; then
# echo
Loading
Loading
Loading
Loading
@@ -10,10 +10,10 @@ echo "# http://keegoid.mit-license.org "
echo "# --------------------------------------------"
 
# if user doesn't exist, add new user
if [ "$(user_exists $USER_NAME)" = false ]; then
echo
sudo /usr/sbin/adduser $USER_NAME
fi
#if [ "$(user_exists $USER_NAME)" = false ]; then
# echo
# sudo /usr/sbin/adduser $USER_NAME
#fi
 
if [ "$IS_SERVER" = true ]; then
# make a copy of the original sshd config file
Loading
Loading
@@ -38,13 +38,13 @@ if [ "$IS_SERVER" = true ]; then
echo -e "SSH port set to $SSH_PORT\nclient alive interval set to $CLIENT_ALIVE"
 
# add public SSH key for new ssh user
SSH_DIRECTORY="/home/$USER_NAME/.ssh"
SSH_DIRECTORY="$HOME/.ssh"
 
# generate SSH keypair
# gen_ssh_keys $SSH_DIRECTORY "$SSH_COMMENT" true $USER_NAME
 
# add authorized key for ssh user
authorized_ssh_keys $SSH_DIRECTORY $USER_NAME
authorized_ssh_keys $SSH_DIRECTORY $(logname)
 
# use ufw to limit login attempts too
echo
Loading
Loading
@@ -58,10 +58,10 @@ if [ "$IS_SERVER" = true ]; then
-e "s|PasswordAuthentication yes|PasswordAuthentication no|" \
-e "s|#MaxStartups 10:30:60|MaxStartups 2:30:10|" \
-e "s|#Banner /etc/issue.net|Banner /etc/issue.net|" /etc/ssh/sshd_config
if grep -q "AllowUsers $USER_NAME" /etc/ssh/sshd_config; then
if grep -q "AllowUsers $(logname)" /etc/ssh/sshd_config; then
echo "AllowUsers is already configured"
else
sudo printf "\nAllowUsers $USER_NAME" >> /etc/ssh/sshd_config && echo -e "\nroot login disallowed"
sudo printf "\nAllowUsers $(logname)" >> /etc/ssh/sshd_config && echo -e "\nroot login disallowed"
fi
 
echo
Loading
Loading
@@ -69,6 +69,6 @@ if [ "$IS_SERVER" = true ]; then
sudo service ssh restart
else
# generate an RSA SSH keypair if none exists
gen_ssh_keys "/home/$USER_NAME/.ssh" "$SSH_KEY_COMMENT" true $USER_NAME
gen_ssh_keys "$HOME/.ssh" "$SSH_KEY_COMMENT" true $(logname)
fi
 
Loading
Loading
@@ -10,61 +10,61 @@ echo "# http://keegoid.mit-license.org "
echo "# --------------------------------------------"
 
# if user doesn't exist, add new user
if [ "$(user_exists $USER_NAME)" = false ]; then
echo
sudo /usr/sbin/adduser $USER_NAME
fi
#if [ "$(user_exists $USER_NAME)" = false ]; then
# echo
# sudo /usr/sbin/adduser $USER_NAME
#fi
 
# color terminal prompts
if grep -q "#force_color_prompt=yes" /home/$USER_NAME/.bashrc; then
if grep -q "#force_color_prompt=yes" $HOME/.bashrc; then
echo "adding color to terminal prompts"
sed -i.bak -e "s/#force_color_prompt=yes/force_color_prompt=yes/" /home/$USER_NAME/.bashrc
sed -i.bak -e "s|#force_color_prompt=yes|force_color_prompt=yes|" $HOME/.bashrc
else
echo "already set color prompts for $USER_NAME..."
echo "already set color prompts..."
fi
 
# terminal history lookup
pause "Press enter to add terminal history lookup for $USER_NAME..."
[ -e /home/$USER_NAME/.inputrc ] || printf "" > /home/$USER_NAME/.inputrc
if grep -q "backward-char" /home/$USER_NAME/.inputrc; then
echo "already added terminal history lookup for $USER_NAME..."
[ -e $HOME/.inputrc ] || printf "" > $HOME/.inputrc
if grep -q "backward-char" $HOME/.inputrc; then
echo "already added terminal history lookup..."
else
# terminal input config file
cat << 'EOF' >> /home/$USER_NAME/.inputrc
pause "Press enter to add terminal history lookup..."
# terminal input config file, EOF must not be indented
cat << 'EOF' >> $HOME/.inputrc
# shell command history lookup by matching string
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
EOF
echo "/home/$USER_NAME/.inputrc was created with:"
cat "/home/$USER_NAME/.inputrc"
echo "$HOME/.inputrc was created with:"
cat "$HOME/.inputrc"
fi
 
# proxy for terminal traffic
#PROXY=$(confirm "Do you wish to use a proxy for terminal operations?")
 
if [ "$PROXY" = true ]; then
# set proxy address and port in .bashrc
if grep -q "http_proxy" /etc/environment; then
echo "already set proxy for $USER_NAME..."
else
# check if trying to use lantern proxy without lantern installed
if ! dpkg-query -W lantern >/dev/null 2>&1 && [ "$PROXY_ADDRESS" = 'http://127.0.0.1:8787' ]; then
echo "error: Lantern is not installed, skipping proxy..."
echo "download Lantern from getlantern.org and run this script again"
else
echo "setting http_proxy var to: $PROXY_ADDRESS"
echo "" >> /home/$USER_NAME/.bashrc
echo "# proxy for terminal (set by $USER_NAME)" >> /home/$USER_NAME/.bashrc
echo "http_proxy=$PROXY_ADDRESS" >> /home/$USER_NAME/.bashrc
echo "http_proxy=$PROXY_ADDRESS" | sudo tee --append /etc/environment > /dev/null
echo "Acquire::http::proxy $PROXY_ADDRESS;" | sudo tee /etc/apt/apt.conf > /dev/null
echo "" | sudo tee /etc/apt/apt.conf > /dev/null
fi
fi
else
#if [ "$PROXY" = true ]; then
# # set proxy address and port in .bashrc
# if grep -q "http_proxy" /etc/environment; then
# echo "already set proxy..."
# else
# # check if trying to use lantern proxy without lantern installed
# if [ "$(not_installed lantern)" = true ] && [ "$PROXY_ADDRESS" = 'http://127.0.0.1:8787' ]; then
# echo "error: Lantern is not installed, skipping proxy..."
# echo "download Lantern from getlantern.org and run this script again"
# else
# echo "setting http_proxy var to: $PROXY_ADDRESS"
# echo "" >> /home/$USER_NAME/.bashrc
# echo "# proxy for terminal (set by $(logname))" >> $HOME/.bashrc
# echo "http_proxy=$PROXY_ADDRESS" >> $HOME/.bashrc
# echo "http_proxy=$PROXY_ADDRESS" | sudo tee --append /etc/environment > /dev/null
# echo "Acquire::http::proxy $PROXY_ADDRESS;" | sudo tee /etc/apt/apt.conf > /dev/null
# echo "" | sudo tee /etc/apt/apt.conf > /dev/null
# fi
# fi
#else
# echo
# echo "skipping proxy..."
fi
#fi
 
#!/bin/bash
echo "# --------------------------------------------"
echo "# Install requirments for WordPress dev. "
echo "# "
echo "# Author : Keegan Mullaney "
echo "# Website: http://keegoid.com "
echo "# Email : keeganmullaney@gmail.com "
echo "# "
echo "# http://keegoid.mit-license.org "
echo "# --------------------------------------------"
# wordpress development
VVV_REQS=$(confirm "install virtualbox and vagrant for VVV?" false)
if [ "$VVV_REQS" = true ]; then
install_virtualbox
install_vagrant
VVV_GO=$(confirm "clone VVV and VV for WordPress development?" false)
if [ "$VVV_GO" = true ]; then
clone_vvv
clone_vv
fi
fi
#!/bin/bash
# --------------------------------------------
# Set global variables for run.sh script.
#
# Author : Keegan Mullaney
# Website: http://keegoid.com
# Email : keeganmullaney@gmail.com
#
# http://keegoid.mit-license.org
# --------------------------------------------
# --------------------------------------------
# EDIT THESE VARIABLES WITH YOUR INFO
USER_NAME='kmullaney' # your Linux user
REAL_NAME='Keegan Mullaney'
EMAIL_ADDRESS='keegan@kmauthorized.com'
SSH_KEY_COMMENT='coding key'
GITHUB_USER='keegoid' # your GitHub username
GIT_EDITOR='vi'
#PROXY_ADDRESS='http://127.0.0.1:8787' # default uses Lantern
# programs to be installed
WORKSTATION_PROGRAMS='deluge gist git gnupg2 gufw lynx nautilus-open-terminal xclip vagrant vim virtualbox virtualbox-guest-additions-iso vlc'
SERVER_PROGRAMS='openssh-server'
#GEM_PROGRAMS='gist'
PIP_PROGRAMS='jrnl[encrypted]'
NPM_PROGRAMS='doctoc'
# --------------------------------------------
# for screen error messages
RED='\033[0;41;30m'
STD='\033[0;0;39m'
# library files
LIBS='base.lib software.lib git.lib'
LIBS_DIR='includes'
# save current directory
WORKING_DIR="$PWD"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment