Compare commits
3 Commits
18d7743cae
...
cb356b630b
Author | SHA1 | Date | |
---|---|---|---|
cb356b630b | |||
b5804afbc2 | |||
2f671fb09d |
@ -60,7 +60,7 @@ apt_install() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pip_install() {
|
pip_install() {
|
||||||
pip install --user $1 &> /dev/null
|
pip install --user $1 > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
export PATH=~/.local/bin:$PATH
|
export PATH=~/.local/bin:$PATH
|
||||||
@ -148,4 +148,4 @@ missing conduit && agree "Install conduit" && \
|
|||||||
echo "To use install pip packages update your PATH:"
|
echo "To use install pip packages update your PATH:"
|
||||||
echo 'export PATH=~/.local/bin:$PATH'
|
echo 'export PATH=~/.local/bin:$PATH'
|
||||||
|
|
||||||
[ -f $0 ] && agree "Remove $0" "N" && rm $0
|
[ -f $0 ] && agree "Remove $0" "N" && rm $0 || exit 0
|
||||||
|
@ -131,7 +131,7 @@ def install_conduit():
|
|||||||
path.append(r'C:\tools\cmder\vendor\git-for-windows\bin')
|
path.append(r'C:\tools\cmder\vendor\git-for-windows\bin')
|
||||||
environ['PATH'] = ';'.join(path)
|
environ['PATH'] = ';'.join(path)
|
||||||
call([r'C:\Python27\Scripts\pip.exe', 'install',
|
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__':
|
if __name__ == '__main__':
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
show_usage() {
|
show_usage() {
|
||||||
echo "usage: $0 [-h] [-d]"
|
echo "usage: $0 [-h] [-y]"
|
||||||
}
|
}
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
@ -13,7 +13,7 @@ show_help() {
|
|||||||
echo
|
echo
|
||||||
echo "* Xcode command line developer tools"
|
echo "* Xcode command line developer tools"
|
||||||
echo "* Homebrew - package manager"
|
echo "* Homebrew - package manager"
|
||||||
echo "* Python - from Homebrew"
|
echo "* python - from Homebrew"
|
||||||
echo "* virtualenv - from pip"
|
echo "* virtualenv - from pip"
|
||||||
echo "* SSH key - from ssh-keygen"
|
echo "* SSH key - from ssh-keygen"
|
||||||
echo "* GitHub public key - with SSH key"
|
echo "* GitHub public key - with SSH key"
|
||||||
@ -23,89 +23,77 @@ show_help() {
|
|||||||
echo
|
echo
|
||||||
echo "optional arguments:"
|
echo "optional arguments:"
|
||||||
echo " -h show this help message and exit"
|
echo " -h show this help message and exit"
|
||||||
echo " -d dry run, don't actuall install anything"
|
echo " -y assume yes when prompted"
|
||||||
}
|
}
|
||||||
|
|
||||||
dry=0
|
yes=0
|
||||||
|
|
||||||
while getopts 'hd' opt; do
|
while getopts 'hy' opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h)
|
h) show_help; exit 0 ;;
|
||||||
show_help
|
y) yes=1 ;;
|
||||||
exit 0
|
*) show_usage; exit 1 ;;
|
||||||
;;
|
|
||||||
d)
|
|
||||||
dry=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
show_usage
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $dry -eq 1 ]; then
|
missing() {
|
||||||
echo "OPERATING IN DRY RUN MODE!"
|
which $1 &> /dev/null && return 1 || return 0
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
# Install Xcode command line developer tools
|
|
||||||
if ! xcode-select --print-path &> /dev/null; then
|
if ! xcode-select --print-path &> /dev/null; then
|
||||||
if [ $dry -eq 1 ]; then
|
agree "Install Xcode command line developer tools" && xcode-select --install
|
||||||
xcode-select --install
|
|
||||||
fi
|
|
||||||
echo "Installed: Xcode command line developer tools"
|
|
||||||
else
|
|
||||||
echo "Satisfied: Xcode command line developer tools"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Homebrew
|
missing brew && agree "Intalll Homebrew" && /usr/bin/ruby -e \
|
||||||
if ! brew help &> /dev/null; then
|
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||||
if [ $dry -eq 0 ]; then
|
|
||||||
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
agree "Update Homebrew packages" && brew update > /dev/null
|
||||||
fi
|
|
||||||
echo "Installed: Homebrew"
|
if missing /usr/local/bin/python2 && agree "Install Homebrew python"; then
|
||||||
else
|
brew_install python
|
||||||
echo "Satisfied: Homebrew"
|
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'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Python
|
missing virtualenv && agree "Install virtualenv" && pip_install virtualenv
|
||||||
if [ ! -f /usr/local/bin/python ]; then
|
|
||||||
if [ $dry -eq 0 ]; then
|
|
||||||
brew install python
|
|
||||||
fi
|
|
||||||
echo "Installed: Python"
|
|
||||||
else
|
|
||||||
echo "Satisfied: Python"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install virtualenv
|
if [ ! -f ~/.ssh/id_rsa ] && agree "Generate SSH key"; then
|
||||||
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
|
read -rp "SSH email: " email
|
||||||
mkdir ~/.ssh
|
[ ! -d ~/.ssh ] && mkdir -p ~/.ssh
|
||||||
if [ $dry -eq 0 ]; then
|
ssh-keygen -t rsa -b 4096 -C "$email" -N "" -f ~/.ssh/id_rsa
|
||||||
ssh-keygen -t rsa -b 4096 -C "$email" -N "" -f ~/.ssh/id_rsa
|
|
||||||
fi
|
|
||||||
echo "Generated: SSH key"
|
|
||||||
else
|
|
||||||
echo "Satisfied: SSH key"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# GitHub public key
|
if ! missing virtualenv && agree "GitHub public key"; then
|
||||||
env=$(mktemp -d)
|
env=$(mktemp -d)
|
||||||
virtualenv $env &> /dev/null
|
virtualenv $env &> /dev/null
|
||||||
source $env/bin/activate
|
source $env/bin/activate
|
||||||
pip install githubpy &> /dev/null
|
pip install githubpy &> /dev/null
|
||||||
python <(cat << EOF
|
python <(cat << EOF
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from os import environ
|
from os import environ
|
||||||
from os.path import join
|
from os.path import join
|
||||||
@ -142,28 +130,28 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
exit(1)
|
exit(130)
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
deactivate
|
deactivate
|
||||||
rm -r $env
|
rm -r $env
|
||||||
|
|
||||||
# Prompt user to setup other SSH key recipients
|
|
||||||
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
|
fi
|
||||||
|
|
||||||
echo "Completed: $0 will now be removed"
|
# TODO: Gogs SSH key
|
||||||
if [ -f $0 ]; then rm $0; fi
|
|
||||||
|
# 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: "
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user