Compare commits

..

3 Commits

Author SHA1 Message Date
18d7743cae Add bootstrap-Windows.cmd
usage: bootstrap-Windows.cmd [/?]

Bootstrap a macOS instance with:

* Windows SDK - from MSDN
* Chocolatey - package manager
* Git - from Chocolatey
* Python - from Chocolatey
* virtualenv - from pip
* SSH key - from ssh-keygen
* GitHub public key - with SSH key
* conduit - configuration manager

optional arguments:
        /?              show this help message and exit
2017-12-04 16:15:58 +00:00
6efb08da3c Add bootstrap-Ubuntu.sh
usage: ./bootstrap-Ubuntu.sh [-h] [-y]

Bootstrap a Ubuntu or Linux Mint instance with:

* update apt cache
* upgrade apt packages
* git - from apt
* python - from apt
* python-pip - from apt
* virtualenv - from pip
* SSH key - from ssh-keygen
* GitHub public key - with SSH key
* conduit - configuration manager

If any already exist they will not be reinstalled.

optional arguments:
        -h              show this help message and exit
        -y              assume yes when prompted
2017-12-04 16:15:54 +00:00
53af32ecd7 Add bootstrap-macOS.sh
usage: ./bootstrap-macOS.sh [-h] [-d]

Bootstrap a macOS instance with:

* Xcode command line developer tools
* Homebrew - package manager
* Python - from Homebrew
* virtualenv - from pip
* SSH key - from ssh-keygen
* GitHub public key - with SSH key
* conduit - configuration manager

If any already exist they will not be reinstalled.

optional arguments:
        -h              show this help message and exit
        -d              dry run, don't actuall install anything
2017-11-25 15:30:44 +00:00
3 changed files with 90 additions and 78 deletions

View File

@ -60,7 +60,7 @@ apt_install() {
}
pip_install() {
pip install --user $1 > /dev/null
pip install --user $1 &> /dev/null
}
export PATH=~/.local/bin:$PATH
@ -148,4 +148,4 @@ missing conduit && agree "Install conduit" && \
echo "To use install pip packages update your PATH:"
echo 'export PATH=~/.local/bin:$PATH'
[ -f $0 ] && agree "Remove $0" "N" && rm $0 || exit 0
[ -f $0 ] && agree "Remove $0" "N" && rm $0

View File

@ -131,7 +131,7 @@ def install_conduit():
path.append(r'C:\tools\cmder\vendor\git-for-windows\bin')
environ['PATH'] = ';'.join(path)
call([r'C:\Python27\Scripts\pip.exe', 'install',
'git+ssh://git@github.com/kbenzie/conduit.git'])
'git+ssh://git@github.com:kbenzie/conduit.git'])
if __name__ == '__main__':

View File

