Skip to content

Instantly share code, notes, and snippets.

@mezcel
Last active April 19, 2018 21:19
Show Gist options
  • Save mezcel/6ee0d73b72f2c43e82d3733ffa97bec3 to your computer and use it in GitHub Desktop.
Save mezcel/6ee0d73b72f2c43e82d3733ffa97bec3 to your computer and use it in GitHub Desktop.
A Gist version of the readme/info from my repo-pocket repository
#!/bin/bash
# set -e
###############################################################################
# Written for Linux Mint 18+ on x64
# Author : Mezcel
# Website : www.github.com/mezcel/repo-pocket/shell/linuxsetupShell.sh
# Compatable with: Git and Gitbash
###############################################################################
#
reset
echo "###############################################################################"
echo "# Intall/Update My Git Repos and their Linux Dependencies #"
echo "# --------------------------------------------------------------------------- #"
echo "# Author : Mezcel #"
echo "# Website : https://github.com/mezcel/repo-pocket #"
echo "# Dependancies will include: #"
echo "# git, python, pip, virtualenv, scrapy #"
echo "# dependancies will only install if not installed #"
echo "# if git repo does not exist, then it will pull update #"
echo "# Abort Feature: #"
echo "# After you are propted to enter a directory, you will be asked to #"
echo "# confirm. There you can retry or exit the shell setup. #"
echo "###############################################################################"
echo ""
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "# The Bash on this OS is: $OSTYPE"
echo "# Liunx will use its native bash, Windows will use GITBASH."
fi
echo ""
echo "# --------------------------------------------------------------------------- #"
echo "# Enter the desired Git Repo Root Directory #"
echo "# --------------------------------------------------------------------------- #"
echo "# Type in the desired root directory for the Git Repository #"
echo "# #"
echo "# Ex: Default drive is [github] on my Linux's and my Dev Win10's #"
echo "# Ex: Default drive is [/e/github] on my Win10 Kangaroo Mini #"
echo "# Ex: Default drive is [/d/github] on other Win10 machines #"
echo "# Note: Win10 Git root is typically default to: #"
echo "# Gitbash: c/users/[yourusername] #"
echo "# or #"
echo "# C:\Users\[yourusername] #"
echo "# #"
echo "# If you enter nothing, a folder named 'github' will be auto assigned #"
echo "# linux will be in your home root #"
echo "# windows will be in the d: drive (not everyone has a D: drive... #"
echo "# so remember to input your drive) like: (/d/ /e/ for d: e:) #"
echo "# #"
echo "# --------------------------------------------------------------------------- #"
echo ""
echo "# Enter a different path, if you so desire."
echo -n "# >> User Input
Type a Dir Path and press [ENTER]: "
read desiredgitdir
if [[ ! $desiredgitdir ]]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
desiredgitdir="github"
else
desiredgitdir="/d/github"
fi
fi
while [[ $myconfirm != 'n' ]] || [[ $myconfirm != 'y' ]] || [[ $myconfirm != 'r' ]] || [[ $myconfirm == '' ]]
do
echo ""
echo "# > CONFIRMATION:
# The Git directory on $OSTYPE is maped to [~/$desiredgitdir]"
echo ""
echo "# > Continue using the selected Git Clone/Git Pull directory?
# [y] - Yes, Perform the Git setup
# [r] - No, Rename Dir
# [n] - No, exit"
echo ""
echo -n "# >> User Input:
Enter [y, n, or r]: "
read -n 1 myconfirm
echo ""
if [ $myconfirm == 'n' ]; then
reset
echo ""
echo "###############################################################################"
echo "
███████╗██╗ ██╗██╗████████╗ ███████╗███████╗████████╗██╗ ██╗██████╗
██╔════╝╚██╗██╔╝██║╚══██╔══╝ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
█████╗ ╚███╔╝ ██║ ██║ ███████╗█████╗ ██║ ██║ ██║██████╔╝
██╔══╝ ██╔██╗ ██║ ██║ ╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
███████╗██╔╝ ██╗██║ ██║ ███████║███████╗ ██║ ╚██████╔╝██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝"
echo "###############################################################################"
echo ""
echo -n "# >> Press any key to EXIT"
read exitVar
exit
elif [ $myconfirm == 'y' ]; then
echo ""
echo "# Commencing Automated Setup ..."
echo ""
break
elif [ $myconfirm == 'r' ]; then
echo ""
echo "###############################################################################"
echo "# You opted to reinput your desired Git Repo Root Directory #"
echo "# --------------------------------------------------------------------------- #"
echo "# Type in the desired root directory for the Git Repository #"
echo "# #"
echo "# Ex: Default drive is [github] on my Linux's and my Dev Win10's #"
echo "# Ex: Default drive is [/e/github] on my bullshit Win10's #"
echo "# Note: Win10 Git root is typically default to: #"
echo "# Gitbash: c/users/[yourusername] #"
echo "# or #"
echo "# C:\Users\[yourusername] #"
echo "# #"
echo "# If you enter nothing, a folder named 'gihub' will be automatically assigned #"
echo "# linux will be in your home root #"
echo "# windows will be in the d: drive (many pc's dont have an d: drive... #"
echo "# so remember to input your drive) like: (c/ d/ e/ or c: d: e:) #"
echo "# #"
echo "###############################################################################"
echo ""
echo "# Enter a different path, if you so desire."
echo ""
echo -n "# >> User Input:
Type in a Dir/Folder Path/Name and press [ENTER]: "
read desiredgitdir
if [[ ! $desiredgitdir ]]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
desiredgitdir="github"
else
desiredgitdir="/d/github"
fi
fi
else
echo "#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#"
echo "# Input Error. Select either 'y' or 'n' #"
echo "#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#"
fi
done
echo "###############################################################################"
echo "
███████╗███████╗████████╗████████╗██╗███╗ ██╗ ██████╗ ██╗ ██╗██████╗
██╔════╝██╔════╝╚══██╔══╝╚══██╔══╝██║████╗ ██║██╔════╝ ██║ ██║██╔══██╗
███████╗█████╗ ██║ ██║ ██║██╔██╗ ██║██║ ███╗ ██║ ██║██████╔╝
╚════██║██╔══╝ ██║ ██║ ██║██║╚██╗██║██║ ██║ ██║ ██║██╔═══╝
███████║███████╗ ██║ ██║ ██║██║ ╚████║╚██████╔╝ ╚██████╔╝██║
╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝"
echo "###############################################################################"
echo ""
# Install Git
echo "# Preparing Git ..."
if ! [ -x "$(command -v git)" ]; then
echo '# Git is not installed.'
echo '# Attempting to install Git now. (https://git-scm.com/download/linux)'
echo '# sudo add-apt-repository ppa:git-core/ppa'
echo '# sudo apt-get update; apt install git'
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update; apt install git
#exit 1
else
echo '# Git is allready installed'
#exit 1
fi
# Install PIP
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo ""
echo "# Preparing PIP ..."
if ! [ -x "$(command -v pip)" ]; then
echo '# !!! Error: PIP is not installed. !!!'
echo '# Attempting to install PIP now ...'
# PIP Prerequisets
echo '# Installin PIP Prerequisets...'
echo '# sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev'
sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev
echo '# sudo apt-get install zlib1g-dev libffi-dev libssl-dev'
sudo '# apt-get install zlib1g-dev libffi-dev libssl-dev'
echo ""
#exit 1
else
echo '# PIP is allready installed'
#exit 1
fi
fi
# Setup Git for Github
echo ""
echo "# Preparing local Git repositories for Github"
# mydirname="github"
mydirname=$desiredgitdir
echo "# checking if $mydirname exists ..."
cd
if [ -d $mydirname ]; then
echo "# Directory path: $mydirname already exists"
echo ""
else
echo "# Directory path: $mydirname did not exists. The directory $mydirname will be made"
mkdir -p $mydirname
echo ""
fi
# Clone Github Repos
mygithub="https://github.com/mezcel"
repo1="repo-pocket"
repo2="document-generator"
repo3="scrapy-scrape-viewer"
repo4="googlemaps-api-helloworld"
repo5="Dynatree-Outline"
repo6="rosary-jquery-mobile"
repo7="Prophet-Booklet"
repo8="Bootstrap-Stations-of-the-Cross"
repo9="angular-wpt-maker"
repo10="plantid-Bootstrap"
repo11="Toggle-Tag"
## Windows Programms, Python, or Eclipse Projects ##
repo12="plantid"
repo13="rosary.net"
repo14="emgucv"
repo15="Chrome-Extension"
repo16="mezcel-vaporfuturelofiwave-syntax"
repo17="win-drives-icons"
repo18="photo-bat"
repo19="python"
repo20="adeptus-mechanicus-stc"
repo21="backyardgps"
repo22="catechism-scrape"
repo23="Csound-Ghostwriter"
repo100="myTmp"
echo ""
echo "######################## Add non-web browser repo's ##########################"
echo "# >> Do you want to import .net and other non-web browser specific projects?"
echo "# >> [y] - yes download the .net, python, batch.. ect files."
echo "# >> [any other key] - skips the dowun load of non browser specfifiv project"
echo "#"
echo -n "# >> Type in a letter, then press [ENTER]: "
read moreRepos
echo "#"
if [[ "$moreRepos" == "y" ]]; then
myrepoArr=($repo1 $repo2 $repo3 $repo4 $repo5 $repo6 $repo7 $repo8 $repo9 $repo10 $repo11 $repo12 $repo13 $repo14 $repo15 $repo16 $repo17 $repo18 $repo19 $repo20 $repo21 $repo22 $repo23)
else
myrepoArr=($repo1 $repo2 $repo3 $repo4 $repo5 $repo6 $repo7 $repo8 $repo9 $repo10 $repo11)
fi
echo "###############################################################################"
echo ""
echo "###############################################################################"
echo "# I made an array of repo names at arround (sh line: ~208 & ~221 )"
echo "###############################################################################"
echo ""
echo "# List of Local repos to setup:"
echo "# --------------------------------------------------------------------------- #"
echo ""
let i=1
for dirArr in "${myrepoArr[@]}"; do
echo "# Repo $((i++)): $dirArr"
echo "# -$mydirname/$dirArr"
echo "# -$mygithub/$dirArr.git"
echo ""
done
echo ""
echo "###############################################################################"
echo "# Perform Clone if Repo does not exist in directory #"
echo "# otherwise Repo will pull-update. #"
echo "###############################################################################"
let i=1
for dirArr in "${myrepoArr[@]}"; do
if [ ! -d $mydirname/$dirArr ]; then
echo ""
echo "# Repo $((i++)): Cloned Repo from Github.com"
echo "# Executing:"
echo "# git clone $mygithub/$dirArr.git"
echo ""
cd $mydirname
git clone $mygithub/$dirArr.git
elif [ -d $mydirname/$dirArr ]; then
echo ""
echo "# Repo $((i++)): $dirArr allready exists"
echo "# Downloading updates from the 'origin' remote repo"
echo "# $mygithub/$dirArr.git"
echo "# Executing: cd; cd $mydirname/$dirArr"
echo "# git init; git pull origin master"
echo "# Or: git init; git pull --rebase origin master"
echo ""
cd
cd $mydirname/$dirArr
git init
# git pull
git pull --rebase origin master
else
echo ""
echo "# idk"
echo ""
fi
# Rebuild virtualenv for each computer's use case
# I set, ahead of time, that repo3="scrapy-scrape-viewer"
# I want to check if $dirArr == $repo3
if [[ "$OSTYPE" == "linux-gnu" ]]; then
if [ $dirArr == "scrapy-scrape-viewer" ]; then
echo ""
echo "###########################################################################"
echo "# Virtualenv (on Linux) "
echo "# ----------------------------------------------------------------------- "
echo "# Virtual Environment is a virtual invironment & I use it with Scrapy. "
echo "# In each new git clone or git pull, I want a virtualenv for that setup. "
echo "# It has to do with YOUR's, MINE, and Github, have our own unique ENV "
echo "# Reloading/rebuiling/reconfiguring with ensure your ENV is YOUR ENV "
echo "# ----------------------------------------------------------------------- "
echo "# launching the .sh script from the Repo: $repo3"
echo "# Script File: ~/reset-scrapy-viewer.sh"
echo "# Virtualenv path: cd $mydirname/$dirArr/scrapyvirtualenv"
echo "# "
echo "########################### sh line: ~273-~324 ############################"
echo ""
# make a temporary placeholder for the files/dirs i want to keep
cd
cd $mydirname/$dirArr/scrapyvirtualenv
mkdir -p myTempCrawlerContainer
ls
# Recursive Copy and paste the Dir i want to keep and use
# cp -r [deisred file path] [new desired dir path]
cp -r expresspros myTempCrawlerContainer
cp -r jobsups myTempCrawlerContainer
cp -r stackoverflow myTempCrawlerContainer
cp -r targetedjobfairs myTempCrawlerContainer
ls
# Delete unwanted imported folders
rm -r bin
rm -r include
rm -r lib
rm -r local
rm -r expresspros
rm -r jobsups
rm -r stackoverflow
rm -r targetedjobfairs
# Delete unwanted imported files
rm pip-selfcheck.json
# Step up to its parent directory and define child folder as a virtual environment
echo ""
echo "# Preparing virtualenv ..."
if ! [ -x "$(command -v virtualenv)" ]; then
echo '# virtualenv is not installed.'
echo '# Attempting to install virtualenv now.'
echo '# Performing: sudo apt install virtualenv'
sudo apt-get install virtualenv
#exit 1
else
echo '# Virtualenv is allready installed'
#exit 1
fi
echo ""
# cd ../
cd
echo "# --------------------------------------------------------------------------- #"
echo "# Commense Virtualenv rebuild for Scrappy #"
echo "# --------------------------------------------------------------------------- #"
echo ""
cd $mydirname/$dirArr
# this assumes virtualenv is installed at this point
virtualenv scrapyvirtualenv
ls
cd scrapyvirtualenv
source bin/activate
pip install scrapy
ls
cd myTempCrawlerContainer
cp -r expresspros ../
cp -r jobsups ../
cp -r stackoverflow ../
cp -r targetedjobfairs ../
cd ..
rm -r myTempCrawlerContainer
deactivate
echo ""
echo "# --------------------------------------------------------------------------- #"
echo "# Virtualenv rebuild for Scrappy iscompleted #"
echo "# --------------------------------------------------------------------------- #"
fi
fi
cd
done
echo ""
echo "###############################################################################"
echo "# The Desired Repo's are installed #"
echo "###############################################################################"
echo ""
echo "# Memory allocated in Git:"
echo "# --------------------------------------------------------------------------- #"
let i=1
for dirArr in "${myrepoArr[@]}"; do
cd
cd $mydirname/$dirArr
echo ""
echo "# (Repo $((i++))) Local Dir: ~/$mydirname/$dirArr"
echo "# File size:"
du -hcs
done
echo ""
echo "# --------------------------------------------------------------------------- #"
echo -n "# Total Root size of ~/$mydirname is: "
cd
cd $mydirname
du -hcs
echo "# The large size is mostly due to Scrapy and Virtualenv. A repo within a repo."
echo "###############################################################################"
echo "
███████╗███████╗████████╗██╗ ██╗██████╗
██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
███████╗█████╗ ██║ ██║ ██║██████╔╝
╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
███████║███████╗ ██║ ╚██████╔╝██║
╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝
██████╗ ██████╗ ███╗ ███╗██████╗ ██╗ ███████╗████████╗███████╗██████╗
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██║ ██╔════╝╚══██╔══╝██╔════╝██╔══██╗
██║ ██║ ██║██╔████╔██║██████╔╝██║ █████╗ ██║ █████╗ ██║ ██║
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██╔══╝ ██║ ██╔══╝ ██║ ██║
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ███████╗███████╗ ██║ ███████╗██████╔╝
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝╚═════╝"
echo "###############################################################################"
echo "# I am now leaving you in the Root Dir you initially setup. Enjoy."
echo ""
echo "no wait... i want to plop in some LAMP related and remote RDP/VNC related things"
echo " this applied only to LINUX..."
echo " i use for my 'pocket linux server'. It literally fits in a shirt pocket"
echo " i 'cloud' everywhere' with it"
echo ""
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo ""
echo "# ----------------------------- LAMP ----------------------------------------- #"
echo ""
echo "# Preparing LAMP Server ..."
echo "# If acpache2 is not installed, I will just assume you dont have LAMP setup ..."
if ! [ -x "$(command -v apache2)" ]; then
echo '# apache2 is not installed. lets get some.'
echo ""
# LAMP
sudo apt-get update
sudo apt update && sudo apt install lamp-server^
sudo apt-get update
else
echo '# apache2 is allready installed'
#exit 1
fi
echo ""
echo "# ------------------------------- acpi -------------------------------------- #"
echo ""
echo "# Preparing acpi ..."
echo "# this is just for easy battery hardware readings. it is used to monitor my pocket server"
if ! [ -x "$(command -v acpi)" ]; then
echo '# acpi is not installed. lets get some.'
echo ""
# acpi
sudo apt-get update
sudo apt-get install acpi
sudo apt-get update
else
echo '# acpi is allready installed'
#exit 1
fi
echo ""
echo "# --------------------------- tightvncserver -------------------------------- #"
echo ""
echo "# Preparing tightvncserver ..."
echo "# this is for remote terminal stuff"
if ! [ -x "$(command -v vncserver)" ]; then
echo '# tightvncserver is not installed. lets get some.'
echo ""
# tightvnc
sudo apt-get update
sudo apt install tightvncserver
sudo apt-get update
else
echo '# tightvncserver is allready installed'
#exit 1
fi
echo ""
echo "# -------------------------- openssh-server --------------------------------- #"
echo ""
echo "# Preparing things related to remote terminal through SSH ..."
echo "# openssh-server and xrdp"
echo "# this is for remote terminal stuff"
if ! [ -x "$(command -v ssh)" ]; then
echo '# ssh is not installed. lets get some.'
echo ""
# remote client connectors
sudo apt-get update
sudo apt-get install openssh-server
sudo apt-get update
sudo apt install xrdp
sudo apt-get update
sudo apt list --upgradable
sudo apt-get list --upgradable
else
echo '# openssh-server is allready installed'
#exit 1
fi
echo ""
echo "# ------------------------------ phpmyadmin --------------------------------- #"
echo ""
echo "# Preparing phpmyadmin ..."
if ! [ -x "$(command -v php)" ]; then
echo '# php is not installed. lets get some.'
echo ""
# Install phpMyAdmin
sudo apt-get update
sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo apt-get update
else
echo '# phpmyadmin is allready installed'
#exit 1
fi
echo ""
echo "# --------------------------- mysql workbench ------------------------------- #"
echo "https://www.ubuntuupdates.org/package/core/artful/universe/base/mysql-workbench"
echo ""
echo "# Preparing mysql-workbench ..."
if ! [ -x "$(command -v mysql-workbench)" ]; then
echo '# mysql-workbench is not installed. lets get some.'
echo ""
# Install MySql Workbench
# https://www.ubuntuupdates.org/package/core/artful/universe/base/mysql-workbench
sudo apt-get install mysql-workbench
else
echo '# mysql-workbench is allready installed'
#exit 1
fi
echo ""
echo "# phew ..."
echo ""
else
echo ""
echo " Nevermind... further installation is N/A for your computer."
fi
echo ""
echo "# Oh... and I also want you to have Typora, Pinta, Vlc, Atom.io and Node.js and Npm... "
echo "# just for good measure "
echo ""
echo "
###############################################################################
Extra-extra-bloat
Typora, Pinta, VLC, NodeJs, Atom-w-packages
###############################################################################
"
# Typora
# https://typora.io/#linux
echo "
# Typora
# https://typora.io/#linux
"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
sudo add-apt-repository 'deb https://typora.io linux/'
sudo apt-get update
sudo apt-get install typora
# Pinta
echo "
# Pinta
"
sudo add-apt-repository ppa:pinta-maintainers/pinta-stable
sudo apt-get update
sudo apt-get install pinta
# VLC
sudo apt-get update
sudo apt-get install vlc
# Node JS
# Latest Current Version: 9.11.1 (includes npm 5.6.0)
# https://nodejs.org/en/download/package-manager/
echo "
# Node JS
# Latest Current Version: 9.11.1 (includes npm 5.6.0)
# https://nodejs.org/en/download/package-manager/
"
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Optional: install build tools
sudo apt-get install -y build-essential
sudo apt-get update
# Atom.io
# https://flight-manual.atom.io/getting-started/sections/installing-atom/
echo "
# Atom.io
# https://flight-manual.atom.io/getting-started/sections/installing-atom/
"
curl -L https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
sudo apt-get update
# Install Atom
sudo apt-get install atom
# # Install Atom Beta
# sudo apt-get install atom-beta
# Alternatively, you can download the Atom .deb package and install it directly:
# # Install Atom
# sudo dpkg -i atom-amd64.deb
# # Install Atom's dependencies if they are missing
# sudo apt-get -f install
sudo apt-get update
# Atom Packages
# atom-beautify
# Atom Package: https://atom.io/packages/atom-beautify
apm install atom-beautify
# git-plus
# https://atom.io/packages/git-plus
apm install git-plus
# termination
# https://atom.io/packages/termination
apm install termination
sudo apt-get update
# file-icons
# https://atom.io/packages/file-icons
apm install file-icons
sudo apt-get update
# cmatrix
# just a fun terminal matrix movie thing
sudo apt-get install cmatrix
# Github User Credentials
echo "###############################################################################"
echo "# Getting Started - First-Time Git Setup"
echo "#"
echo "# https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup"
echo "#"
echo "# Enter the user name and email for linking to your remote repository"
echo "###############################################################################"
echo "# Existing user accounts on this machine:"
echo "#"
echo "# "git config --global user.name
echo "#"
echo "# Existing user account emails on this machine: "
echo "#"
echo "# "git config --global user.email
echo "#"
echo "#-----------------------------------------------------------------------------#"
echo "# > Enter your Github user.name... if you have one: "
read -p "# user.name: " globalusername
echo ""
echo "# > Enter your Github user.email:"
read -p "# user.email: " globaluseremail
myconfirm=''
while [[ $myconfirm != 'n' ]] || [[ $myconfirm != 'y' ]] || [[ $myconfirm != 'r' ]] || [[ $myconfirm == '' ]]
do
echo "#-----------------------------------------------------------------------------#"
echo "# > CONFIRMATION:"
echo "#"
echo "# Does this look right?"
echo "#"
echo "# git config --global user.name $globalusername"
echo "# git config --global user.email $globaluseremail"
echo "#"
echo "# [y] - Yes, Perform the Git setup"
echo "# [r] - No, Try Again"
echo "# [n] - No, exit"
echo ""
echo -n "# >> User Input:
Enter [y, n, or r]: "
read -n 1 myconfirm
echo ""
if [ $myconfirm == 'n' ]; then
reset
echo ""
echo "#-----------------------------------------------------------------------------#"
echo "EXIT SETUP"
echo "#-----------------------------------------------------------------------------#"
echo ""
echo -n "# >> Press any key to EXIT"
read exitVar
exit
elif [ $myconfirm == 'y' ]; then
echo ""
echo "# Commencing Automated Setup ..."
echo ""
git config --global user.name "$globalusername"
git config --global user.email "$globaluseremail"
break
elif [ $myconfirm == 'r' ]; then
echo "#-----------------------------------------------------------------------------#"
echo ""
echo "# > Enter your Github user.name... if you have one: "
read -p "# user.name: " globalusername
echo ""
echo "# > Enter your Github user.email:"
read -p "# user.email: " globaluseremail
else
echo "#-----------------------------------------------------------------------------#"
echo ""
echo "# enter one of the requested letters..."
fi
done
echo "###############################################################################"
echo "# Existing user accounts on this machine:"
git config --global user.name
echo ""
echo "# Existing user account emails on this machine: "
git config --global user.email
echo ""
echo "###############################################################################"
echo ""
echo "###############################################################################"
echo ""
echo "# Okay... now we are done. For now..."
echo ""

