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

update libs with back and debug mode

 Changes to be committed:
	modified:   includes/base.sh
	modified:   includes/git.sh
	modified:   includes/software.sh
parent 5e9394ba
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -75,11 +75,16 @@ function die()
# purpose: wait for user to press enter
# arguments:
# $1 -> user message
# #2 -> use back option?
function pause()
{
local msg="$1"
[ -z "${msg}" ] && msg="Press [Enter] key to continue..."
read -p "$msg"
local msg="$1"
local back="$2"
# default message
[ -z "${msg}" ] && msg="Press [Enter] key to continue"
# how to go back, with either default or user message
[ "$back" = true ] && msg="${msg}, [Ctrl+Z] to go back"
read -p "$msg..."
}
 
# purpose: return true if script is executed by the root user
Loading
Loading
@@ -159,6 +164,7 @@ function script_name()
# purpose: run a script from another script
# arguments:
# $1 -> name of script to be run
# #2 -> debug mode? (optional)
function run_script()
{
local name="$1"
Loading
Loading
@@ -173,14 +179,13 @@ function run_script()
dos2unix -k -q "${name}"
chmod +x "${name}"
 
# run the script
# clear the screen and run the script
[ "${2}" = true ] || clear
. ./"${name}"
echo "script: ${name} has finished"
 
# change back to original directory
cd - >/dev/null
echo "script: ${name} has finished"
read -p "Press enter to return to the main menu..."
}
 
# purpose: generate an RSA SSH keypair if none exists or copy from root
Loading
Loading
@@ -198,14 +203,14 @@ function gen_ssh_keys()
 
if [ "$use_ssh" = true ]; then
echo
echo "Note: ${ssh_dir}/id_rsa is for public/private key pairs to establish SSH connections to remote systems"
echo "Note: ${ssh_dir} is for public/private key pairs to establish SSH connections to remote systems"
echo
# check if id_rsa exists
if [ -e "${ssh_dir}/id_rsa" ]; then
echo "${ssh_dir}/id_rsa already exists"
else
# create a new ssh key with provided ssh key comment
pause "Press enter to generate a new SSH key at: ${ssh_dir}/id_rsa"
pause "Press [Enter] to generate a new SSH key at: ${ssh_dir}/id_rsa" true
ssh-keygen -b 4096 -t rsa -C "${comment}"
echo "SSH key generated"
chmod -c 0600 "${ssh_dir}/id_rsa"
Loading
Loading
@@ -218,7 +223,7 @@ function gen_ssh_keys()
echo
cat "${ssh_dir}/id_rsa.pub"
echo
read -p "Press enter to continue..."
read -p "Press [Enter] to continue..."
fi
echo
echo "Have you copied id_rsa.pub (above) to the SSH keys section"
Loading
Loading
@@ -285,7 +290,7 @@ function get_public_key()
local apt_keys="$HOME/apt_keys"
 
[ -z "${url}" ] && echo false && return
pause "Press enter to download and import the GPG Key..."
pause "Press [Enter] to download and import the GPG Key..."
mkdir -pv "$apt_keys"
cd "$apt_keys"
# echo "changing directory to $_"
Loading
Loading
Loading
Loading
@@ -21,20 +21,16 @@ function configure_git()
local editor="$3"
local ignore="$HOME/.gitignore_global"
 
if [ -e "${ignore}" ]; then
echo "git is already configured."
else
read -p "Press enter to configure git..."
# specify a user
git config --global user.name "${name}"
git config --global user.email "${email}"
# select a text editor
git config --global core.editor "${editor}"
# set default push and pull behavior to the old method
git config --global push.default matching
git config --global pull.default matching
# create a global .gitignore file
echo "# global list of file types to ignore
# specify a user
git config --global user.name "${name}"
git config --global user.email "${email}"
# select a text editor
git config --global core.editor "${editor}"
# set default push and pull behavior to the old method
git config --global push.default matching
git config --global pull.default matching
# create a global .gitignore file
echo "# global list of file types to ignore
# from https://gist.githubusercontent.com/octocat/9257657/raw/c91b435be351fcdff00f6f97f20824d0286b99ef/.gitignore
 
# Compiled source #
Loading
Loading
@@ -78,12 +74,11 @@ Thumbs.db
# txt editor backups #
######################
*.*~" > "${ignore}"
git config --global core.excludesfile "${ignore}"
echo "git was configured"
echo
read -p "Press enter to view the config..."
git config --list
fi
git config --global core.excludesfile "${ignore}"
echo "git was configured"
echo
read -p "Press [Enter] to view the config..."
git config --list
}
 
