-
Notifications
You must be signed in to change notification settings - Fork 8
/
ezsetup
executable file
·98 lines (86 loc) · 2.68 KB
/
ezsetup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#*****************************************************************
# Copyright (c) 2013 The 6Th Column Project, LLC
# All rights reserved.
# http://6thcolumn.org/LICENSE
#*****************************************************************
#
# Organization: CodeWrx
# Directorate: Computation
# Department: Computing Applications and Research
# Program: Tom Foolery
# Project: BASH-FOO
# First Author: Gavin M. Bell ([email protected])
#
# Description:
# A clean and easy way to setup your bash environment that is hassle free.
# We use lots of different machines... it makes it less painful
#
# Sets up dot bash files in your home directory
#
#*****************************************************************
do_fetch_n_setup() {
echo -n "checking for git... "
local v=$(git --version 2> /dev/null)
[ $? != 0 ] || [ -z "${v}" ] && echo "Sorry, you need git to run this installer" && exit 1
echo "[OK]"
#Okay so now let's do some installation magic...
local __destination=${1:-${__destination:-${HOME:-~}}} >& /dev/null
shift
echo "destination = ${__destination}"
[ ! -d "${__destination}" ] && echo "Sorry this installation destination does not exist" && exit 2
#[ ! -f "${__destination}/.git/config" ] && echo "Sorry this location is already under git source control" && exit 3
git clone git://github.com/gavinmbell/bash_resources.git ${__destination}/.bash_resources # 2> /dev/null
cd ${__destination}/.bash_resources
./setup $@ && echo "ezsetup complete"
}
_usage() {
printf "
Usage:
> ezsetup <top level dir to checkout repo> [flags]
--install - Runs the installation process [default]
--revert - Uninstalls the system [not yet implemented]
--help|-h - Prints this help message
--debug - Runs in debug mode (more output)
--dry-run - Will not perform operations but will print what would be done
"
exit 0
}
main() {
while [ -n "$1" ]; do
case "$1" in
--install)
shift
INSTALL=1
;;
--revert)
shift
REVERT=1
;;
--help|-h)
_usage
;;
--debug)
shift
DEBUG=1
;;
--force)
shift
FORCE=1
;;
--dry-run)
shift
DRY_RUN=1
;;
*)
echo "Unknown option $1"
exit 1
esac
done
((DEBUG)) && echo "Debug mode on"
((DRY_RUN)) && echo "Dry run mode on"
if ((REVERT)); then revert_homedir; exit $?; fi
#Functions that peform the installtion....
do_fetch_n_setup $@
}
main $@