Git 1-2-3

a git cheat sheet

I usually use git-plus on Atom.io, but the Terminal UI provides the best results, especially when pushing/pulling with remote servers.


Config Git User

# Install Git if needed
# sudo apt install git-all

add-apt-repository ppa:git-core/ppa
apt update; apt install git

# Once installed, initialize your credentials
# this is important when working with remote repositories

git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"

Import a Github Repository

# Adding Remote Repositories
# note: the url will be automatically stored into the 'origin' variable

git clone 'https://github.com/thatuser/thatrepo'

# when you are ready to make modifications
# or ready to just start using Git to interface with that Repo
# declare an initialization on/within that Directory

git init

Switch between branches

# view branches within your active Repo

git branch

# checkout the branch you want from the list
# that branch is like the init for that Dir until your checkout some other branch

git checkout 'the-desired-branch-name'

# Create a new branch

git checkout -b 'new-created-branch-name'

Update existing local repo from github

# Import latest data from your Remote repo counterpart
# in this case Remote origin to local master

git pull origin master

# or
# With the rebase command, you can take all the changes that were committed on one branch and replay them on another one.
# https://git-scm.com/book/en/v2/Git-Branching-Rebasing

git pull --rebase origin master

Basic Merging

# Go to the branch I want to Update, in this case 'master'