# purpose: clone repository after fork
Loading
Loading
@@ -108,7 +103,7 @@ function clone_repo()
echo
echo "*** NOTE ***"
echo "Make sure \"github.com/${address}\" exists."
read -p "Press enter to clone ${address} at GitHub..."
read -p "Press [Enter] to clone ${address} at GitHub..."
if [ "$use_ssh" = true ]; then
git clone "git@github.com:${address}"
else
Loading
Loading
@@ -148,7 +143,7 @@ function set_remote_repo()
else
echo
if [ "$set_upstream" = true ]; then
read -p "Press enter to assign upstream repository..."
read -p "Press [Enter] to assign upstream repository..."
if [ "$use_ssh" = true ]; then
git remote add upstream "git@github.com:${address}" && echo "remote upstream added: git@github.com:${address}"
else
Loading
Loading
@@ -158,7 +153,7 @@ function set_remote_repo()
echo "*** NOTE ***"
echo "Make sure \"github.com/${address}\" exists."
echo "Either fork and rename it, or create a new repository in your GitHub."
read -p "Press enter to assign remote origin repository..."
read -p "Press [Enter] to assign remote origin repository..."
if [ "$use_ssh" = true ]; then
git remote add origin "git@github.com:${address}" && echo "remote origin added: git@github.com:${address}"
else
Loading
Loading
@@ -177,7 +172,7 @@ function create_branch()
local branch_name="$1"
echo
read -p "Press enter to create a git branch for your site at ${branch_name}..."
read -p "Press [Enter] to create a git branch for your site at ${branch_name}..."
git checkout -b "${branch_name}"
 
# some work and some commits happen
Loading
Loading
@@ -186,11 +181,11 @@ function create_branch()
#git rebase upstream/master or git rebase interactive upstream/master
 
echo
read -p "Press enter to push changes and set branch origin in config..."
read -p "Press [Enter] to push changes and set branch origin in config..."
git push -u origin "${branch_name}"
 
echo
read -p "Press enter to checkout the master branch again..."
read -p "Press [Enter] to checkout the master branch again..."
git checkout master
 
# above could also be done with:
Loading
Loading
@@ -211,14 +206,14 @@ function merge_upstream()
{
# pull in changes not present in local repository, without modifying local files
echo
read -p "Press enter to fetch changes from upstream repository..."
read -p "Press [Enter] to fetch changes from upstream repository..."
git fetch upstream && echo "upstream fetch done"
 
# merge any changes fetched into local working files
echo
echo "*** NOTE ***"
echo "If merging changes, press \":wq enter\" to accept the merge message in vi."
read -p "Press enter to merge changes..."
read -p "Press [Enter] to merge changes..."
git merge upstream/master
 
# or combine fetch and merge with:
Loading
Loading
@@ -238,7 +233,7 @@ function merge_upstream()
# push commits to your remote repository
# if $commit || git status | grep -qw "Your branch is ahead of"; then
# echo
# read -p "Press enter to push changes to your remote repository (GitHub)..."
# read -p "Press [Enter] to push changes to your remote repository (GitHub)..."
# git push origin master
# else
# echo "nothing to push, skipping push..."
Loading
Loading
Loading
Loading
@@ -77,7 +77,7 @@ function get_software()
echo
for url in ${list}; do
name="${url##*/}"
read -p "Press enter to download and extract: $name"
read -p "Press [Enter] to download and extract: $name"
wget -nc $url
tar -xzf $name
done
Loading
Loading
@@ -105,7 +105,7 @@ function install_apt()
for apt in $names; do
if [ "$(not_installed $apt)" = true ]; then
echo
read -p "Press enter to install $apt..."
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"; }
fi
done
Loading
Loading
@@ -127,7 +127,7 @@ function install_npm()
for app in $names; do
if ! npm ls -gs | grep -qw "$app"; then
echo
read -p "Press enter to install $app..."
read -p "Press [Enter] to install $app..."
sudo npm install -g "$app"
fi
done
Loading
Loading
@@ -145,7 +145,7 @@ function install_gem()
for app in $names; do
if ! $(gem list "$app" -i); then
echo
read -p "Press enter to install $app..."
read -p "Press [Enter] to install $app..."
gem install "$app"
fi
done
Loading
Loading
@@ -164,7 +164,7 @@ function install_pip()
app=$(trim_longest_right_pattern "$app" "[")
if ! pip list | grep "$app" >/dev/null 2>&1; then
echo
read -p "Press enter to install $app..."
read -p "Press [Enter] to install $app..."
sudo pip install "$app"
fi
done
Loading
Loading
@@ -175,7 +175,7 @@ function install_pip()
function install_ruby()
{
echo
read -p "Press enter to install ruby and rubygems..."
read -p "Press [Enter] to install ruby and rubygems..."
if ! ruby -v | grep -q "ruby ${RUBY_V}"; then
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -L "$RUBY_URL" | bash -s stable --ruby="${RUBY_V}"
Loading
Loading
@@ -187,7 +187,7 @@ function install_ruby()
function source_rvm()
{
echo
read -p "Press enter to start using rvm..."
read -p "Press [Enter] to start using rvm..."
if grep -q "/usr/local/rvm/scripts/rvm" $HOME/.bashrc; then
source /usr/local/rvm/scripts/rvm && echo "sourced rvm"
else
Loading
Loading
@@ -263,7 +263,7 @@ function clone_vv()
git clone https://github.com/bradp/vv.git "${repos}/vv"
# add vv directory to PATH
if ! grep -q "${repos}/vv" $HOME/.profile; then
echo "PATH=${repos}/vv:$PATH" >> $HOME/.profile
echo "PATH=${repos}/vv:'$PATH'" >> $HOME/.profile && source $HOME/.profile
echo "vv directory added to PATH so vv commands will work in terminal"
fi
fi
Loading
Loading
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