@ -3,7 +3,7 @@
set -e
show_usage() {
echo "usage: $0 [-h] [-y]"
echo "usage: $0 [-h] [-d]"
}
show_help() {
@ -13,7 +13,7 @@ show_help() {
echo
echo "* Xcode command line developer tools"
echo "* Homebrew - package manager"
echo "* python - from Homebrew"
echo "* Python - from Homebrew"
echo "* virtualenv - from pip"
echo "* SSH key - from ssh-keygen"
echo "* GitHub public key - with SSH key"
@ -23,77 +23,89 @@ show_help() {
echo
echo "optional arguments:"
echo " -h show this help message and exit"
echo " -y assume yes when prompted"
echo " -d dry run, don't actuall install anything"
}
yes=0
dry=0
while getopts 'hy' opt; do
while getopts 'hd' opt; do
case $opt in
h) show_help; exit 0 ;;
y) yes=1 ;;
*) show_usage; exit 1 ;;
h)
show_help
exit 0
;;
d)
dry=1
;;
*)
show_usage
exit 1
;;
esac
done
missing() {
which $1 &> /dev/null && return 1 || return 0
}
agree() {
local check=^[Nn]$
[ $yes -eq 1 ] && [[ ! "$2" =~ $check ]] && return 0
[[ "$2" =~ $check ]] && local default="[y/N]" || local default="[Y/n]"
read -p "$1 $default? " answer
case "$answer" in
y|Y|yes) return 0 ;;
n|N|no) return 1 ;;
'') [[ "$2" =~ $check ]] && return 1 || return 0 ;;
*) echo "invalid input: $answer" && return `agree "$1"` ;;
esac
}
brew_install() {
brew install $1 > /dev/null
}
pip_install() {
pip install --user $1 > /dev/null
}
export PATH=~/.local/bin:$PATH
export PYTHONUSERBASE=~/.local
if [ $dry -eq 1 ]; then
echo "OPERATING IN DRY RUN MODE!"
fi
# Install Xcode command line developer tools
if ! xcode-select --print-path &> /dev/null; then
agree "Install Xcode command line developer tools" && xcode-select --install
if [ $dry -eq 1 ]; then
xcode-select --install
fi
echo "Installed: Xcode command line developer tools"
else
echo "Satisfied: Xcode command line developer tools"
fi
missing brew && agree "Intalll Homebrew" && /usr/bin/ruby -e \
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
agree "Update Homebrew packages" && brew update > /dev/null
if missing /usr/local/bin/python2 && agree "Install Homebrew python"; then
brew_install python
export PATH=/usr/local/opt/python/libexec/bin:$PATH
echo "To use Homebrew python update your PATH:"
echo 'export PATH=/usr/local/opt/python/libexec/bin:$PATH'
# Install Homebrew
if ! brew help &> /dev/null; then
if [ $dry -eq 0 ]; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
echo "Installed: Homebrew"
else
echo "Satisfied: Homebrew"
fi
missing virtualenv && agree "Install virtualenv" && pip_install virtualenv
# Install Python
if [ ! -f /usr/local/bin/python ]; then
if [ $dry -eq 0 ]; then
brew install python
fi
echo "Installed: Python"
else
echo "Satisfied: Python"
fi
if [ ! -f ~/.ssh/id_rsa ] && agree "Generate SSH key"; then
# Install virtualenv
if [ ! -f /usr/local/bin/virtualenv ]; then
if [ $dry -eq 0 ]; then
pip install virtualenv &> /dev/null
fi
echo "Installed: virtualenv"
else
echo "Satisfied: virtualenv"
fi
# Generate SSH key
if [ ! -f ~/.ssh/id_rsa ]; then
read -rp "SSH email: " email
[ ! -d ~/.ssh ] && mkdir -p ~/.ssh
ssh-keygen -t rsa -b 4096 -C "$email" -N "" -f ~/.ssh/id_rsa
mkdir ~/.ssh
if [ $dry -eq 0 ]; then
ssh-keygen -t rsa -b 4096 -C "$email" -N "" -f ~/.ssh/id_rsa
fi
echo "Generated: SSH key"
else
echo "Satisfied: SSH key"
fi
if ! missing virtualenv && agree "GitHub public key"; then
env=$(mktemp -d)
virtualenv $env &> /dev/null
source $env/bin/activate
pip install githubpy &> /dev/null
python <(cat << EOF
# GitHub public key
env=$(mktemp -d)
virtualenv $env &> /dev/null
source $env/bin/activate
pip install githubpy &> /dev/null
python <(cat << EOF
from __future__ import print_function
from os import environ
from os.path import join
@ -130,28 +142,28 @@ if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit(130)
exit(1)
EOF
)
deactivate
rm -r $env
fi
# TODO: Gogs SSH key
)
deactivate
rm -r $env
# Prompt user to setup other SSH key recipients
if [ -f ~/.ssh/id_rsa.pub ]; then
echo '----------------------------------------------------------------------'
cat ~/.ssh/id_rsa.pub
echo '----------------------------------------------------------------------'
read -rp "Set other SSH key recipients, press ENTER to continue: "
echo '----------------------------------------------------------------------'
cat ~/.ssh/id_rsa.pub
echo '----------------------------------------------------------------------'
read -rp "Set other SSH key recipients, press ENTER to continue: "
# Install conduit
if ! python -c 'import conduit' &> /dev/null; then
if [ $dry -eq 0 ]; then
pip install git+ssh://git@github.com:kbenzie/conduit.git
fi
echo "Installed: conduit"
else
echo "Satisfied: conduit"
fi
! missing pip && missing conduit && agree "Install conduit" && \
pip_install git+ssh://git@github.com/kbenzie/conduit.git
echo "To use installed pip packages update your PATH and PYTHONUSERBASE:"
echo 'export PATH=~/.local/bin:$PATH && export PYTHONUSERBASE=~/.local'
[ -f $0 ] && agree "Remove $0" "N" && rm $0 || exit 0
echo "Completed: $0 will now be removed"
if [ -f $0 ]; then rm $0; fi