git checkout master

# OPTIONAL: you can also see the remote branch variable names

git remote -v

# Pull in all the changes made from 'dev branch' into the 'master'
git merge 'theotherbranchname'

Stage files and commit to all changes made

# view modified files since the last commit
git status

# view the files in the list and select the files  whose changes you want committed
# also leave a comment for -Blame tracking

git add 'your file as listed in status list'

# OPTIONAL: you can also unstage/undo that file change, if you want
git reset -- 'your file as listed in status list'

# when you are ready to finalize your actions
git commit -m "an appropriate comment that represents the changes made"

Push local to remote

# this only works if Github all ready has that repo destination
# you can not make a new Repo Locally and then send it, Github needs an existing repo waiting for you

git push origin master

# But... if you did want to start everything from your Local Computer, then...
# I avoid this. When I have web access, I prefer to just setup Github first.

git remote add origin 'the desination remote repository URL'

# verify the url is in place

git remote -v

# then

git push origin master

Bouns:

Make .sh executable

## With a shebang in your file header, ex: #!/bin/bash
## enter this in terminal

chmod u+x [mypath]/myBashScriptFile.sh

I love lamp?

New Debian Disro Install

sudo apt update && sudo apt install lamp-server^

reset apache

sudo service apache2 restart

Prefered Legacy Tools

  • MySql Workbench
  • phpMyAdmin

check batter in php

sudo apt-get install acpi

LAN RDP/VNC Win-Linux

Server: tightvncserver

# install
sudo apt install tightvncserver
#start
vncserver

#kill
vncserver -kill :1

Client: Remmina-vnc

remember to enable Desktop sharing on Linux

sudo apt-add-repository ppa:remmina-ppa-team/remmina-next
sudo apt-get update
sudo apt-get install remmina remmina-plugin-rdp remmina-plugin-secret

PuTTY:

# ensure red and ssh is on linux server
sudo apt-get install openssh-server
sudo apt install xrdp

# battery utility for php power calculations
mstsc

Putty setup

Session

host-ip: the linux ip, port:22

Connection

  SSH
  
    Tunnels
    
      source port: any free port, ex: 5555

      destination: localhost with one uof your listening ports, ex: 3389

Win 10 Remote Desktop Client:

mstsc

localhost:5555

Remote Terminal UI

PHP Server Website Drives

When using Xfce, drives will not automatically mount on startup. This is bad when your working without a monitor. It is neglegant when you do have a monitor. I programmed a startup routine to handle this.

The OS drive does mount, and so does the SSD/HDD, but the micoSD needs a little help.

This is the startup macro on the Kangaroo Mini:

udisksctl mount -b /dev/mmcblk1p1

GUI

For my 'pocket server' i want want light and fast. Other than command line terminal... xfce is the next fastes thing at my disposal

I use both, but when you just need a GUI, remote vnc does the trick

Here are some styles I like to look at while GUI-ing

light weight linux theme components

MacBuntu OS Y Theme, Icons and cursors:

sudo add-apt-repository ppa:noobslab/macbuntu 
sudo apt-get update 
sudo apt-get install macbuntu-os-icons-lts-v7 
sudo apt-get install macbuntu-os-ithemes-lts-v7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment